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,3951 +0,0 @@
1
- import { promises, existsSync } from 'node:fs';
2
- import posix from '../chunks/index10.mjs';
3
- import { glob } from 'tinyglobby';
4
- import { p as parse } from './ccjk.BBtCGd_g.mjs';
5
- import { CLOUD_ENDPOINTS } from '../chunks/constants.mjs';
6
-
7
- const LogLevels = {
8
- fatal: 0,
9
- error: 0,
10
- warn: 1,
11
- log: 2,
12
- info: 3,
13
- success: 3,
14
- fail: 3,
15
- debug: 4,
16
- trace: 5,
17
- verbose: Number.POSITIVE_INFINITY
18
- };
19
- const LogTypes = {
20
- // Silent
21
- silent: {
22
- level: -1
23
- },
24
- // Level 0
25
- fatal: {
26
- level: LogLevels.fatal
27
- },
28
- error: {
29
- level: LogLevels.error
30
- },
31
- // Level 1
32
- warn: {
33
- level: LogLevels.warn
34
- },
35
- // Level 2
36
- log: {
37
- level: LogLevels.log
38
- },
39
- // Level 3
40
- info: {
41
- level: LogLevels.info
42
- },
43
- success: {
44
- level: LogLevels.success
45
- },
46
- fail: {
47
- level: LogLevels.fail
48
- },
49
- ready: {
50
- level: LogLevels.info
51
- },
52
- start: {
53
- level: LogLevels.info
54
- },
55
- box: {
56
- level: LogLevels.info
57
- },
58
- // Level 4
59
- debug: {
60
- level: LogLevels.debug
61
- },
62
- // Level 5
63
- trace: {
64
- level: LogLevels.trace
65
- },
66
- // Verbose
67
- verbose: {
68
- level: LogLevels.verbose
69
- }
70
- };
71
-
72
- function isPlainObject$1(value) {
73
- if (value === null || typeof value !== "object") {
74
- return false;
75
- }
76
- const prototype = Object.getPrototypeOf(value);
77
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
78
- return false;
79
- }
80
- if (Symbol.iterator in value) {
81
- return false;
82
- }
83
- if (Symbol.toStringTag in value) {
84
- return Object.prototype.toString.call(value) === "[object Module]";
85
- }
86
- return true;
87
- }
88
-
89
- function _defu(baseObject, defaults, namespace = ".", merger) {
90
- if (!isPlainObject$1(defaults)) {
91
- return _defu(baseObject, {}, namespace);
92
- }
93
- const object = Object.assign({}, defaults);
94
- for (const key in baseObject) {
95
- if (key === "__proto__" || key === "constructor") {
96
- continue;
97
- }
98
- const value = baseObject[key];
99
- if (value === null || value === void 0) {
100
- continue;
101
- }
102
- if (Array.isArray(value) && Array.isArray(object[key])) {
103
- object[key] = [...value, ...object[key]];
104
- } else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
105
- object[key] = _defu(
106
- value,
107
- object[key],
108
- (namespace ? `${namespace}.` : "") + key.toString());
109
- } else {
110
- object[key] = value;
111
- }
112
- }
113
- return object;
114
- }
115
- function createDefu(merger) {
116
- return (...arguments_) => (
117
- // eslint-disable-next-line unicorn/no-array-reduce
118
- arguments_.reduce((p, c) => _defu(p, c, ""), {})
119
- );
120
- }
121
- const defu = createDefu();
122
-
123
- function isPlainObject(obj) {
124
- return Object.prototype.toString.call(obj) === "[object Object]";
125
- }
126
- function isLogObj(arg) {
127
- if (!isPlainObject(arg)) {
128
- return false;
129
- }
130
- if (!arg.message && !arg.args) {
131
- return false;
132
- }
133
- if (arg.stack) {
134
- return false;
135
- }
136
- return true;
137
- }
138
-
139
- let paused = false;
140
- const queue = [];
141
- class Consola {
142
- options;
143
- _lastLog;
144
- _mockFn;
145
- /**
146
- * Creates an instance of Consola with specified options or defaults.
147
- *
148
- * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
149
- */
150
- constructor(options = {}) {
151
- const types = options.types || LogTypes;
152
- this.options = defu(
153
- {
154
- ...options,
155
- defaults: { ...options.defaults },
156
- level: _normalizeLogLevel(options.level, types),
157
- reporters: [...options.reporters || []]
158
- },
159
- {
160
- types: LogTypes,
161
- throttle: 1e3,
162
- throttleMin: 5,
163
- formatOptions: {
164
- date: true,
165
- colors: false,
166
- compact: true
167
- }
168
- }
169
- );
170
- for (const type in types) {
171
- const defaults = {
172
- type,
173
- ...this.options.defaults,
174
- ...types[type]
175
- };
176
- this[type] = this._wrapLogFn(defaults);
177
- this[type].raw = this._wrapLogFn(
178
- defaults,
179
- true
180
- );
181
- }
182
- if (this.options.mockFn) {
183
- this.mockTypes();
184
- }
185
- this._lastLog = {};
186
- }
187
- /**
188
- * Gets the current log level of the Consola instance.
189
- *
190
- * @returns {number} The current log level.
191
- */
192
- get level() {
193
- return this.options.level;
194
- }
195
- /**
196
- * Sets the minimum log level that will be output by the instance.
197
- *
198
- * @param {number} level - The new log level to set.
199
- */
200
- set level(level) {
201
- this.options.level = _normalizeLogLevel(
202
- level,
203
- this.options.types,
204
- this.options.level
205
- );
206
- }
207
- /**
208
- * Displays a prompt to the user and returns the response.
209
- * Throw an error if `prompt` is not supported by the current configuration.
210
- *
211
- * @template T
212
- * @param {string} message - The message to display in the prompt.
213
- * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
214
- * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
215
- */
216
- prompt(message, opts) {
217
- if (!this.options.prompt) {
218
- throw new Error("prompt is not supported!");
219
- }
220
- return this.options.prompt(message, opts);
221
- }
222
- /**
223
- * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
224
- *
225
- * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
226
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
227
- */
228
- create(options) {
229
- const instance = new Consola({
230
- ...this.options,
231
- ...options
232
- });
233
- if (this._mockFn) {
234
- instance.mockTypes(this._mockFn);
235
- }
236
- return instance;
237
- }
238
- /**
239
- * Creates a new Consola instance with the specified default log object properties.
240
- *
241
- * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
242
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
243
- */
244
- withDefaults(defaults) {
245
- return this.create({
246
- ...this.options,
247
- defaults: {
248
- ...this.options.defaults,
249
- ...defaults
250
- }
251
- });
252
- }
253
- /**
254
- * Creates a new Consola instance with a specified tag, which will be included in every log.
255
- *
256
- * @param {string} tag - The tag to include in each log of the new instance.
257
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
258
- */
259
- withTag(tag) {
260
- return this.withDefaults({
261
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
262
- });
263
- }
264
- /**
265
- * Adds a custom reporter to the Consola instance.
266
- * Reporters will be called for each log message, depending on their implementation and log level.
267
- *
268
- * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
269
- * @returns {Consola} The current Consola instance.
270
- */
271
- addReporter(reporter) {
272
- this.options.reporters.push(reporter);
273
- return this;
274
- }
275
- /**
276
- * Removes a custom reporter from the Consola instance.
277
- * If no reporter is specified, all reporters will be removed.
278
- *
279
- * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
280
- * @returns {Consola} The current Consola instance.
281
- */
282
- removeReporter(reporter) {
283
- if (reporter) {
284
- const i = this.options.reporters.indexOf(reporter);
285
- if (i !== -1) {
286
- return this.options.reporters.splice(i, 1);
287
- }
288
- } else {
289
- this.options.reporters.splice(0);
290
- }
291
- return this;
292
- }
293
- /**
294
- * Replaces all reporters of the Consola instance with the specified array of reporters.
295
- *
296
- * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
297
- * @returns {Consola} The current Consola instance.
298
- */
299
- setReporters(reporters) {
300
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
301
- return this;
302
- }
303
- wrapAll() {
304
- this.wrapConsole();
305
- this.wrapStd();
306
- }
307
- restoreAll() {
308
- this.restoreConsole();
309
- this.restoreStd();
310
- }
311
- /**
312
- * Overrides console methods with Consola logging methods for consistent logging.
313
- */
314
- wrapConsole() {
315
- for (const type in this.options.types) {
316
- if (!console["__" + type]) {
317
- console["__" + type] = console[type];
318
- }
319
- console[type] = this[type].raw;
320
- }
321
- }
322
- /**
323
- * Restores the original console methods, removing Consola overrides.
324
- */
325
- restoreConsole() {
326
- for (const type in this.options.types) {
327
- if (console["__" + type]) {
328
- console[type] = console["__" + type];
329
- delete console["__" + type];
330
- }
331
- }
332
- }
333
- /**
334
- * Overrides standard output and error streams to redirect them through Consola.
335
- */
336
- wrapStd() {
337
- this._wrapStream(this.options.stdout, "log");
338
- this._wrapStream(this.options.stderr, "log");
339
- }
340
- _wrapStream(stream, type) {
341
- if (!stream) {
342
- return;
343
- }
344
- if (!stream.__write) {
345
- stream.__write = stream.write;
346
- }
347
- stream.write = (data) => {
348
- this[type].raw(String(data).trim());
349
- };
350
- }
351
- /**
352
- * Restores the original standard output and error streams, removing the Consola redirection.
353
- */
354
- restoreStd() {
355
- this._restoreStream(this.options.stdout);
356
- this._restoreStream(this.options.stderr);
357
- }
358
- _restoreStream(stream) {
359
- if (!stream) {
360
- return;
361
- }
362
- if (stream.__write) {
363
- stream.write = stream.__write;
364
- delete stream.__write;
365
- }
366
- }
367
- /**
368
- * Pauses logging, queues incoming logs until resumed.
369
- */
370
- pauseLogs() {
371
- paused = true;
372
- }
373
- /**
374
- * Resumes logging, processing any queued logs.
375
- */
376
- resumeLogs() {
377
- paused = false;
378
- const _queue = queue.splice(0);
379
- for (const item of _queue) {
380
- item[0]._logFn(item[1], item[2]);
381
- }
382
- }
383
- /**
384
- * Replaces logging methods with mocks if a mock function is provided.
385
- *
386
- * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
387
- */
388
- mockTypes(mockFn) {
389
- const _mockFn = mockFn || this.options.mockFn;
390
- this._mockFn = _mockFn;
391
- if (typeof _mockFn !== "function") {
392
- return;
393
- }
394
- for (const type in this.options.types) {
395
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
396
- this[type].raw = this[type];
397
- }
398
- }
399
- _wrapLogFn(defaults, isRaw) {
400
- return (...args) => {
401
- if (paused) {
402
- queue.push([this, defaults, args, isRaw]);
403
- return;
404
- }
405
- return this._logFn(defaults, args, isRaw);
406
- };
407
- }
408
- _logFn(defaults, args, isRaw) {
409
- if ((defaults.level || 0) > this.level) {
410
- return false;
411
- }
412
- const logObj = {
413
- date: /* @__PURE__ */ new Date(),
414
- args: [],
415
- ...defaults,
416
- level: _normalizeLogLevel(defaults.level, this.options.types)
417
- };
418
- if (!isRaw && args.length === 1 && isLogObj(args[0])) {
419
- Object.assign(logObj, args[0]);
420
- } else {
421
- logObj.args = [...args];
422
- }
423
- if (logObj.message) {
424
- logObj.args.unshift(logObj.message);
425
- delete logObj.message;
426
- }
427
- if (logObj.additional) {
428
- if (!Array.isArray(logObj.additional)) {
429
- logObj.additional = logObj.additional.split("\n");
430
- }
431
- logObj.args.push("\n" + logObj.additional.join("\n"));
432
- delete logObj.additional;
433
- }
434
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
435
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
436
- const resolveLog = (newLog = false) => {
437
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
438
- if (this._lastLog.object && repeated > 0) {
439
- const args2 = [...this._lastLog.object.args];
440
- if (repeated > 1) {
441
- args2.push(`(repeated ${repeated} times)`);
442
- }
443
- this._log({ ...this._lastLog.object, args: args2 });
444
- this._lastLog.count = 1;
445
- }
446
- if (newLog) {
447
- this._lastLog.object = logObj;
448
- this._log(logObj);
449
- }
450
- };
451
- clearTimeout(this._lastLog.timeout);
452
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
453
- this._lastLog.time = logObj.date;
454
- if (diffTime < this.options.throttle) {
455
- try {
456
- const serializedLog = JSON.stringify([
457
- logObj.type,
458
- logObj.tag,
459
- logObj.args
460
- ]);
461
- const isSameLog = this._lastLog.serialized === serializedLog;
462
- this._lastLog.serialized = serializedLog;
463
- if (isSameLog) {
464
- this._lastLog.count = (this._lastLog.count || 0) + 1;
465
- if (this._lastLog.count > this.options.throttleMin) {
466
- this._lastLog.timeout = setTimeout(
467
- resolveLog,
468
- this.options.throttle
469
- );
470
- return;
471
- }
472
- }
473
- } catch {
474
- }
475
- }
476
- resolveLog(true);
477
- }
478
- _log(logObj) {
479
- for (const reporter of this.options.reporters) {
480
- reporter.log(logObj, {
481
- options: this.options
482
- });
483
- }
484
- }
485
- }
486
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
487
- if (input === void 0) {
488
- return defaultLevel;
489
- }
490
- if (typeof input === "number") {
491
- return input;
492
- }
493
- if (types[input] && types[input].level !== void 0) {
494
- return types[input].level;
495
- }
496
- return defaultLevel;
497
- }
498
- Consola.prototype.add = Consola.prototype.addReporter;
499
- Consola.prototype.remove = Consola.prototype.removeReporter;
500
- Consola.prototype.clear = Consola.prototype.removeReporter;
501
- Consola.prototype.withScope = Consola.prototype.withTag;
502
- Consola.prototype.mock = Consola.prototype.mockTypes;
503
- Consola.prototype.pause = Consola.prototype.pauseLogs;
504
- Consola.prototype.resume = Consola.prototype.resumeLogs;
505
- function createConsola$1(options = {}) {
506
- return new Consola(options);
507
- }
508
-
509
- class BrowserReporter {
510
- options;
511
- defaultColor;
512
- levelColorMap;
513
- typeColorMap;
514
- constructor(options) {
515
- this.options = { ...options };
516
- this.defaultColor = "#7f8c8d";
517
- this.levelColorMap = {
518
- 0: "#c0392b",
519
- // Red
520
- 1: "#f39c12",
521
- // Yellow
522
- 3: "#00BCD4"
523
- // Cyan
524
- };
525
- this.typeColorMap = {
526
- success: "#2ecc71"
527
- // Green
528
- };
529
- }
530
- _getLogFn(level) {
531
- if (level < 1) {
532
- return console.__error || console.error;
533
- }
534
- if (level === 1) {
535
- return console.__warn || console.warn;
536
- }
537
- return console.__log || console.log;
538
- }
539
- log(logObj) {
540
- const consoleLogFn = this._getLogFn(logObj.level);
541
- const type = logObj.type === "log" ? "" : logObj.type;
542
- const tag = logObj.tag || "";
543
- const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
544
- const style = `
545
- background: ${color};
546
- border-radius: 0.5em;
547
- color: white;
548
- font-weight: bold;
549
- padding: 2px 0.5em;
550
- `;
551
- const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
552
- if (typeof logObj.args[0] === "string") {
553
- consoleLogFn(
554
- `${badge}%c ${logObj.args[0]}`,
555
- style,
556
- // Empty string as style resets to default console style
557
- "",
558
- ...logObj.args.slice(1)
559
- );
560
- } else {
561
- consoleLogFn(badge, style, ...logObj.args);
562
- }
563
- }
564
- }
565
-
566
- function createConsola(options = {}) {
567
- const consola2 = createConsola$1({
568
- reporters: options.reporters || [new BrowserReporter({})],
569
- prompt(message, options2 = {}) {
570
- if (options2.type === "confirm") {
571
- return Promise.resolve(confirm(message));
572
- }
573
- return Promise.resolve(prompt(message));
574
- },
575
- ...options
576
- });
577
- return consola2;
578
- }
579
- const consola = createConsola();
580
-
581
- async function pathExists$5(p) {
582
- try {
583
- await promises.access(p);
584
- return true;
585
- } catch {
586
- return false;
587
- }
588
- }
589
- async function readJson$1(p) {
590
- const content = await promises.readFile(p, "utf-8");
591
- return JSON.parse(content);
592
- }
593
- const logger$6 = consola.withTag("dependency-resolver");
594
- async function analyzeDependencies$1(analysis, config) {
595
- logger$6.info("Analyzing project dependencies");
596
- if (config.analyzeTransitiveDeps) {
597
- logger$6.warn(
598
- 'Transitive dependency analysis requested but not fully implemented. The "all" field will only contain direct dependencies. See dependency-resolver.ts for details.'
599
- );
600
- }
601
- const projectPath = analysis.rootPath;
602
- const packageManager = analysis.packageManager;
603
- analysis.languages;
604
- let direct = [];
605
- let all = [];
606
- if (packageManager === "npm" || packageManager === "yarn" || packageManager === "pnpm" || packageManager === "bun") {
607
- const npmDeps = await analyzeNpmDependencies(projectPath);
608
- direct = npmDeps.direct;
609
- all = npmDeps.all;
610
- } else if (packageManager === "pip" || packageManager === "poetry" || packageManager === "pipenv") {
611
- const pythonDeps = await analyzePythonDependencies(projectPath, packageManager);
612
- direct = pythonDeps.direct;
613
- all = pythonDeps.all;
614
- } else if (packageManager === "go") {
615
- const goDeps = await analyzeGoDependencies(projectPath);
616
- direct = goDeps.direct;
617
- all = goDeps.all;
618
- } else if (packageManager === "cargo") {
619
- const rustDeps = await analyzeRustDependencies(projectPath);
620
- direct = rustDeps.direct;
621
- all = rustDeps.all;
622
- }
623
- const graph = buildDependencyGraph(all);
624
- const installationPlan = generateInstallationPlan(all, packageManager);
625
- const conflicts = detectConflicts(all);
626
- const circularDeps = detectCircularDependencies(graph);
627
- logger$6.info(`Found ${direct.length} direct dependencies, ${all.length} total`);
628
- if (conflicts.length > 0) {
629
- logger$6.warn(`Found ${conflicts.length} dependency conflicts`);
630
- }
631
- if (circularDeps.length > 0) {
632
- logger$6.warn(`Found ${circularDeps.length} circular dependencies`);
633
- }
634
- return {
635
- direct,
636
- all,
637
- graph,
638
- installationPlan,
639
- conflicts,
640
- circularDeps
641
- };
642
- }
643
- async function analyzeNpmDependencies(projectPath) {
644
- const packageJsonPath = posix.join(projectPath, "package.json");
645
- if (!await pathExists$5(packageJsonPath)) {
646
- return { direct: [], all: [] };
647
- }
648
- try {
649
- const packageJson = await readJson$1(packageJsonPath);
650
- const direct = [];
651
- const processDeps = (deps2, isDev, isPeer) => {
652
- if (!deps2)
653
- return [];
654
- return Object.entries(deps2).map(([name, version]) => ({
655
- name,
656
- version,
657
- type: isDev ? "dev" : isPeer ? "peer" : "runtime",
658
- isDev,
659
- isPeer,
660
- isOptional: false
661
- }));
662
- };
663
- const deps = processDeps(packageJson.dependencies, false, false);
664
- const devDeps = processDeps(packageJson.devDependencies, true, false);
665
- const peerDeps = processDeps(packageJson.peerDependencies, false, true);
666
- const optionalDeps = processDeps(packageJson.optionalDependencies, false, false).map((d) => ({
667
- ...d,
668
- isOptional: true,
669
- type: "optional"
670
- }));
671
- direct.push(...deps, ...devDeps, ...peerDeps, ...optionalDeps);
672
- const all = [...direct];
673
- return { direct, all };
674
- } catch (error) {
675
- logger$6.warn("Failed to analyze npm dependencies:", error);
676
- return { direct: [], all: [] };
677
- }
678
- }
679
- async function analyzePythonDependencies(projectPath, packageManager) {
680
- const direct = [];
681
- const all = [];
682
- if (packageManager === "poetry") {
683
- const pyprojectPath = posix.join(projectPath, "pyproject.toml");
684
- if (await pathExists$5(pyprojectPath)) {
685
- try {
686
- const { parse } = await import('../chunks/index3.mjs');
687
- const content = await promises.readFile(pyprojectPath, "utf-8");
688
- const pyproject = parse(content);
689
- const deps = pyproject.tool?.poetry?.dependencies || {};
690
- const devDeps = pyproject.tool?.poetry?.["dev-dependencies"] || {};
691
- for (const [name, version] of Object.entries(deps)) {
692
- direct.push({
693
- name,
694
- version: typeof version === "string" ? version : "latest",
695
- type: "runtime",
696
- isDev: false,
697
- isPeer: false,
698
- isOptional: false
699
- });
700
- }
701
- for (const [name, version] of Object.entries(devDeps)) {
702
- direct.push({
703
- name,
704
- version: typeof version === "string" ? version : "latest",
705
- type: "dev",
706
- isDev: true,
707
- isPeer: false,
708
- isOptional: false
709
- });
710
- }
711
- } catch (error) {
712
- logger$6.warn("Failed to parse pyproject.toml:", error);
713
- }
714
- }
715
- } else if (packageManager === "pipenv") {
716
- const pipfilePath = posix.join(projectPath, "Pipfile");
717
- if (await pathExists$5(pipfilePath)) {
718
- try {
719
- const { parse } = await import('../chunks/index3.mjs');
720
- const content = await promises.readFile(pipfilePath, "utf-8");
721
- const pipfile = parse(content);
722
- const deps = pipfile.packages || {};
723
- const devDeps = pipfile["dev-packages"] || {};
724
- for (const [name, version] of Object.entries(deps)) {
725
- direct.push({
726
- name,
727
- version: typeof version === "string" ? version : "latest",
728
- type: "runtime",
729
- isDev: false,
730
- isPeer: false,
731
- isOptional: false
732
- });
733
- }
734
- for (const [name, version] of Object.entries(devDeps)) {
735
- direct.push({
736
- name,
737
- version: typeof version === "string" ? version : "latest",
738
- type: "dev",
739
- isDev: true,
740
- isPeer: false,
741
- isOptional: false
742
- });
743
- }
744
- } catch (error) {
745
- logger$6.warn("Failed to parse Pipfile:", error);
746
- }
747
- }
748
- } else {
749
- const requirementsPath = posix.join(projectPath, "requirements.txt");
750
- if (await pathExists$5(requirementsPath)) {
751
- try {
752
- const content = await promises.readFile(requirementsPath, "utf-8");
753
- const lines = content.split("\n");
754
- for (const line of lines) {
755
- const trimmed = line.trim();
756
- if (trimmed && !trimmed.startsWith("#")) {
757
- const match = trimmed.match(/^([\w-]+)([[~=><].*)?$/);
758
- if (match) {
759
- direct.push({
760
- name: match[1],
761
- version: match[2] || "latest",
762
- type: "runtime",
763
- isDev: false,
764
- isPeer: false,
765
- isOptional: false
766
- });
767
- }
768
- }
769
- }
770
- } catch (error) {
771
- logger$6.warn("Failed to parse requirements.txt:", error);
772
- }
773
- }
774
- }
775
- all.push(...direct);
776
- return { direct, all };
777
- }
778
- async function analyzeGoDependencies(projectPath) {
779
- const goModPath = posix.join(projectPath, "go.mod");
780
- if (!await pathExists$5(goModPath)) {
781
- return { direct: [], all: [] };
782
- }
783
- try {
784
- const content = await promises.readFile(goModPath, "utf-8");
785
- const lines = content.split("\n");
786
- const direct = [];
787
- let inRequireBlock = false;
788
- for (const line of lines) {
789
- const trimmed = line.trim();
790
- if (trimmed.startsWith("require (")) {
791
- inRequireBlock = true;
792
- continue;
793
- }
794
- if (inRequireBlock && trimmed === ")") {
795
- inRequireBlock = false;
796
- continue;
797
- }
798
- if (trimmed.startsWith("require ") || inRequireBlock) {
799
- const parts = trimmed.split(/\s+/);
800
- if (parts.length >= 2) {
801
- const name = parts[0].replace("require ", "");
802
- const version = parts[1];
803
- direct.push({
804
- name,
805
- version,
806
- type: "runtime",
807
- isDev: false,
808
- isPeer: false,
809
- isOptional: false
810
- });
811
- }
812
- }
813
- }
814
- const all = [...direct];
815
- return { direct, all };
816
- } catch (error) {
817
- logger$6.warn("Failed to analyze Go dependencies:", error);
818
- return { direct: [], all: [] };
819
- }
820
- }
821
- async function analyzeRustDependencies(projectPath) {
822
- const cargoTomlPath = posix.join(projectPath, "Cargo.toml");
823
- if (!await pathExists$5(cargoTomlPath)) {
824
- return { direct: [], all: [] };
825
- }
826
- try {
827
- const { parse } = await import('../chunks/index3.mjs');
828
- const content = await promises.readFile(cargoTomlPath, "utf-8");
829
- const cargoToml = parse(content);
830
- const direct = [];
831
- const processDeps = (deps2, isDev) => {
832
- if (!deps2)
833
- return [];
834
- return Object.entries(deps2).map(([name, version]) => ({
835
- name,
836
- version: typeof version === "string" ? version : version?.version || "latest",
837
- type: isDev ? "dev" : "runtime",
838
- isDev,
839
- isPeer: false,
840
- isOptional: false
841
- }));
842
- };
843
- const deps = processDeps(cargoToml.dependencies, false);
844
- const devDeps = processDeps(cargoToml["dev-dependencies"], true);
845
- const buildDeps = processDeps(cargoToml["build-dependencies"], false);
846
- direct.push(...deps, ...devDeps, ...buildDeps);
847
- const all = [...direct];
848
- return { direct, all };
849
- } catch (error) {
850
- logger$6.warn("Failed to analyze Rust dependencies:", error);
851
- return { direct: [], all: [] };
852
- }
853
- }
854
- function buildDependencyGraph(dependencies) {
855
- const graph = /* @__PURE__ */ new Map();
856
- for (const dep of dependencies) {
857
- graph.set(dep.name, []);
858
- }
859
- return graph;
860
- }
861
- function generateInstallationPlan(dependencies, packageManager) {
862
- const order = [...dependencies];
863
- const runtime = order.filter((d) => d.type === "runtime");
864
- order.filter((d) => d.type === "dev");
865
- order.filter((d) => d.type === "peer");
866
- order.filter((d) => d.type === "optional");
867
- const parallelizable = runtime.length;
868
- const commands = generateInstallationCommands(packageManager);
869
- return {
870
- order,
871
- total: dependencies.length,
872
- parallelizable,
873
- commands
874
- };
875
- }
876
- function generateInstallationCommands(packageManager) {
877
- if (!packageManager) {
878
- return {
879
- installAll: 'echo "Unknown package manager"',
880
- installPackage: () => 'echo "Unknown package manager"',
881
- installDev: 'echo "Unknown package manager"',
882
- add: () => 'echo "Unknown package manager"'
883
- };
884
- }
885
- const commands = {
886
- npm: {
887
- installAll: "npm install",
888
- installPackage: (name, version) => `npm install ${name}${version ? `@${version}` : ""}`,
889
- installDev: "npm install --only=dev",
890
- add: (name, isDev) => isDev ? `npm install -D ${name}` : `npm install ${name}`
891
- },
892
- yarn: {
893
- installAll: "yarn install",
894
- installPackage: (name, version) => `yarn add ${name}${version ? `@${version}` : ""}`,
895
- installDev: "yarn install --dev",
896
- add: (name, isDev) => isDev ? `yarn add -D ${name}` : `yarn add ${name}`
897
- },
898
- pnpm: {
899
- installAll: "pnpm install",
900
- installPackage: (name, version) => `pnpm add ${name}${version ? `@${version}` : ""}`,
901
- installDev: "pnpm install --dev",
902
- add: (name, isDev) => isDev ? `pnpm add -D ${name}` : `pnpm add ${name}`
903
- },
904
- bun: {
905
- installAll: "bun install",
906
- installPackage: (name, version) => `bun add ${name}${version ? `@${version}` : ""}`,
907
- installDev: "bun install --dev",
908
- add: (name, isDev) => isDev ? `bun add -d ${name}` : `bun add ${name}`
909
- },
910
- pip: {
911
- installAll: "pip install -r requirements.txt",
912
- installPackage: (name, version) => `pip install ${name}${version ? version.replace(/[*=]/, "==") : ""}`,
913
- installDev: "pip install -r requirements-dev.txt",
914
- add: (name) => `pip install ${name}`
915
- },
916
- poetry: {
917
- installAll: "poetry install",
918
- installPackage: (name, version) => `poetry add ${name}${version ? `=${version}` : ""}`,
919
- installDev: "poetry install --with dev",
920
- add: (name, isDev) => isDev ? `poetry add --group dev ${name}` : `poetry add ${name}`
921
- },
922
- pipenv: {
923
- installAll: "pipenv install",
924
- installPackage: (name, version) => `pipenv install ${name}${version ? `==${version}` : ""}`,
925
- installDev: "pipenv install --dev",
926
- add: (name, isDev) => isDev ? `pipenv install --dev ${name}` : `pipenv install ${name}`
927
- },
928
- go: {
929
- installAll: "go mod download",
930
- installPackage: (name) => `go get ${name}`,
931
- installDev: "go mod download",
932
- add: (name) => `go get ${name}`
933
- },
934
- cargo: {
935
- installAll: "cargo build",
936
- installPackage: (name, version) => `cargo add ${name}${version ? ` --vers ${version}` : ""}`,
937
- installDev: "cargo build",
938
- add: (name) => `cargo add ${name}`
939
- }
940
- };
941
- return commands[packageManager] || commands.npm;
942
- }
943
- function detectConflicts(dependencies, _graph) {
944
- const conflicts = [];
945
- const versionMap = /* @__PURE__ */ new Map();
946
- for (const dep of dependencies) {
947
- if (!versionMap.has(dep.name)) {
948
- versionMap.set(dep.name, /* @__PURE__ */ new Set());
949
- }
950
- versionMap.get(dep.name).add(dep.version);
951
- }
952
- for (const [name, versions] of versionMap) {
953
- if (versions.size > 1) {
954
- conflicts.push({
955
- package: name,
956
- versions: Array.from(versions),
957
- requiredBy: [name],
958
- severity: "warning"
959
- });
960
- }
961
- }
962
- return conflicts;
963
- }
964
- function detectCircularDependencies(graph) {
965
- const circular = [];
966
- const visited = /* @__PURE__ */ new Set();
967
- const recStack = /* @__PURE__ */ new Set();
968
- const path2 = [];
969
- const dfs = (node) => {
970
- visited.add(node);
971
- recStack.add(node);
972
- path2.push(node);
973
- const neighbors = graph.get(node) || [];
974
- for (const neighbor of neighbors) {
975
- if (!visited.has(neighbor.name)) {
976
- if (dfs(neighbor.name)) {
977
- return true;
978
- }
979
- } else if (recStack.has(neighbor.name)) {
980
- const cycleStart = path2.indexOf(neighbor.name);
981
- const cycle = path2.slice(cycleStart).concat(neighbor.name);
982
- circular.push(cycle);
983
- return true;
984
- }
985
- }
986
- path2.pop();
987
- recStack.delete(node);
988
- return false;
989
- };
990
- for (const node of graph.keys()) {
991
- if (!visited.has(node)) {
992
- dfs(node);
993
- }
994
- }
995
- return circular;
996
- }
997
-
998
- async function pathExists$4(p) {
999
- try {
1000
- await promises.access(p);
1001
- return true;
1002
- } catch {
1003
- return false;
1004
- }
1005
- }
1006
- const logger$5 = consola.withTag("go-analyzer");
1007
- const FRAMEWORK_PATTERNS$3 = {
1008
- gin: {
1009
- imports: ["github.com/gin-gonic/gin"],
1010
- indicators: ["gin.Default()", "gin.Context"]
1011
- },
1012
- echo: {
1013
- imports: ["github.com/labstack/echo/v4"],
1014
- indicators: ["echo.New()", "echo.Context"]
1015
- },
1016
- fiber: {
1017
- imports: ["github.com/gofiber/fiber/v2"],
1018
- indicators: ["fiber.New()", "fiber.Ctx"]
1019
- },
1020
- chi: {
1021
- imports: ["github.com/go-chi/chi/v5"],
1022
- indicators: ["chi.NewRouter()", "chi.Router"]
1023
- },
1024
- mux: {
1025
- imports: ["github.com/gorilla/mux"],
1026
- indicators: ["mux.NewRouter()", "mux.Router"]
1027
- },
1028
- httprouter: {
1029
- imports: ["github.com/julienschmidt/httprouter"],
1030
- indicators: ["httprouter.New()", "httprouter.Params"]
1031
- },
1032
- fasthttp: {
1033
- imports: ["github.com/valyala/fasthttp"],
1034
- indicators: ["fasthttp.Server", "fasthttp.RequestHandler"]
1035
- },
1036
- grpc: {
1037
- imports: ["google.golang.org/grpc"],
1038
- indicators: ["grpc.NewServer()", "grpc.Dial"]
1039
- },
1040
- protobuf: {
1041
- imports: ["google.golang.org/protobuf"],
1042
- indicators: [".proto", "proto.Marshal"]
1043
- },
1044
- gorm: {
1045
- imports: ["gorm.io/gorm"],
1046
- indicators: ["gorm.Open", "gorm.DB"]
1047
- },
1048
- sql: {
1049
- imports: ["database/sql"],
1050
- indicators: ["sql.Open", "sql.DB"]
1051
- },
1052
- ent: {
1053
- imports: ["entgo.io/ent"],
1054
- indicators: ["ent.Client", "ent.Schema"]
1055
- },
1056
- cobra: {
1057
- imports: ["github.com/spf13/cobra"],
1058
- indicators: ["cobra.Command", "cobra.Execute"]
1059
- },
1060
- viper: {
1061
- imports: ["github.com/spf13/viper"],
1062
- indicators: ["viper.New", "viper.Get"]
1063
- },
1064
- testify: {
1065
- imports: ["github.com/stretchr/testify"],
1066
- indicators: ["assert.Equal", "require.NoError"]
1067
- },
1068
- mock: {
1069
- imports: ["github.com/golang/mock"],
1070
- indicators: ["gomock.Controller", "mockgen"]
1071
- },
1072
- redis: {
1073
- imports: ["github.com/redis/go-redis/v9"],
1074
- indicators: ["redis.NewClient", "redis.Client"]
1075
- },
1076
- mongo: {
1077
- imports: ["go.mongodb.org/mongo-driver"],
1078
- indicators: ["mongo.Connect", "mongo.Database"]
1079
- },
1080
- prometheus: {
1081
- imports: ["github.com/prometheus/client_golang"],
1082
- indicators: ["prometheus.Counter", "promhttp.Handler"]
1083
- },
1084
- jaeger: {
1085
- imports: ["github.com/uber/jaeger-client-go"],
1086
- indicators: ["jaeger.NewTracer", "jaeger.Config"]
1087
- },
1088
- kubernetes: {
1089
- imports: ["k8s.io/client-go"],
1090
- indicators: ["kubernetes.Clientset", "k8s.io"]
1091
- }
1092
- };
1093
- async function analyzeGoProject(projectPath, files, _languages) {
1094
- logger$5.info("Analyzing Go project");
1095
- const frameworks = [];
1096
- const goModPath = posix.join(projectPath, "go.mod");
1097
- let _goMod = null;
1098
- try {
1099
- if (await pathExists$4(goModPath)) {
1100
- const content = await promises.readFile(goModPath, "utf-8");
1101
- _goMod = parseGoMod(content);
1102
- }
1103
- } catch (error) {
1104
- logger$5.warn("Failed to read go.mod:", error);
1105
- }
1106
- const imports = await scanGoImports(projectPath, files);
1107
- for (const [frameworkName, patterns] of Object.entries(FRAMEWORK_PATTERNS$3)) {
1108
- const evidence = [];
1109
- let confidence = 0;
1110
- for (const importPath of patterns.imports) {
1111
- if (imports[importPath]) {
1112
- evidence.push(`Found import: ${importPath}`);
1113
- confidence += 0.5;
1114
- }
1115
- }
1116
- for (const indicator of patterns.indicators) {
1117
- const filesWithIndicator = Object.values(imports).flat();
1118
- if (filesWithIndicator.some((f) => f.includes(indicator))) {
1119
- evidence.push(`Found pattern: ${indicator}`);
1120
- confidence += 0.3;
1121
- }
1122
- }
1123
- if (confidence > 0) {
1124
- frameworks.push({
1125
- name: frameworkName,
1126
- category: getFrameworkCategory$3(frameworkName),
1127
- confidence: Math.min(confidence, 1),
1128
- evidence
1129
- });
1130
- }
1131
- }
1132
- await detectAdditionalPatterns$3(projectPath, files, frameworks, imports);
1133
- frameworks.sort((a, b) => b.confidence - a.confidence);
1134
- logger$5.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
1135
- return frameworks;
1136
- }
1137
- function parseGoMod(content) {
1138
- const result = {
1139
- requires: {}
1140
- };
1141
- const lines = content.split("\n");
1142
- for (const line of lines) {
1143
- const trimmed = line.trim();
1144
- if (trimmed.startsWith("module")) {
1145
- result.module = trimmed.split(" ")[1];
1146
- } else if (trimmed.startsWith("go")) {
1147
- result.go = trimmed.split(" ")[1];
1148
- } else if (trimmed.startsWith("require")) {
1149
- const parts = trimmed.split(" ");
1150
- if (parts.length >= 3) {
1151
- result.requires[parts[1]] = parts[2];
1152
- }
1153
- } else if (trimmed.includes(" ")) {
1154
- const parts = trimmed.split(" ");
1155
- if (parts.length >= 2 && !trimmed.startsWith("//")) {
1156
- result.requires[parts[0]] = parts[1];
1157
- }
1158
- }
1159
- }
1160
- return result;
1161
- }
1162
- async function scanGoImports(projectPath, files) {
1163
- const imports = {};
1164
- const goFiles = files.filter((f) => f.endsWith(".go"));
1165
- for (const file of goFiles) {
1166
- try {
1167
- const content = await promises.readFile(posix.join(projectPath, file), "utf-8");
1168
- const fileImports = extractGoImports(content);
1169
- for (const importPath of fileImports) {
1170
- if (!imports[importPath]) {
1171
- imports[importPath] = [];
1172
- }
1173
- imports[importPath].push(file);
1174
- }
1175
- } catch (error) {
1176
- logger$5.warn(`Failed to read ${file}:`, error);
1177
- }
1178
- }
1179
- return imports;
1180
- }
1181
- function extractGoImports(content) {
1182
- const imports = [];
1183
- const importRegex = /import\s+(?:\(\s*([\s\S]*?)\s*\)|(["`][^"`]+["`]))/g;
1184
- let match;
1185
- while ((match = importRegex.exec(content)) !== null) {
1186
- const importBlock = match[1] || match[2];
1187
- if (importBlock) {
1188
- const singleImportRegex = /["`]([^"`]+)["`]/g;
1189
- let importMatch;
1190
- while ((importMatch = singleImportRegex.exec(importBlock)) !== null) {
1191
- imports.push(importMatch[1]);
1192
- }
1193
- }
1194
- }
1195
- return imports;
1196
- }
1197
- function getFrameworkCategory$3(framework) {
1198
- const categories = {
1199
- web: [
1200
- "gin",
1201
- "echo",
1202
- "fiber",
1203
- "chi",
1204
- "mux",
1205
- "httprouter",
1206
- "fasthttp"
1207
- ],
1208
- rpc: ["grpc", "protobuf"],
1209
- database: ["gorm", "sql", "ent"],
1210
- cli: ["cobra", "viper"],
1211
- testing: ["testify", "mock"],
1212
- cache: ["redis"],
1213
- database2: ["mongo"],
1214
- monitoring: ["prometheus", "jaeger"],
1215
- infrastructure: ["kubernetes"]
1216
- };
1217
- for (const [category, frameworks] of Object.entries(categories)) {
1218
- if (frameworks.includes(framework)) {
1219
- return category;
1220
- }
1221
- }
1222
- return "other";
1223
- }
1224
- async function detectAdditionalPatterns$3(projectPath, files, frameworks, imports) {
1225
- const goModPath = posix.join(projectPath, "go.mod");
1226
- if (files.includes("go.mod") && await pathExists$4(goModPath)) {
1227
- try {
1228
- const content = await promises.readFile(goModPath, "utf-8");
1229
- const goVersionMatch = content.match(/^go\s+(\d+\.\d+)/m);
1230
- if (goVersionMatch) {
1231
- frameworks.push({
1232
- name: "go",
1233
- category: "language",
1234
- version: goVersionMatch[1],
1235
- confidence: 0.9,
1236
- evidence: ["Found go.mod"]
1237
- });
1238
- }
1239
- } catch (error) {
1240
- logger$5.warn("Failed to read go.mod:", error);
1241
- }
1242
- }
1243
- const dockerFiles = ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"];
1244
- for (const file of dockerFiles) {
1245
- if (files.includes(file)) {
1246
- frameworks.push({
1247
- name: "docker",
1248
- category: "deployment",
1249
- confidence: 0.9,
1250
- evidence: [`Found ${file}`]
1251
- });
1252
- }
1253
- }
1254
- if (files.some((f) => f.endsWith("_test.go"))) {
1255
- frameworks.push({
1256
- name: "testing",
1257
- category: "testing",
1258
- confidence: 0.7,
1259
- evidence: ["Found test files"]
1260
- });
1261
- }
1262
- const buildFiles = {
1263
- "Makefile": "make",
1264
- "Dockerfile": "docker",
1265
- ".goreleaser.yml": "goreleaser",
1266
- ".goreleaser.yaml": "goreleaser"
1267
- };
1268
- for (const [file, tool] of Object.entries(buildFiles)) {
1269
- if (files.includes(file)) {
1270
- frameworks.push({
1271
- name: tool,
1272
- category: "build",
1273
- confidence: 0.8,
1274
- evidence: [`Found ${file}`]
1275
- });
1276
- }
1277
- }
1278
- const lintingTools = [
1279
- "github.com/golangci/golangci-lint",
1280
- "golang.org/x/lint",
1281
- "honnef.co/go/tools"
1282
- ];
1283
- for (const tool of lintingTools) {
1284
- if (imports[tool]) {
1285
- frameworks.push({
1286
- name: "golangci-lint",
1287
- category: "linting",
1288
- confidence: 0.8,
1289
- evidence: [`Found ${tool} import`]
1290
- });
1291
- }
1292
- }
1293
- const ciFiles = {
1294
- ".github/workflows": "github-actions",
1295
- ".gitlab-ci.yml": "gitlab-ci",
1296
- "Jenkinsfile": "jenkins",
1297
- ".travis.yml": "travis-ci"
1298
- };
1299
- for (const [file, tool] of Object.entries(ciFiles)) {
1300
- if (files.includes(file) || files.some((f) => f.startsWith(file))) {
1301
- frameworks.push({
1302
- name: tool,
1303
- category: "ci-cd",
1304
- confidence: 0.8,
1305
- evidence: [`Found ${file}`]
1306
- });
1307
- }
1308
- }
1309
- if (files.some((f) => f.endsWith(".proto"))) {
1310
- frameworks.push({
1311
- name: "protobuf",
1312
- category: "rpc",
1313
- confidence: 0.9,
1314
- evidence: ["Found .proto files"]
1315
- });
1316
- }
1317
- const goWorkPath = posix.join(projectPath, "go.work");
1318
- if (files.includes("go.work") && await pathExists$4(goWorkPath)) {
1319
- frameworks.push({
1320
- name: "workspace",
1321
- category: "workspace",
1322
- confidence: 0.9,
1323
- evidence: ["Found go.work"]
1324
- });
1325
- }
1326
- if (files.includes("vendor/") || files.some((f) => f.startsWith("vendor/"))) {
1327
- frameworks.push({
1328
- name: "vendor",
1329
- category: "dependency",
1330
- confidence: 0.8,
1331
- evidence: ["Found vendor directory"]
1332
- });
1333
- }
1334
- }
1335
-
1336
- async function pathExists$3(p) {
1337
- try {
1338
- await promises.access(p);
1339
- return true;
1340
- } catch {
1341
- return false;
1342
- }
1343
- }
1344
- const logger$4 = consola.withTag("python-analyzer");
1345
- const FRAMEWORK_PATTERNS$2 = {
1346
- "django": {
1347
- files: ["manage.py", "settings.py"],
1348
- dependencies: ["django"],
1349
- indicators: ["manage.py", "wsgi.py", "asgi.py", "settings/", "templates/", "static/"]
1350
- },
1351
- "fastapi": {
1352
- files: ["main.py"],
1353
- dependencies: ["fastapi"],
1354
- indicators: ["main.py", "app/", "api/", "routers/"]
1355
- },
1356
- "flask": {
1357
- files: ["app.py", "wsgi.py"],
1358
- dependencies: ["flask"],
1359
- indicators: ["app.py", "app/", "templates/", "static/"]
1360
- },
1361
- "tornado": {
1362
- files: [],
1363
- dependencies: ["tornado"],
1364
- indicators: ["tornado", "handlers/"]
1365
- },
1366
- "sanic": {
1367
- files: [],
1368
- dependencies: ["sanic"],
1369
- indicators: ["sanic"]
1370
- },
1371
- "quart": {
1372
- files: [],
1373
- dependencies: ["quart"],
1374
- indicators: ["quart"]
1375
- },
1376
- "falcon": {
1377
- files: [],
1378
- dependencies: ["falcon"],
1379
- indicators: ["falcon"]
1380
- },
1381
- "bottle": {
1382
- files: [],
1383
- dependencies: ["bottle"],
1384
- indicators: ["bottle"]
1385
- },
1386
- "pyramid": {
1387
- files: ["development.ini", "production.ini"],
1388
- dependencies: ["pyramid"],
1389
- indicators: ["development.ini", "production.ini"]
1390
- },
1391
- "starlette": {
1392
- files: [],
1393
- dependencies: ["starlette"],
1394
- indicators: ["starlette"]
1395
- },
1396
- "celery": {
1397
- files: ["celery.py"],
1398
- dependencies: ["celery"],
1399
- indicators: ["celery.py", "tasks.py", "celeryconfig.py"]
1400
- },
1401
- "pandas": {
1402
- files: [],
1403
- dependencies: ["pandas"],
1404
- indicators: ["pandas"]
1405
- },
1406
- "numpy": {
1407
- files: [],
1408
- dependencies: ["numpy"],
1409
- indicators: ["numpy"]
1410
- },
1411
- "scikit-learn": {
1412
- files: [],
1413
- dependencies: ["scikit-learn"],
1414
- indicators: ["sklearn"]
1415
- },
1416
- "tensorflow": {
1417
- files: [],
1418
- dependencies: ["tensorflow"],
1419
- indicators: ["tensorflow"]
1420
- },
1421
- "pytorch": {
1422
- files: [],
1423
- dependencies: ["torch"],
1424
- indicators: ["torch"]
1425
- },
1426
- "jupyter": {
1427
- files: [],
1428
- dependencies: ["jupyter"],
1429
- indicators: [".ipynb", "jupyter"]
1430
- },
1431
- "streamlit": {
1432
- files: [],
1433
- dependencies: ["streamlit"],
1434
- indicators: ["streamlit"]
1435
- },
1436
- "dash": {
1437
- files: [],
1438
- dependencies: ["dash"],
1439
- indicators: ["dash"]
1440
- },
1441
- "gradio": {
1442
- files: [],
1443
- dependencies: ["gradio"],
1444
- indicators: ["gradio"]
1445
- },
1446
- "pytest": {
1447
- files: [],
1448
- dependencies: ["pytest"],
1449
- indicators: ["pytest", "conftest.py", "test_"]
1450
- },
1451
- "unittest": {
1452
- files: [],
1453
- dependencies: [],
1454
- indicators: ["test_", "_test.py"]
1455
- },
1456
- "poetry": {
1457
- files: ["pyproject.toml"],
1458
- dependencies: [],
1459
- indicators: ["pyproject.toml", "poetry.lock"]
1460
- },
1461
- "pipenv": {
1462
- files: ["Pipfile"],
1463
- dependencies: [],
1464
- indicators: ["Pipfile", "Pipfile.lock"]
1465
- },
1466
- "conda": {
1467
- files: ["environment.yml", "environment.yaml"],
1468
- dependencies: [],
1469
- indicators: ["environment.yml", "environment.yaml"]
1470
- }
1471
- };
1472
- async function analyzePythonProject(projectPath, files, _languages) {
1473
- logger$4.info("Analyzing Python project");
1474
- const frameworks = [];
1475
- const dependencies = await analyzeDependencies(projectPath, files);
1476
- for (const [frameworkName, patterns] of Object.entries(FRAMEWORK_PATTERNS$2)) {
1477
- const evidence = [];
1478
- let confidence = 0;
1479
- for (const file of patterns.files) {
1480
- if (files.includes(file) || files.some((f) => f.includes(file))) {
1481
- evidence.push(`Found ${file}`);
1482
- confidence += 0.3;
1483
- }
1484
- }
1485
- for (const indicator of patterns.indicators) {
1486
- if (files.some((f) => f.includes(indicator))) {
1487
- evidence.push(`Found ${indicator} pattern`);
1488
- confidence += 0.2;
1489
- }
1490
- }
1491
- for (const dep of patterns.dependencies) {
1492
- if (dependencies[dep]) {
1493
- evidence.push(`Found ${dep} in dependencies`);
1494
- confidence += 0.4;
1495
- }
1496
- }
1497
- if (confidence > 0) {
1498
- frameworks.push({
1499
- name: frameworkName,
1500
- category: getFrameworkCategory$2(frameworkName),
1501
- version: dependencies[frameworkName],
1502
- confidence: Math.min(confidence, 1),
1503
- evidence
1504
- });
1505
- }
1506
- }
1507
- await detectAdditionalPatterns$2(projectPath, files, frameworks, dependencies);
1508
- frameworks.sort((a, b) => b.confidence - a.confidence);
1509
- logger$4.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
1510
- return frameworks;
1511
- }
1512
- async function analyzeDependencies(projectPath, files) {
1513
- const dependencies = {};
1514
- const requirementsPath = posix.join(projectPath, "requirements.txt");
1515
- if (files.includes("requirements.txt") && await pathExists$3(requirementsPath)) {
1516
- try {
1517
- const content = await promises.readFile(requirementsPath, "utf-8");
1518
- const lines = content.split("\n");
1519
- for (const line of lines) {
1520
- const trimmed = line.trim();
1521
- if (trimmed && !trimmed.startsWith("#")) {
1522
- const match = trimmed.match(/^([\w-]+)([[~=><].*)?$/);
1523
- if (match) {
1524
- dependencies[match[1]] = match[2] || "latest";
1525
- }
1526
- }
1527
- }
1528
- } catch (error) {
1529
- logger$4.warn("Failed to parse requirements.txt:", error);
1530
- }
1531
- }
1532
- const pyprojectPath = posix.join(projectPath, "pyproject.toml");
1533
- if (files.includes("pyproject.toml") && await pathExists$3(pyprojectPath)) {
1534
- try {
1535
- const content = await promises.readFile(pyprojectPath, "utf-8");
1536
- const parsed = parse(content);
1537
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && "tool" in parsed) {
1538
- const tool = parsed.tool;
1539
- if (typeof tool === "object" && tool !== null && !Array.isArray(tool) && "poetry" in tool) {
1540
- const poetry = tool.poetry;
1541
- if (typeof poetry === "object" && poetry !== null && !Array.isArray(poetry) && "dependencies" in poetry) {
1542
- const poetryDeps = poetry.dependencies;
1543
- if (typeof poetryDeps === "object" && poetryDeps !== null && !Array.isArray(poetryDeps)) {
1544
- Object.assign(dependencies, poetryDeps);
1545
- }
1546
- }
1547
- }
1548
- }
1549
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && "project" in parsed) {
1550
- const project = parsed.project;
1551
- if (typeof project === "object" && project !== null && !Array.isArray(project) && "dependencies" in project) {
1552
- const projectDeps = project.dependencies;
1553
- if (Array.isArray(projectDeps)) {
1554
- for (const dep of projectDeps) {
1555
- if (typeof dep === "string") {
1556
- const match = dep.match(/^([\w-]+)([[~=><].*)?$/);
1557
- if (match) {
1558
- dependencies[match[1]] = match[2] || "latest";
1559
- }
1560
- }
1561
- }
1562
- }
1563
- }
1564
- }
1565
- } catch (error) {
1566
- logger$4.warn("Failed to parse pyproject.toml:", error);
1567
- }
1568
- }
1569
- const pipfilePath = posix.join(projectPath, "Pipfile");
1570
- if (files.includes("Pipfile") && await pathExists$3(pipfilePath)) {
1571
- try {
1572
- const content = await promises.readFile(pipfilePath, "utf-8");
1573
- const lines = content.split("\n");
1574
- let inPackages = false;
1575
- for (const line of lines) {
1576
- const trimmed = line.trim();
1577
- if (trimmed === "[packages]") {
1578
- inPackages = true;
1579
- continue;
1580
- }
1581
- if (trimmed.startsWith("[") && trimmed !== "[packages]") {
1582
- inPackages = false;
1583
- continue;
1584
- }
1585
- if (inPackages && trimmed && !trimmed.startsWith("#")) {
1586
- const match = trimmed.match(/^([\w-]+)\s*=\s*"?([^"]*)"?/);
1587
- if (match) {
1588
- dependencies[match[1]] = match[2] || "latest";
1589
- }
1590
- }
1591
- }
1592
- } catch (error) {
1593
- logger$4.warn("Failed to parse Pipfile:", error);
1594
- }
1595
- }
1596
- const setupPath = posix.join(projectPath, "setup.py");
1597
- if (files.includes("setup.py") && await pathExists$3(setupPath)) {
1598
- try {
1599
- const content = await promises.readFile(setupPath, "utf-8");
1600
- const installRequiresMatch = content.match(/install_requires\s*=\s*\[([\s\S]*?)\]/);
1601
- if (installRequiresMatch) {
1602
- const requiresList = installRequiresMatch[1];
1603
- const requires = requiresList.match(/['"`]([\w-]+)/g);
1604
- if (requires) {
1605
- for (const req of requires) {
1606
- const name = req.replace(/['"`]/g, "");
1607
- dependencies[name] = "latest";
1608
- }
1609
- }
1610
- }
1611
- } catch (error) {
1612
- logger$4.warn("Failed to parse setup.py:", error);
1613
- }
1614
- }
1615
- const envPath = posix.join(projectPath, "environment.yml");
1616
- if (files.includes("environment.yml") && await pathExists$3(envPath)) {
1617
- try {
1618
- const content = await promises.readFile(envPath, "utf-8");
1619
- const parsed = parse(content);
1620
- if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && "dependencies" in parsed) {
1621
- const deps = parsed.dependencies;
1622
- if (Array.isArray(deps)) {
1623
- for (const dep of deps) {
1624
- if (typeof dep === "string") {
1625
- const match = dep.match(/^([\w-]+)([[~=><].*)?$/);
1626
- if (match) {
1627
- dependencies[match[1]] = match[2] || "latest";
1628
- }
1629
- }
1630
- }
1631
- }
1632
- }
1633
- } catch (error) {
1634
- logger$4.warn("Failed to parse environment.yml:", error);
1635
- }
1636
- }
1637
- return dependencies;
1638
- }
1639
- function getFrameworkCategory$2(framework) {
1640
- const categories = {
1641
- web: [
1642
- "django",
1643
- "fastapi",
1644
- "flask",
1645
- "tornado",
1646
- "sanic",
1647
- "quart",
1648
- "falcon",
1649
- "bottle",
1650
- "pyramid",
1651
- "starlette"
1652
- ],
1653
- async: ["celery"],
1654
- data: ["pandas", "numpy", "scikit-learn", "tensorflow", "pytorch"],
1655
- notebook: ["jupyter"],
1656
- ui: ["streamlit", "dash", "gradio"],
1657
- testing: ["pytest", "unittest"],
1658
- package: ["poetry", "pipenv", "conda"]
1659
- };
1660
- for (const [category, frameworks] of Object.entries(categories)) {
1661
- if (frameworks.includes(framework)) {
1662
- return category;
1663
- }
1664
- }
1665
- return "other";
1666
- }
1667
- async function detectAdditionalPatterns$2(projectPath, files, frameworks, dependencies) {
1668
- const pythonVersionPath = posix.join(projectPath, ".python-version");
1669
- if (files.includes(".python-version") && await pathExists$3(pythonVersionPath)) {
1670
- try {
1671
- const version = await promises.readFile(pythonVersionPath, "utf-8");
1672
- frameworks.push({
1673
- name: "python",
1674
- category: "language",
1675
- version: version.trim(),
1676
- confidence: 0.9,
1677
- evidence: ["Found .python-version"]
1678
- });
1679
- } catch (error) {
1680
- logger$4.warn("Failed to read .python-version:", error);
1681
- }
1682
- }
1683
- const dockerFiles = ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"];
1684
- for (const file of dockerFiles) {
1685
- if (files.includes(file)) {
1686
- frameworks.push({
1687
- name: "docker",
1688
- category: "deployment",
1689
- confidence: 0.9,
1690
- evidence: [`Found ${file}`]
1691
- });
1692
- }
1693
- }
1694
- if (files.some((f) => f.startsWith("test_") || f.includes("_test.py"))) {
1695
- frameworks.push({
1696
- name: "unittest",
1697
- category: "testing",
1698
- confidence: 0.6,
1699
- evidence: ["Found test files"]
1700
- });
1701
- }
1702
- const lintingTools = ["flake8", "pylint", "black", "isort", "mypy"];
1703
- for (const tool of lintingTools) {
1704
- if (dependencies[tool]) {
1705
- frameworks.push({
1706
- name: tool,
1707
- category: "linting",
1708
- version: dependencies[tool],
1709
- confidence: 0.8,
1710
- evidence: [`Found ${tool} in dependencies`]
1711
- });
1712
- }
1713
- }
1714
- const configFiles = {
1715
- "setup.cfg": "setuptools",
1716
- "tox.ini": "tox",
1717
- "mypy.ini": "mypy",
1718
- ".flake8": "flake8",
1719
- ".pylintrc": "pylint",
1720
- "pytest.ini": "pytest",
1721
- "pyproject.toml": "modern-python"
1722
- };
1723
- for (const [file, tool] of Object.entries(configFiles)) {
1724
- if (files.includes(file)) {
1725
- frameworks.push({
1726
- name: tool,
1727
- category: "config",
1728
- confidence: 0.8,
1729
- evidence: [`Found ${file}`]
1730
- });
1731
- }
1732
- }
1733
- }
1734
-
1735
- async function pathExists$2(p) {
1736
- try {
1737
- await promises.access(p);
1738
- return true;
1739
- } catch {
1740
- return false;
1741
- }
1742
- }
1743
- const logger$3 = consola.withTag("rust-analyzer");
1744
- const FRAMEWORK_PATTERNS$1 = {
1745
- "actix-web": {
1746
- dependencies: ["actix-web"],
1747
- indicators: ["HttpServer", "web::"]
1748
- },
1749
- "rocket": {
1750
- dependencies: ["rocket"],
1751
- indicators: ["rocket::", "#[get]", "#[post]"]
1752
- },
1753
- "tokio": {
1754
- dependencies: ["tokio"],
1755
- indicators: ["tokio::", "#[tokio::main]"]
1756
- },
1757
- "async-std": {
1758
- dependencies: ["async-std"],
1759
- indicators: ["async_std::"]
1760
- },
1761
- "serde": {
1762
- dependencies: ["serde"],
1763
- indicators: ["serde::", "Serialize", "Deserialize"]
1764
- },
1765
- "clap": {
1766
- dependencies: ["clap"],
1767
- indicators: ["clap::", "Command", "Parser"]
1768
- },
1769
- "axum": {
1770
- dependencies: ["axum"],
1771
- indicators: ["axum::", "Router"]
1772
- },
1773
- "warp": {
1774
- dependencies: ["warp"],
1775
- indicators: ["warp::", "Filter"]
1776
- },
1777
- "hyper": {
1778
- dependencies: ["hyper"],
1779
- indicators: ["hyper::", "Request", "Response"]
1780
- },
1781
- "tide": {
1782
- dependencies: ["tide"],
1783
- indicators: ["tide::", "Server"]
1784
- },
1785
- "tracing": {
1786
- dependencies: ["tracing"],
1787
- indicators: ["tracing::", "#[instrument]"]
1788
- },
1789
- "log": {
1790
- dependencies: ["log"],
1791
- indicators: ["log::", "info!", "debug!"]
1792
- },
1793
- "anyhow": {
1794
- dependencies: ["anyhow"],
1795
- indicators: ["anyhow::", "anyhow!"]
1796
- },
1797
- "thiserror": {
1798
- dependencies: ["thiserror"],
1799
- indicators: ["thiserror::", "#[error]"]
1800
- },
1801
- "sqlx": {
1802
- dependencies: ["sqlx"],
1803
- indicators: ["sqlx::", "PgPool"]
1804
- },
1805
- "diesel": {
1806
- dependencies: ["diesel"],
1807
- indicators: ["diesel::", "prelude::*"]
1808
- },
1809
- "sea-orm": {
1810
- dependencies: ["sea-orm"],
1811
- indicators: ["sea_orm::", "Database"]
1812
- },
1813
- "redis": {
1814
- dependencies: ["redis"],
1815
- indicators: ["redis::", "Connection"]
1816
- },
1817
- "tokio-postgres": {
1818
- dependencies: ["tokio-postgres"],
1819
- indicators: ["tokio_postgres::", "Client"]
1820
- },
1821
- "prometheus": {
1822
- dependencies: ["prometheus"],
1823
- indicators: ["prometheus::", "Counter"]
1824
- },
1825
- "sentry": {
1826
- dependencies: ["sentry"],
1827
- indicators: ["sentry::", "capture_event"]
1828
- },
1829
- "uuid": {
1830
- dependencies: ["uuid"],
1831
- indicators: ["uuid::", "Uuid"]
1832
- },
1833
- "chrono": {
1834
- dependencies: ["chrono"],
1835
- indicators: ["chrono::", "DateTime"]
1836
- },
1837
- "regex": {
1838
- dependencies: ["regex"],
1839
- indicators: ["regex::", "Regex"]
1840
- },
1841
- "rand": {
1842
- dependencies: ["rand"],
1843
- indicators: ["rand::", "Rng"]
1844
- },
1845
- "serde_json": {
1846
- dependencies: ["serde_json"],
1847
- indicators: ["serde_json::", "json!"]
1848
- },
1849
- "tower": {
1850
- dependencies: ["tower"],
1851
- indicators: ["tower::", "Service"]
1852
- },
1853
- "prost": {
1854
- dependencies: ["prost"],
1855
- indicators: ["prost::", "Message"]
1856
- },
1857
- "tonic": {
1858
- dependencies: ["tonic"],
1859
- indicators: ["tonic::", "#[tonic::async_trait]"]
1860
- },
1861
- "yew": {
1862
- dependencies: ["yew"],
1863
- indicators: ["yew::", "html!"]
1864
- },
1865
- "leptos": {
1866
- dependencies: ["leptos"],
1867
- indicators: ["leptos::", "view!"]
1868
- },
1869
- "tauri": {
1870
- dependencies: ["tauri"],
1871
- indicators: ["tauri::", "#[tauri::command]"]
1872
- },
1873
- "bevy": {
1874
- dependencies: ["bevy"],
1875
- indicators: ["bevy::", "App"]
1876
- },
1877
- "egui": {
1878
- dependencies: ["egui"],
1879
- indicators: ["egui::", "CentralPanel"]
1880
- }
1881
- };
1882
- async function analyzeRustProject(projectPath, files, _languages) {
1883
- logger$3.info("Analyzing Rust project");
1884
- const frameworks = [];
1885
- const cargoTomlPath = posix.join(projectPath, "Cargo.toml");
1886
- let cargoToml = null;
1887
- try {
1888
- if (await pathExists$2(cargoTomlPath)) {
1889
- const content = await promises.readFile(cargoTomlPath, "utf-8");
1890
- cargoToml = parse(content);
1891
- }
1892
- } catch (error) {
1893
- logger$3.warn("Failed to read Cargo.toml:", error);
1894
- }
1895
- const dependencies = extractCargoDependencies(cargoToml);
1896
- const patterns = await scanRustPatterns(projectPath, files);
1897
- for (const [frameworkName, frameworkPatterns] of Object.entries(FRAMEWORK_PATTERNS$1)) {
1898
- const evidence = [];
1899
- let confidence = 0;
1900
- for (const dep of frameworkPatterns.dependencies) {
1901
- if (dependencies[dep]) {
1902
- evidence.push(`Found ${dep} in dependencies`);
1903
- confidence += 0.5;
1904
- }
1905
- }
1906
- for (const indicator of frameworkPatterns.indicators) {
1907
- if (patterns[indicator]) {
1908
- evidence.push(`Found pattern: ${indicator}`);
1909
- confidence += 0.3;
1910
- }
1911
- }
1912
- if (confidence > 0) {
1913
- frameworks.push({
1914
- name: frameworkName,
1915
- category: getFrameworkCategory$1(frameworkName),
1916
- version: dependencies[frameworkName],
1917
- confidence: Math.min(confidence, 1),
1918
- evidence
1919
- });
1920
- }
1921
- }
1922
- await detectAdditionalPatterns$1(projectPath, files, frameworks, dependencies, patterns, cargoToml);
1923
- frameworks.sort((a, b) => b.confidence - a.confidence);
1924
- logger$3.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
1925
- return frameworks;
1926
- }
1927
- function extractCargoDependencies(cargoToml) {
1928
- const dependencies = {};
1929
- if (!cargoToml) {
1930
- return dependencies;
1931
- }
1932
- const depsSections = [
1933
- cargoToml.dependencies,
1934
- cargoToml["dev-dependencies"],
1935
- cargoToml["build-dependencies"]
1936
- ];
1937
- for (const section of depsSections) {
1938
- if (typeof section === "object") {
1939
- for (const [name, version] of Object.entries(section)) {
1940
- if (typeof version === "string") {
1941
- dependencies[name] = version;
1942
- } else if (typeof version === "object" && version !== null && "version" in version) {
1943
- dependencies[name] = version.version;
1944
- }
1945
- }
1946
- }
1947
- }
1948
- if (cargoToml.workspace?.dependencies) {
1949
- for (const [name, version] of Object.entries(cargoToml.workspace.dependencies)) {
1950
- if (!dependencies[name]) {
1951
- if (typeof version === "string") {
1952
- dependencies[name] = version;
1953
- } else if (typeof version === "object" && version !== null && "version" in version) {
1954
- dependencies[name] = version.version;
1955
- }
1956
- }
1957
- }
1958
- }
1959
- return dependencies;
1960
- }
1961
- async function scanRustPatterns(projectPath, files) {
1962
- const patterns = {};
1963
- const rustFiles = files.filter((f) => f.endsWith(".rs"));
1964
- for (const file of rustFiles) {
1965
- try {
1966
- const content = await promises.readFile(posix.join(projectPath, file), "utf-8");
1967
- const patternRegex = /(\w+::|@\[|!\w+\()/g;
1968
- let match;
1969
- while ((match = patternRegex.exec(content)) !== null) {
1970
- const pattern = match[1];
1971
- patterns[pattern] = (patterns[pattern] || 0) + 1;
1972
- }
1973
- const macroRegex = /(\w+!)/g;
1974
- while ((match = macroRegex.exec(content)) !== null) {
1975
- const macroName = match[1];
1976
- patterns[macroName] = (patterns[macroName] || 0) + 1;
1977
- }
1978
- const traitRegex = /:\s*([\w\s,]+)(?:\s*\{|<)/g;
1979
- while ((match = traitRegex.exec(content)) !== null) {
1980
- const traits = match[1].split(",").map((t) => t.trim());
1981
- for (const trait of traits) {
1982
- patterns[trait] = (patterns[trait] || 0) + 1;
1983
- }
1984
- }
1985
- } catch (error) {
1986
- logger$3.warn(`Failed to read ${file}:`, error);
1987
- }
1988
- }
1989
- return patterns;
1990
- }
1991
- function getFrameworkCategory$1(framework) {
1992
- const categories = {
1993
- web: [
1994
- "actix-web",
1995
- "rocket",
1996
- "axum",
1997
- "warp",
1998
- "hyper",
1999
- "tide"
2000
- ],
2001
- async: ["tokio", "async-std"],
2002
- serialization: ["serde", "serde_json"],
2003
- cli: ["clap"],
2004
- error: ["anyhow", "thiserror"],
2005
- logging: ["tracing", "log"],
2006
- database: ["sqlx", "diesel", "sea-orm", "tokio-postgres"],
2007
- cache: ["redis"],
2008
- monitoring: ["prometheus", "sentry"],
2009
- utility: ["uuid", "chrono", "regex", "rand"],
2010
- middleware: ["tower"],
2011
- rpc: ["prost", "tonic"],
2012
- frontend: ["yew", "leptos"],
2013
- desktop: ["tauri"],
2014
- game: ["bevy"],
2015
- gui: ["egui"]
2016
- };
2017
- for (const [category, frameworks] of Object.entries(categories)) {
2018
- if (frameworks.includes(framework)) {
2019
- return category;
2020
- }
2021
- }
2022
- return "other";
2023
- }
2024
- async function detectAdditionalPatterns$1(projectPath, files, frameworks, dependencies, patterns, cargoToml) {
2025
- if (cargoToml?.package?.edition) {
2026
- frameworks.push({
2027
- name: "rust",
2028
- category: "language",
2029
- version: cargoToml.package.edition,
2030
- confidence: 0.9,
2031
- evidence: ["Found Cargo.toml"]
2032
- });
2033
- }
2034
- if (cargoToml?.workspace) {
2035
- frameworks.push({
2036
- name: "workspace",
2037
- category: "workspace",
2038
- confidence: 0.9,
2039
- evidence: ["Found workspace in Cargo.toml"]
2040
- });
2041
- }
2042
- if (cargoToml?.bin) {
2043
- frameworks.push({
2044
- name: "binary",
2045
- category: "build",
2046
- confidence: 0.8,
2047
- evidence: ["Found binary targets"]
2048
- });
2049
- }
2050
- if (cargoToml?.lib) {
2051
- frameworks.push({
2052
- name: "library",
2053
- category: "build",
2054
- confidence: 0.8,
2055
- evidence: ["Found library configuration"]
2056
- });
2057
- }
2058
- const dockerFiles = ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"];
2059
- for (const file of dockerFiles) {
2060
- if (files.includes(file)) {
2061
- frameworks.push({
2062
- name: "docker",
2063
- category: "deployment",
2064
- confidence: 0.9,
2065
- evidence: [`Found ${file}`]
2066
- });
2067
- }
2068
- }
2069
- if (files.some((f) => f.endsWith("_test.rs")) || patterns["#["] && patterns["#["] > 0) {
2070
- frameworks.push({
2071
- name: "testing",
2072
- category: "testing",
2073
- confidence: 0.7,
2074
- evidence: ["Found test files"]
2075
- });
2076
- }
2077
- if (files.some((f) => f.endsWith("_bench.rs"))) {
2078
- frameworks.push({
2079
- name: "benchmark",
2080
- category: "testing",
2081
- confidence: 0.8,
2082
- evidence: ["Found benchmark files"]
2083
- });
2084
- }
2085
- if (files.some((f) => f.startsWith("examples/"))) {
2086
- frameworks.push({
2087
- name: "examples",
2088
- category: "documentation",
2089
- confidence: 0.7,
2090
- evidence: ["Found examples directory"]
2091
- });
2092
- }
2093
- const ciFiles = {
2094
- ".github/workflows": "github-actions",
2095
- ".gitlab-ci.yml": "gitlab-ci",
2096
- "Jenkinsfile": "jenkins",
2097
- ".travis.yml": "travis-ci"
2098
- };
2099
- for (const [file, tool] of Object.entries(ciFiles)) {
2100
- if (files.includes(file) || files.some((f) => f.startsWith(file))) {
2101
- frameworks.push({
2102
- name: tool,
2103
- category: "ci-cd",
2104
- confidence: 0.8,
2105
- evidence: [`Found ${file}`]
2106
- });
2107
- }
2108
- }
2109
- const buildFiles = {
2110
- "Makefile": "make",
2111
- "justfile": "just",
2112
- "build.rs": "build-script"
2113
- };
2114
- for (const [file, tool] of Object.entries(buildFiles)) {
2115
- if (files.includes(file)) {
2116
- frameworks.push({
2117
- name: tool,
2118
- category: "build",
2119
- confidence: 0.8,
2120
- evidence: [`Found ${file}`]
2121
- });
2122
- }
2123
- }
2124
- if (files.some((f) => f.endsWith(".proto"))) {
2125
- frameworks.push({
2126
- name: "protobuf",
2127
- category: "rpc",
2128
- confidence: 0.9,
2129
- evidence: ["Found .proto files"]
2130
- });
2131
- }
2132
- if (dependencies["wasm-bindgen"] || dependencies["wasm-pack"]) {
2133
- frameworks.push({
2134
- name: "wasm",
2135
- category: "webassembly",
2136
- confidence: 0.8,
2137
- evidence: ["Found WASM dependencies"]
2138
- });
2139
- }
2140
- if (patterns["#![no_std]"]) {
2141
- frameworks.push({
2142
- name: "no_std",
2143
- category: "embedded",
2144
- confidence: 0.9,
2145
- evidence: ["Found #![no_std]"]
2146
- });
2147
- }
2148
- if (cargoToml?.lib?.proc_macro) {
2149
- frameworks.push({
2150
- name: "proc-macro",
2151
- category: "meta",
2152
- confidence: 0.9,
2153
- evidence: ["Found proc-macro configuration"]
2154
- });
2155
- }
2156
- if (dependencies.clippy) {
2157
- frameworks.push({
2158
- name: "clippy",
2159
- category: "linting",
2160
- confidence: 0.8,
2161
- evidence: ["Found clippy dependency"]
2162
- });
2163
- }
2164
- if (dependencies.rustfmt) {
2165
- frameworks.push({
2166
- name: "rustfmt",
2167
- category: "formatting",
2168
- confidence: 0.8,
2169
- evidence: ["Found rustfmt dependency"]
2170
- });
2171
- }
2172
- if (dependencies.rustdoc) {
2173
- frameworks.push({
2174
- name: "rustdoc",
2175
- category: "documentation",
2176
- confidence: 0.8,
2177
- evidence: ["Found rustdoc dependency"]
2178
- });
2179
- }
2180
- if (cargoToml?.package?.publish) {
2181
- frameworks.push({
2182
- name: "crates.io",
2183
- category: "registry",
2184
- confidence: 0.7,
2185
- evidence: ["Found publish configuration"]
2186
- });
2187
- }
2188
- if (cargoToml?.package?.license) {
2189
- frameworks.push({
2190
- name: cargoToml.package.license,
2191
- category: "legal",
2192
- confidence: 0.6,
2193
- evidence: ["Found license in Cargo.toml"]
2194
- });
2195
- }
2196
- if (cargoToml?.package) {
2197
- const type = cargoToml.bin ? "binary" : cargoToml.lib ? "library" : "unknown";
2198
- frameworks.push({
2199
- name: type,
2200
- category: "package",
2201
- confidence: 0.9,
2202
- evidence: [`Detected as ${type}`]
2203
- });
2204
- }
2205
- if (files.includes("target/") || files.some((f) => f.startsWith("target/"))) {
2206
- logger$3.debug("Found target/ directory (build artifacts)");
2207
- }
2208
- if (files.includes("Cargo.lock")) {
2209
- frameworks.push({
2210
- name: "cargo-lock",
2211
- category: "dependency",
2212
- confidence: 0.9,
2213
- evidence: ["Found Cargo.lock"]
2214
- });
2215
- }
2216
- }
2217
-
2218
- async function pathExists$1(p) {
2219
- try {
2220
- await promises.access(p);
2221
- return true;
2222
- } catch {
2223
- return false;
2224
- }
2225
- }
2226
- async function readJson(p) {
2227
- const content = await promises.readFile(p, "utf-8");
2228
- return JSON.parse(content);
2229
- }
2230
- const logger$2 = consola.withTag("typescript-analyzer");
2231
- const FRAMEWORK_PATTERNS = {
2232
- "next.js": {
2233
- files: ["next.config.js", "next.config.ts", "next.config.mjs"],
2234
- dependencies: ["next"],
2235
- indicators: ["pages/", "app/", "src/app/", "src/pages/"]
2236
- },
2237
- "nuxt": {
2238
- files: ["nuxt.config.js", "nuxt.config.ts"],
2239
- dependencies: ["nuxt"],
2240
- indicators: ["pages/", "layouts/", "components/", "store/"]
2241
- },
2242
- "sveltekit": {
2243
- files: ["svelte.config.js", "svelte.config.ts"],
2244
- dependencies: ["@sveltejs/kit"],
2245
- indicators: ["src/routes/", "src/lib/", ".svelte-kit/"]
2246
- },
2247
- "astro": {
2248
- files: ["astro.config.js", "astro.config.mjs", "astro.config.ts"],
2249
- dependencies: ["astro"],
2250
- indicators: ["src/pages/", "src/content/", "src/components/"]
2251
- },
2252
- "solidstart": {
2253
- files: ["vite.config.ts", "vite.config.js"],
2254
- dependencies: ["solid-start"],
2255
- indicators: ["src/routes/", "src/components/"]
2256
- },
2257
- "qwik": {
2258
- files: ["vite.config.ts"],
2259
- dependencies: ["@builder.io/qwik"],
2260
- indicators: ["src/routes/", "src/components/"]
2261
- },
2262
- "remix": {
2263
- files: ["remix.config.js", "vite.config.ts"],
2264
- dependencies: ["@remix-run/node"],
2265
- indicators: ["app/", "app/routes/", "app/components/"]
2266
- },
2267
- "gatsby": {
2268
- files: ["gatsby-config.js", "gatsby-config.ts"],
2269
- dependencies: ["gatsby"],
2270
- indicators: ["src/pages/", "src/templates/", "gatsby-node.js"]
2271
- },
2272
- "vue": {
2273
- files: ["vue.config.js"],
2274
- dependencies: ["vue"],
2275
- indicators: ["src/components/", "src/views/", "src/router/"]
2276
- },
2277
- "angular": {
2278
- files: ["angular.json"],
2279
- dependencies: ["@angular/core"],
2280
- indicators: ["src/app/", "e2e/", ".angular/"]
2281
- },
2282
- "react": {
2283
- files: [],
2284
- dependencies: ["react", "react-dom"],
2285
- indicators: ["src/", "components/", "src/components/"]
2286
- },
2287
- "preact": {
2288
- files: [],
2289
- dependencies: ["preact"],
2290
- indicators: ["src/", "components/"]
2291
- },
2292
- "solidjs": {
2293
- files: [],
2294
- dependencies: ["solid-js"],
2295
- indicators: ["src/", "components/"]
2296
- },
2297
- "svelte": {
2298
- files: [],
2299
- dependencies: ["svelte"],
2300
- indicators: ["src/", "components/", "src/components/"]
2301
- },
2302
- "nest.js": {
2303
- files: ["nest-cli.json"],
2304
- dependencies: ["@nestjs/core"],
2305
- indicators: ["src/", "src/modules/", "src/controllers/"]
2306
- },
2307
- "express": {
2308
- files: [],
2309
- dependencies: ["express"],
2310
- indicators: ["app.js", "server.js", "routes/", "middleware/"]
2311
- },
2312
- "fastify": {
2313
- files: [],
2314
- dependencies: ["fastify"],
2315
- indicators: ["app.js", "server.js", "routes/", "plugins/"]
2316
- },
2317
- "koa": {
2318
- files: [],
2319
- dependencies: ["koa"],
2320
- indicators: ["app.js", "server.js", "middleware/"]
2321
- },
2322
- "adonisjs": {
2323
- files: [".adonisrc.json"],
2324
- dependencies: ["@adonisjs/core"],
2325
- indicators: ["app/", "config/", "start/", "providers/"]
2326
- },
2327
- "feathers": {
2328
- files: [],
2329
- dependencies: ["@feathersjs/feathers"],
2330
- indicators: ["src/", "services/"]
2331
- },
2332
- "meteor": {
2333
- files: [".meteor/"],
2334
- dependencies: ["meteor-node-stubs"],
2335
- indicators: ["client/", "server/", "imports/"]
2336
- },
2337
- "ionic": {
2338
- files: ["ionic.config.json"],
2339
- dependencies: ["@ionic/core"],
2340
- indicators: ["src/", "www/"]
2341
- },
2342
- "electron": {
2343
- files: [],
2344
- dependencies: ["electron"],
2345
- indicators: ["main.js", "src/main/", "electron/"]
2346
- },
2347
- "turborepo": {
2348
- files: ["turbo.json"],
2349
- dependencies: ["turbo"],
2350
- indicators: ["apps/", "packages/"]
2351
- },
2352
- "nx": {
2353
- files: ["nx.json"],
2354
- dependencies: ["nx"],
2355
- indicators: ["apps/", "libs/"]
2356
- },
2357
- "lerna": {
2358
- files: ["lerna.json"],
2359
- dependencies: ["lerna"],
2360
- indicators: ["packages/"]
2361
- }
2362
- };
2363
- async function analyzeTypeScriptProject(projectPath, files, _languages) {
2364
- logger$2.info("Analyzing TypeScript/JavaScript project");
2365
- const frameworks = [];
2366
- const packageJsonPath = posix.join(projectPath, "package.json");
2367
- let packageJson = null;
2368
- try {
2369
- if (await pathExists$1(packageJsonPath)) {
2370
- packageJson = await readJson(packageJsonPath);
2371
- }
2372
- } catch (error) {
2373
- logger$2.warn("Failed to read package.json:", error);
2374
- }
2375
- for (const [frameworkName, patterns] of Object.entries(FRAMEWORK_PATTERNS)) {
2376
- const evidence = [];
2377
- let confidence = 0;
2378
- for (const file of patterns.files) {
2379
- if (files.includes(file)) {
2380
- evidence.push(`Found ${file}`);
2381
- confidence += 0.3;
2382
- }
2383
- }
2384
- for (const indicator of patterns.indicators) {
2385
- const indicatorPath = posix.join(projectPath, indicator);
2386
- if (files.some((f) => f.startsWith(indicator)) || await pathExists$1(indicatorPath)) {
2387
- evidence.push(`Found ${indicator} directory`);
2388
- confidence += 0.2;
2389
- }
2390
- }
2391
- if (packageJson) {
2392
- const allDeps = {
2393
- ...packageJson.dependencies,
2394
- ...packageJson.devDependencies
2395
- };
2396
- for (const dep of patterns.dependencies) {
2397
- if (allDeps[dep]) {
2398
- evidence.push(`Found ${dep} in dependencies`);
2399
- confidence += 0.4;
2400
- }
2401
- }
2402
- }
2403
- if (confidence > 0) {
2404
- let version;
2405
- if (packageJson) {
2406
- for (const dep of patterns.dependencies) {
2407
- const depVersion = packageJson.dependencies?.[dep] || packageJson.devDependencies?.[dep];
2408
- if (depVersion) {
2409
- version = depVersion;
2410
- break;
2411
- }
2412
- }
2413
- }
2414
- frameworks.push({
2415
- name: frameworkName,
2416
- category: getFrameworkCategory(frameworkName),
2417
- version,
2418
- confidence: Math.min(confidence, 1),
2419
- evidence
2420
- });
2421
- }
2422
- }
2423
- await detectAdditionalPatterns(projectPath, files, frameworks, packageJson);
2424
- frameworks.sort((a, b) => b.confidence - a.confidence);
2425
- logger$2.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
2426
- return frameworks;
2427
- }
2428
- function getFrameworkCategory(framework) {
2429
- const categories = {
2430
- frontend: [
2431
- "next.js",
2432
- "nuxt",
2433
- "sveltekit",
2434
- "astro",
2435
- "solidstart",
2436
- "qwik",
2437
- "remix",
2438
- "gatsby",
2439
- "vue",
2440
- "angular",
2441
- "react",
2442
- "preact",
2443
- "solidjs",
2444
- "svelte",
2445
- "ionic"
2446
- ],
2447
- backend: [
2448
- "nest.js",
2449
- "express",
2450
- "fastify",
2451
- "koa",
2452
- "adonisjs",
2453
- "feathers",
2454
- "meteor"
2455
- ],
2456
- desktop: ["electron"],
2457
- monorepo: ["turborepo", "nx", "lerna"]
2458
- };
2459
- for (const [category, frameworks] of Object.entries(categories)) {
2460
- if (frameworks.includes(framework)) {
2461
- return category;
2462
- }
2463
- }
2464
- return "other";
2465
- }
2466
- async function detectAdditionalPatterns(projectPath, files, frameworks, packageJson) {
2467
- if (files.includes("tsconfig.json")) {
2468
- const tsFramework = frameworks.find((f) => f.name === "typescript");
2469
- if (!tsFramework) {
2470
- frameworks.push({
2471
- name: "typescript",
2472
- category: "language",
2473
- confidence: 0.9,
2474
- evidence: ["Found tsconfig.json"]
2475
- });
2476
- }
2477
- }
2478
- const testDependencies = ["jest", "vitest", "cypress", "playwright", "mocha", "jasmine"];
2479
- if (packageJson) {
2480
- const allDeps = {
2481
- ...packageJson.dependencies,
2482
- ...packageJson.devDependencies
2483
- };
2484
- for (const testDep of testDependencies) {
2485
- if (allDeps[testDep]) {
2486
- frameworks.push({
2487
- name: testDep,
2488
- category: "testing",
2489
- version: allDeps[testDep],
2490
- confidence: 0.8,
2491
- evidence: [`Found ${testDep} in dependencies`]
2492
- });
2493
- }
2494
- }
2495
- }
2496
- const cssFrameworks = ["tailwindcss", "bootstrap", "bulma", "material-ui", "chakra-ui"];
2497
- if (packageJson) {
2498
- const allDeps = {
2499
- ...packageJson.dependencies,
2500
- ...packageJson.devDependencies
2501
- };
2502
- for (const cssFw of cssFrameworks) {
2503
- if (allDeps[cssFw]) {
2504
- frameworks.push({
2505
- name: cssFw,
2506
- category: "css",
2507
- version: allDeps[cssFw],
2508
- confidence: 0.8,
2509
- evidence: [`Found ${cssFw} in dependencies`]
2510
- });
2511
- }
2512
- }
2513
- }
2514
- const stateLibs = ["redux", "zustand", "recoil", "jotai", "valtio"];
2515
- if (packageJson) {
2516
- const allDeps = {
2517
- ...packageJson.dependencies,
2518
- ...packageJson.devDependencies
2519
- };
2520
- for (const lib of stateLibs) {
2521
- if (allDeps[lib]) {
2522
- frameworks.push({
2523
- name: lib,
2524
- category: "state-management",
2525
- version: allDeps[lib],
2526
- confidence: 0.8,
2527
- evidence: [`Found ${lib} in dependencies`]
2528
- });
2529
- }
2530
- }
2531
- }
2532
- const lintingTools = ["eslint", "prettier", "biome", "rome"];
2533
- if (packageJson) {
2534
- const allDeps = {
2535
- ...packageJson.dependencies,
2536
- ...packageJson.devDependencies
2537
- };
2538
- for (const tool of lintingTools) {
2539
- if (allDeps[tool]) {
2540
- frameworks.push({
2541
- name: tool,
2542
- category: "linting",
2543
- version: allDeps[tool],
2544
- confidence: 0.8,
2545
- evidence: [`Found ${tool} in dependencies`]
2546
- });
2547
- }
2548
- }
2549
- }
2550
- const deploymentFiles = {
2551
- "vercel.json": "vercel",
2552
- "netlify.toml": "netlify",
2553
- "app.yaml": "app-engine",
2554
- "now.json": "now"
2555
- };
2556
- for (const [file, platform] of Object.entries(deploymentFiles)) {
2557
- if (files.includes(file)) {
2558
- frameworks.push({
2559
- name: platform,
2560
- category: "deployment",
2561
- confidence: 0.9,
2562
- evidence: [`Found ${file}`]
2563
- });
2564
- }
2565
- }
2566
- }
2567
-
2568
- async function pathExists(p) {
2569
- try {
2570
- await promises.access(p);
2571
- return true;
2572
- } catch {
2573
- return false;
2574
- }
2575
- }
2576
- const logger$1 = consola.withTag("project-detector");
2577
- const LANGUAGE_PATTERNS = {
2578
- typescript: {
2579
- files: ["package.json", "tsconfig.json", "tsconfig.build.json"],
2580
- extensions: [".ts", ".tsx", ".mts", ".cts"],
2581
- indicators: ["node_modules", "yarn.lock", "package-lock.json", "pnpm-lock.yaml"]
2582
- },
2583
- javascript: {
2584
- files: ["package.json"],
2585
- extensions: [".js", ".jsx", ".mjs", ".cjs"],
2586
- indicators: ["node_modules", "yarn.lock", "package-lock.json", "pnpm-lock.yaml"]
2587
- },
2588
- python: {
2589
- files: ["requirements.txt", "pyproject.toml", "setup.py", "Pipfile"],
2590
- extensions: [".py", ".pyx", ".pyi"],
2591
- indicators: [".venv", "venv", "__pycache__", ".python-version"]
2592
- },
2593
- go: {
2594
- files: ["go.mod", "go.sum"],
2595
- extensions: [".go"],
2596
- indicators: ["vendor", "Gopkg.lock"]
2597
- },
2598
- rust: {
2599
- files: ["Cargo.toml", "Cargo.lock"],
2600
- extensions: [".rs"],
2601
- indicators: ["target"]
2602
- },
2603
- java: {
2604
- files: ["pom.xml", "build.gradle", "build.gradle.kts"],
2605
- extensions: [".java", ".kt"],
2606
- indicators: ["gradlew", "mvnw"]
2607
- },
2608
- dotnet: {
2609
- files: ["*.csproj", "*.sln", "*.fsproj", "*.vbproj"],
2610
- extensions: [".cs", ".fs", ".vb"],
2611
- indicators: ["bin", "obj"]
2612
- },
2613
- ruby: {
2614
- files: ["Gemfile", "Gemfile.lock"],
2615
- extensions: [".rb"],
2616
- indicators: ["vendor/bundle"]
2617
- },
2618
- php: {
2619
- files: ["composer.json", "composer.lock"],
2620
- extensions: [".php"],
2621
- indicators: ["vendor"]
2622
- },
2623
- swift: {
2624
- files: ["Package.swift"],
2625
- extensions: [".swift"],
2626
- indicators: [".build"]
2627
- },
2628
- kotlin: {
2629
- files: ["build.gradle.kts"],
2630
- extensions: [".kt", ".kts"],
2631
- indicators: ["gradlew"]
2632
- },
2633
- dart: {
2634
- files: ["pubspec.yaml"],
2635
- extensions: [".dart"],
2636
- indicators: [".dart_tool"]
2637
- }
2638
- };
2639
- const FRAMEWORK_PRIORITY = {
2640
- "next.js": 10,
2641
- "nuxt": 9,
2642
- "sveltekit": 8,
2643
- "astro": 7,
2644
- "solidstart": 6,
2645
- "qwik": 5,
2646
- "remix": 4,
2647
- "gatsby": 3,
2648
- "create-react-app": 2,
2649
- "vue": 1,
2650
- "angular": 1,
2651
- "react": 0
2652
- };
2653
- async function detectProject(projectPath, config) {
2654
- const startTime = Date.now();
2655
- logger$1.info(`Detecting project at: ${projectPath}`);
2656
- const absolutePath = posix.resolve(projectPath);
2657
- if (!await pathExists(absolutePath)) {
2658
- throw new Error(`Project path does not exist: ${absolutePath}`);
2659
- }
2660
- const files = await scanProjectFiles(absolutePath, config);
2661
- logger$1.debug(`Scanned ${files.length} files`);
2662
- const languages = await detectLanguages(absolutePath, files, config);
2663
- logger$1.debug(`Detected languages: ${languages.map((l) => l.language).join(", ")}`);
2664
- languages.sort((a, b) => b.confidence - a.confidence);
2665
- const primaryLanguage = languages[0];
2666
- let frameworks = [];
2667
- if (primaryLanguage) {
2668
- switch (primaryLanguage.language) {
2669
- case "typescript":
2670
- case "javascript":
2671
- frameworks = await analyzeTypeScriptProject(absolutePath, files);
2672
- break;
2673
- case "python":
2674
- frameworks = await analyzePythonProject(absolutePath, files);
2675
- break;
2676
- case "go":
2677
- frameworks = await analyzeGoProject(absolutePath, files);
2678
- break;
2679
- case "rust":
2680
- frameworks = await analyzeRustProject(absolutePath, files);
2681
- break;
2682
- }
2683
- }
2684
- const packageManager = detectPackageManager(files);
2685
- const buildSystem = detectBuildSystem(files, frameworks);
2686
- const configFiles = detectConfigFiles(files);
2687
- const importantDirs = detectImportantDirs(absolutePath);
2688
- const analysis = {
2689
- rootPath: absolutePath,
2690
- projectType: determineProjectType(languages, frameworks),
2691
- languages,
2692
- frameworks,
2693
- packageManager,
2694
- buildSystem,
2695
- configFiles,
2696
- importantDirs,
2697
- metadata: {
2698
- timestamp: /* @__PURE__ */ new Date(),
2699
- duration: Date.now() - startTime,
2700
- filesScanned: files.length,
2701
- confidence: calculateOverallConfidence(languages, frameworks),
2702
- version: "1.0.0"
2703
- }
2704
- };
2705
- logger$1.info(`Detected project type: ${analysis.projectType}`);
2706
- return analysis;
2707
- }
2708
- const ROOT_CONFIG_FILES = [
2709
- "package.json",
2710
- "tsconfig.json",
2711
- "jsconfig.json",
2712
- "go.mod",
2713
- "Cargo.toml",
2714
- "pyproject.toml",
2715
- "requirements.txt",
2716
- "setup.py",
2717
- "Gemfile",
2718
- "composer.json",
2719
- "pom.xml",
2720
- "build.gradle",
2721
- "build.gradle.kts",
2722
- "pubspec.yaml",
2723
- "Package.swift",
2724
- "pom.xml"
2725
- ];
2726
- async function scanProjectFiles(projectPath, config) {
2727
- const rootConfigFiles = [];
2728
- for (const configFile of ROOT_CONFIG_FILES) {
2729
- const configPath = posix.join(projectPath, configFile);
2730
- if (await pathExists(configPath)) {
2731
- rootConfigFiles.push(configFile);
2732
- logger$1.debug(`Found root config: ${configFile}`);
2733
- }
2734
- }
2735
- const patterns = ["**/*"];
2736
- const ignore = config.excludePatterns;
2737
- if (!config.includeNodeModules) {
2738
- ignore.push("node_modules/**");
2739
- }
2740
- const allFiles = await glob(patterns, {
2741
- cwd: projectPath,
2742
- ignore,
2743
- absolute: false
2744
- });
2745
- const fileSet = /* @__PURE__ */ new Set([...rootConfigFiles, ...allFiles]);
2746
- const files = Array.from(fileSet);
2747
- if (files.length > config.maxFilesToScan) {
2748
- logger$1.warn(`Too many files (${files.length}), limiting to ${config.maxFilesToScan}`);
2749
- const rootConfigs = files.filter((f) => ROOT_CONFIG_FILES.includes(f));
2750
- const otherFiles = files.filter((f) => !ROOT_CONFIG_FILES.includes(f));
2751
- const limitedOthers = otherFiles.slice(0, config.maxFilesToScan - rootConfigs.length);
2752
- return [...rootConfigs, ...limitedOthers];
2753
- }
2754
- return files;
2755
- }
2756
- async function detectLanguages(projectPath, files, config) {
2757
- const languageCounts = /* @__PURE__ */ new Map();
2758
- const languageIndicators = /* @__PURE__ */ new Map();
2759
- for (const file of files) {
2760
- const ext = posix.extname(file).toLowerCase();
2761
- for (const [language, patterns] of Object.entries(LANGUAGE_PATTERNS)) {
2762
- const extensions = patterns.extensions;
2763
- if (extensions.includes(ext)) {
2764
- languageCounts.set(language, (languageCounts.get(language) || 0) + 1);
2765
- }
2766
- }
2767
- }
2768
- const fileSet = new Set(files);
2769
- for (const [language, patterns] of Object.entries(LANGUAGE_PATTERNS)) {
2770
- const indicators = [];
2771
- for (const file of patterns.files) {
2772
- if (fileSet.has(file) || fileSet.has(file.toLowerCase())) {
2773
- indicators.push(`Found ${file}`);
2774
- languageCounts.set(language, (languageCounts.get(language) || 0) + 10);
2775
- }
2776
- }
2777
- for (const indicator of patterns.indicators) {
2778
- if (fileSet.has(indicator) || await pathExists(posix.join(projectPath, indicator))) {
2779
- indicators.push(`Found ${indicator}`);
2780
- languageCounts.set(language, (languageCounts.get(language) || 0) + 5);
2781
- }
2782
- }
2783
- if (indicators.length > 0) {
2784
- languageIndicators.set(language, new Set(indicators));
2785
- }
2786
- }
2787
- const totalFiles = files.length;
2788
- const languages = [];
2789
- for (const [language, count] of Array.from(languageCounts.entries())) {
2790
- const confidence = Math.min(count / totalFiles, 1);
2791
- if (confidence >= config.minConfidence) {
2792
- languages.push({
2793
- language,
2794
- confidence,
2795
- fileCount: count,
2796
- indicators: Array.from(languageIndicators.get(language) || [])
2797
- });
2798
- }
2799
- }
2800
- return languages;
2801
- }
2802
- function detectPackageManager(files) {
2803
- const managers = {
2804
- "pnpm-lock.yaml": "pnpm",
2805
- "yarn.lock": "yarn",
2806
- "package-lock.json": "npm",
2807
- "bun.lockb": "bun",
2808
- "requirements.txt": "pip",
2809
- "Pipfile": "pipenv",
2810
- "pyproject.toml": "poetry",
2811
- "go.mod": "go",
2812
- "Cargo.toml": "cargo",
2813
- "pom.xml": "maven",
2814
- "build.gradle": "gradle"
2815
- };
2816
- for (const [file, manager] of Object.entries(managers)) {
2817
- if (files.includes(file)) {
2818
- return manager;
2819
- }
2820
- }
2821
- return void 0;
2822
- }
2823
- function detectBuildSystem(files, frameworks) {
2824
- for (const framework of frameworks) {
2825
- if (framework.name.includes("next"))
2826
- return "next";
2827
- if (framework.name.includes("nuxt"))
2828
- return "nuxt";
2829
- if (framework.name.includes("sveltekit"))
2830
- return "svelte";
2831
- if (framework.name.includes("astro"))
2832
- return "unknown";
2833
- }
2834
- const buildFiles = {
2835
- "webpack.config.js": "webpack",
2836
- "webpack.config.ts": "webpack",
2837
- "vite.config.ts": "vite",
2838
- "vite.config.js": "vite",
2839
- "rollup.config.js": "rollup",
2840
- "rollup.config.ts": "rollup",
2841
- "esbuild.config.js": "esbuild",
2842
- "tsconfig.json": "tsc",
2843
- ".babelrc": "babel",
2844
- "babel.config.js": "babel",
2845
- ".swcrc": "swc",
2846
- "Makefile": "make",
2847
- "CMakeLists.txt": "cmake",
2848
- "BUILD": "bazel"
2849
- };
2850
- for (const [file, system] of Object.entries(buildFiles)) {
2851
- if (files.includes(file)) {
2852
- return system;
2853
- }
2854
- }
2855
- return void 0;
2856
- }
2857
- function detectConfigFiles(files) {
2858
- const configPatterns = [
2859
- "package.json",
2860
- "tsconfig.json",
2861
- "jsconfig.json",
2862
- "pyproject.toml",
2863
- "requirements.txt",
2864
- "setup.py",
2865
- "go.mod",
2866
- "Cargo.toml",
2867
- "pom.xml",
2868
- "build.gradle",
2869
- "build.gradle.kts",
2870
- "composer.json",
2871
- "Gemfile",
2872
- "pubspec.yaml",
2873
- "docker-compose.yml",
2874
- "docker-compose.yaml",
2875
- "Dockerfile",
2876
- ".env",
2877
- ".env.example",
2878
- ".gitignore",
2879
- ".dockerignore",
2880
- "README.md",
2881
- "readme.md",
2882
- "README.rst",
2883
- "readme.rst"
2884
- ];
2885
- return files.filter((file) => configPatterns.includes(file));
2886
- }
2887
- function detectImportantDirs(projectPath) {
2888
- const importantDirs = [
2889
- "src",
2890
- "lib",
2891
- "app",
2892
- "public",
2893
- "static",
2894
- "assets",
2895
- "components",
2896
- "pages",
2897
- "views",
2898
- "templates",
2899
- "styles",
2900
- "css",
2901
- "scss",
2902
- "sass",
2903
- "less",
2904
- "tests",
2905
- "test",
2906
- "spec",
2907
- "__tests__",
2908
- "docs",
2909
- "doc",
2910
- "examples",
2911
- "samples",
2912
- "scripts",
2913
- "bin",
2914
- "tools",
2915
- "config",
2916
- "configs",
2917
- "build",
2918
- "dist",
2919
- "out",
2920
- "target",
2921
- ".github",
2922
- ".vscode",
2923
- ".idea"
2924
- ];
2925
- const foundDirs = [];
2926
- for (const dir of importantDirs) {
2927
- if (existsSync(posix.join(projectPath, dir))) {
2928
- foundDirs.push(dir);
2929
- }
2930
- }
2931
- return foundDirs;
2932
- }
2933
- function determineProjectType(languages, frameworks) {
2934
- if (languages.length === 0) {
2935
- return "unknown";
2936
- }
2937
- const sortedFrameworks = [...frameworks].sort((a, b) => {
2938
- const priorityA = FRAMEWORK_PRIORITY[a.name.toLowerCase()] || 0;
2939
- const priorityB = FRAMEWORK_PRIORITY[b.name.toLowerCase()] || 0;
2940
- return priorityB - priorityA;
2941
- });
2942
- if (sortedFrameworks.length > 0 && sortedFrameworks[0].confidence > 0.7) {
2943
- return sortedFrameworks[0].name;
2944
- }
2945
- return languages[0].language;
2946
- }
2947
- function calculateOverallConfidence(languages, frameworks) {
2948
- if (languages.length === 0)
2949
- return 0;
2950
- const langConfidence = languages.reduce((sum, lang) => sum + lang.confidence, 0) / languages.length;
2951
- let frameworkConfidence = 0;
2952
- if (frameworks.length > 0) {
2953
- frameworkConfidence = frameworks.reduce((sum, fw) => sum + fw.confidence, 0) / frameworks.length;
2954
- }
2955
- return frameworkConfidence > 0 ? langConfidence * 0.7 + frameworkConfidence * 0.3 : langConfidence;
2956
- }
2957
-
2958
- class ProjectAnalyzer {
2959
- config = {};
2960
- constructor(config = {}) {
2961
- this.config = config;
2962
- }
2963
- /**
2964
- * Analyze a project directory
2965
- */
2966
- async analyze(projectPath) {
2967
- return analyzeProject(projectPath, this.config);
2968
- }
2969
- /**
2970
- * Get project type only
2971
- */
2972
- async getProjectType(projectPath) {
2973
- return detectProjectType(projectPath);
2974
- }
2975
- }
2976
- const logger = consola.withTag("analyzer");
2977
- const DEFAULT_CONFIG = {
2978
- minConfidence: 0.05,
2979
- // Lower threshold for large projects with many file types
2980
- includeNodeModules: false,
2981
- analyzeTransitiveDeps: true,
2982
- maxFilesToScan: 1e4,
2983
- includePatterns: [],
2984
- excludePatterns: [
2985
- "node_modules",
2986
- ".git",
2987
- "dist",
2988
- "build",
2989
- "coverage",
2990
- ".vscode",
2991
- ".idea",
2992
- "*.log",
2993
- "*.tmp",
2994
- ".DS_Store",
2995
- "Thumbs.db"
2996
- ]
2997
- };
2998
- async function analyzeProject(projectPath, config = {}) {
2999
- const startTime = Date.now();
3000
- logger.info(`Analyzing project at: ${projectPath}`);
3001
- const mergedConfig = {
3002
- ...DEFAULT_CONFIG,
3003
- ...config
3004
- };
3005
- try {
3006
- const analysis = await detectProject(projectPath, mergedConfig);
3007
- if (mergedConfig.analyzeTransitiveDeps && analysis.dependencies) {
3008
- analysis.dependencies = await analyzeDependencies$1(analysis, mergedConfig);
3009
- }
3010
- analysis.metadata.duration = Date.now() - startTime;
3011
- logger.success(`Project analysis completed in ${analysis.metadata.duration}ms`);
3012
- logger.info(`Detected: ${analysis.projectType} (${analysis.metadata.confidence * 100}% confidence)`);
3013
- return analysis;
3014
- } catch (error) {
3015
- logger.error("Project analysis failed:", error);
3016
- throw new Error(`Failed to analyze project at ${projectPath}: ${error instanceof Error ? error.message : String(error)}`);
3017
- }
3018
- }
3019
- async function detectProjectType(projectPath) {
3020
- const analysis = await analyzeProject(projectPath, {
3021
- analyzeTransitiveDeps: false
3022
- });
3023
- return analysis.projectType;
3024
- }
3025
- async function batchAnalyze(projectPaths, config = {}) {
3026
- logger.info(`Batch analyzing ${projectPaths.length} projects`);
3027
- const results = [];
3028
- for (const path of projectPaths) {
3029
- try {
3030
- const analysis = await analyzeProject(path, config);
3031
- results.push(analysis);
3032
- } catch (error) {
3033
- logger.error(`Failed to analyze ${path}:`, error);
3034
- }
3035
- }
3036
- logger.success(`Batch analysis completed: ${results.length}/${projectPaths.length} successful`);
3037
- return results;
3038
- }
3039
-
3040
- const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
3041
- const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
3042
- const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
3043
- function jsonParseTransform(key, value) {
3044
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
3045
- warnKeyDropped(key);
3046
- return;
3047
- }
3048
- return value;
3049
- }
3050
- function warnKeyDropped(key) {
3051
- console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
3052
- }
3053
- function destr(value, options = {}) {
3054
- if (typeof value !== "string") {
3055
- return value;
3056
- }
3057
- if (value[0] === '"' && value[value.length - 1] === '"' && value.indexOf("\\") === -1) {
3058
- return value.slice(1, -1);
3059
- }
3060
- const _value = value.trim();
3061
- if (_value.length <= 9) {
3062
- switch (_value.toLowerCase()) {
3063
- case "true": {
3064
- return true;
3065
- }
3066
- case "false": {
3067
- return false;
3068
- }
3069
- case "undefined": {
3070
- return void 0;
3071
- }
3072
- case "null": {
3073
- return null;
3074
- }
3075
- case "nan": {
3076
- return Number.NaN;
3077
- }
3078
- case "infinity": {
3079
- return Number.POSITIVE_INFINITY;
3080
- }
3081
- case "-infinity": {
3082
- return Number.NEGATIVE_INFINITY;
3083
- }
3084
- }
3085
- }
3086
- if (!JsonSigRx.test(value)) {
3087
- if (options.strict) {
3088
- throw new SyntaxError("[destr] Invalid JSON");
3089
- }
3090
- return value;
3091
- }
3092
- try {
3093
- if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
3094
- if (options.strict) {
3095
- throw new Error("[destr] Possible prototype pollution");
3096
- }
3097
- return JSON.parse(value, jsonParseTransform);
3098
- }
3099
- return JSON.parse(value);
3100
- } catch (error) {
3101
- if (options.strict) {
3102
- throw error;
3103
- }
3104
- return value;
3105
- }
3106
- }
3107
-
3108
- const HASH_RE = /#/g;
3109
- const AMPERSAND_RE = /&/g;
3110
- const SLASH_RE = /\//g;
3111
- const EQUAL_RE = /=/g;
3112
- const PLUS_RE = /\+/g;
3113
- const ENC_CARET_RE = /%5e/gi;
3114
- const ENC_BACKTICK_RE = /%60/gi;
3115
- const ENC_PIPE_RE = /%7c/gi;
3116
- const ENC_SPACE_RE = /%20/gi;
3117
- function encode(text) {
3118
- return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
3119
- }
3120
- function encodeQueryValue(input) {
3121
- return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
3122
- }
3123
- function encodeQueryKey(text) {
3124
- return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
3125
- }
3126
- function decode(text = "") {
3127
- try {
3128
- return decodeURIComponent("" + text);
3129
- } catch {
3130
- return "" + text;
3131
- }
3132
- }
3133
- function decodeQueryKey(text) {
3134
- return decode(text.replace(PLUS_RE, " "));
3135
- }
3136
- function decodeQueryValue(text) {
3137
- return decode(text.replace(PLUS_RE, " "));
3138
- }
3139
-
3140
- function parseQuery(parametersString = "") {
3141
- const object = /* @__PURE__ */ Object.create(null);
3142
- if (parametersString[0] === "?") {
3143
- parametersString = parametersString.slice(1);
3144
- }
3145
- for (const parameter of parametersString.split("&")) {
3146
- const s = parameter.match(/([^=]+)=?(.*)/) || [];
3147
- if (s.length < 2) {
3148
- continue;
3149
- }
3150
- const key = decodeQueryKey(s[1]);
3151
- if (key === "__proto__" || key === "constructor") {
3152
- continue;
3153
- }
3154
- const value = decodeQueryValue(s[2] || "");
3155
- if (object[key] === void 0) {
3156
- object[key] = value;
3157
- } else if (Array.isArray(object[key])) {
3158
- object[key].push(value);
3159
- } else {
3160
- object[key] = [object[key], value];
3161
- }
3162
- }
3163
- return object;
3164
- }
3165
- function encodeQueryItem(key, value) {
3166
- if (typeof value === "number" || typeof value === "boolean") {
3167
- value = String(value);
3168
- }
3169
- if (!value) {
3170
- return encodeQueryKey(key);
3171
- }
3172
- if (Array.isArray(value)) {
3173
- return value.map(
3174
- (_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`
3175
- ).join("&");
3176
- }
3177
- return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
3178
- }
3179
- function stringifyQuery(query) {
3180
- return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
3181
- }
3182
-
3183
- const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
3184
- const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
3185
- const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
3186
- const JOIN_LEADING_SLASH_RE = /^\.?\//;
3187
- function hasProtocol(inputString, opts = {}) {
3188
- if (typeof opts === "boolean") {
3189
- opts = { acceptRelative: opts };
3190
- }
3191
- if (opts.strict) {
3192
- return PROTOCOL_STRICT_REGEX.test(inputString);
3193
- }
3194
- return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
3195
- }
3196
- function hasTrailingSlash(input = "", respectQueryAndFragment) {
3197
- {
3198
- return input.endsWith("/");
3199
- }
3200
- }
3201
- function withoutTrailingSlash(input = "", respectQueryAndFragment) {
3202
- {
3203
- return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
3204
- }
3205
- }
3206
- function withTrailingSlash(input = "", respectQueryAndFragment) {
3207
- {
3208
- return input.endsWith("/") ? input : input + "/";
3209
- }
3210
- }
3211
- function withBase(input, base) {
3212
- if (isEmptyURL(base) || hasProtocol(input)) {
3213
- return input;
3214
- }
3215
- const _base = withoutTrailingSlash(base);
3216
- if (input.startsWith(_base)) {
3217
- return input;
3218
- }
3219
- return joinURL(_base, input);
3220
- }
3221
- function withQuery(input, query) {
3222
- const parsed = parseURL(input);
3223
- const mergedQuery = { ...parseQuery(parsed.search), ...query };
3224
- parsed.search = stringifyQuery(mergedQuery);
3225
- return stringifyParsedURL(parsed);
3226
- }
3227
- function isEmptyURL(url) {
3228
- return !url || url === "/";
3229
- }
3230
- function isNonEmptyURL(url) {
3231
- return url && url !== "/";
3232
- }
3233
- function joinURL(base, ...input) {
3234
- let url = base || "";
3235
- for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {
3236
- if (url) {
3237
- const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
3238
- url = withTrailingSlash(url) + _segment;
3239
- } else {
3240
- url = segment;
3241
- }
3242
- }
3243
- return url;
3244
- }
3245
-
3246
- const protocolRelative = Symbol.for("ufo:protocolRelative");
3247
- function parseURL(input = "", defaultProto) {
3248
- const _specialProtoMatch = input.match(
3249
- /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
3250
- );
3251
- if (_specialProtoMatch) {
3252
- const [, _proto, _pathname = ""] = _specialProtoMatch;
3253
- return {
3254
- protocol: _proto.toLowerCase(),
3255
- pathname: _pathname,
3256
- href: _proto + _pathname,
3257
- auth: "",
3258
- host: "",
3259
- search: "",
3260
- hash: ""
3261
- };
3262
- }
3263
- if (!hasProtocol(input, { acceptRelative: true })) {
3264
- return parsePath(input);
3265
- }
3266
- const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
3267
- let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
3268
- if (protocol === "file:") {
3269
- path = path.replace(/\/(?=[A-Za-z]:)/, "");
3270
- }
3271
- const { pathname, search, hash } = parsePath(path);
3272
- return {
3273
- protocol: protocol.toLowerCase(),
3274
- auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
3275
- host,
3276
- pathname,
3277
- search,
3278
- hash,
3279
- [protocolRelative]: !protocol
3280
- };
3281
- }
3282
- function parsePath(input = "") {
3283
- const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
3284
- return {
3285
- pathname,
3286
- search,
3287
- hash
3288
- };
3289
- }
3290
- function stringifyParsedURL(parsed) {
3291
- const pathname = parsed.pathname || "";
3292
- const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
3293
- const hash = parsed.hash || "";
3294
- const auth = parsed.auth ? parsed.auth + "@" : "";
3295
- const host = parsed.host || "";
3296
- const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "";
3297
- return proto + auth + host + pathname + search + hash;
3298
- }
3299
-
3300
- class FetchError extends Error {
3301
- constructor(message, opts) {
3302
- super(message, opts);
3303
- this.name = "FetchError";
3304
- if (opts?.cause && !this.cause) {
3305
- this.cause = opts.cause;
3306
- }
3307
- }
3308
- }
3309
- function createFetchError(ctx) {
3310
- const errorMessage = ctx.error?.message || ctx.error?.toString() || "";
3311
- const method = ctx.request?.method || ctx.options?.method || "GET";
3312
- const url = ctx.request?.url || String(ctx.request) || "/";
3313
- const requestStr = `[${method}] ${JSON.stringify(url)}`;
3314
- const statusStr = ctx.response ? `${ctx.response.status} ${ctx.response.statusText}` : "<no response>";
3315
- const message = `${requestStr}: ${statusStr}${errorMessage ? ` ${errorMessage}` : ""}`;
3316
- const fetchError = new FetchError(
3317
- message,
3318
- ctx.error ? { cause: ctx.error } : void 0
3319
- );
3320
- for (const key of ["request", "options", "response"]) {
3321
- Object.defineProperty(fetchError, key, {
3322
- get() {
3323
- return ctx[key];
3324
- }
3325
- });
3326
- }
3327
- for (const [key, refKey] of [
3328
- ["data", "_data"],
3329
- ["status", "status"],
3330
- ["statusCode", "status"],
3331
- ["statusText", "statusText"],
3332
- ["statusMessage", "statusText"]
3333
- ]) {
3334
- Object.defineProperty(fetchError, key, {
3335
- get() {
3336
- return ctx.response && ctx.response[refKey];
3337
- }
3338
- });
3339
- }
3340
- return fetchError;
3341
- }
3342
-
3343
- const payloadMethods = new Set(
3344
- Object.freeze(["PATCH", "POST", "PUT", "DELETE"])
3345
- );
3346
- function isPayloadMethod(method = "GET") {
3347
- return payloadMethods.has(method.toUpperCase());
3348
- }
3349
- function isJSONSerializable(value) {
3350
- if (value === void 0) {
3351
- return false;
3352
- }
3353
- const t = typeof value;
3354
- if (t === "string" || t === "number" || t === "boolean" || t === null) {
3355
- return true;
3356
- }
3357
- if (t !== "object") {
3358
- return false;
3359
- }
3360
- if (Array.isArray(value)) {
3361
- return true;
3362
- }
3363
- if (value.buffer) {
3364
- return false;
3365
- }
3366
- if (value instanceof FormData || value instanceof URLSearchParams) {
3367
- return false;
3368
- }
3369
- return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
3370
- }
3371
- const textTypes = /* @__PURE__ */ new Set([
3372
- "image/svg",
3373
- "application/xml",
3374
- "application/xhtml",
3375
- "application/html"
3376
- ]);
3377
- const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
3378
- function detectResponseType(_contentType = "") {
3379
- if (!_contentType) {
3380
- return "json";
3381
- }
3382
- const contentType = _contentType.split(";").shift() || "";
3383
- if (JSON_RE.test(contentType)) {
3384
- return "json";
3385
- }
3386
- if (contentType === "text/event-stream") {
3387
- return "stream";
3388
- }
3389
- if (textTypes.has(contentType) || contentType.startsWith("text/")) {
3390
- return "text";
3391
- }
3392
- return "blob";
3393
- }
3394
- function resolveFetchOptions(request, input, defaults, Headers) {
3395
- const headers = mergeHeaders(
3396
- input?.headers ?? request?.headers,
3397
- defaults?.headers,
3398
- Headers
3399
- );
3400
- let query;
3401
- if (defaults?.query || defaults?.params || input?.params || input?.query) {
3402
- query = {
3403
- ...defaults?.params,
3404
- ...defaults?.query,
3405
- ...input?.params,
3406
- ...input?.query
3407
- };
3408
- }
3409
- return {
3410
- ...defaults,
3411
- ...input,
3412
- query,
3413
- params: query,
3414
- headers
3415
- };
3416
- }
3417
- function mergeHeaders(input, defaults, Headers) {
3418
- if (!defaults) {
3419
- return new Headers(input);
3420
- }
3421
- const headers = new Headers(defaults);
3422
- if (input) {
3423
- for (const [key, value] of Symbol.iterator in input || Array.isArray(input) ? input : new Headers(input)) {
3424
- headers.set(key, value);
3425
- }
3426
- }
3427
- return headers;
3428
- }
3429
- async function callHooks(context, hooks) {
3430
- if (hooks) {
3431
- if (Array.isArray(hooks)) {
3432
- for (const hook of hooks) {
3433
- await hook(context);
3434
- }
3435
- } else {
3436
- await hooks(context);
3437
- }
3438
- }
3439
- }
3440
-
3441
- const retryStatusCodes = /* @__PURE__ */ new Set([
3442
- 408,
3443
- // Request Timeout
3444
- 409,
3445
- // Conflict
3446
- 425,
3447
- // Too Early (Experimental)
3448
- 429,
3449
- // Too Many Requests
3450
- 500,
3451
- // Internal Server Error
3452
- 502,
3453
- // Bad Gateway
3454
- 503,
3455
- // Service Unavailable
3456
- 504
3457
- // Gateway Timeout
3458
- ]);
3459
- const nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]);
3460
- function createFetch(globalOptions = {}) {
3461
- const {
3462
- fetch = globalThis.fetch,
3463
- Headers = globalThis.Headers,
3464
- AbortController = globalThis.AbortController
3465
- } = globalOptions;
3466
- async function onError(context) {
3467
- const isAbort = context.error && context.error.name === "AbortError" && !context.options.timeout || false;
3468
- if (context.options.retry !== false && !isAbort) {
3469
- let retries;
3470
- if (typeof context.options.retry === "number") {
3471
- retries = context.options.retry;
3472
- } else {
3473
- retries = isPayloadMethod(context.options.method) ? 0 : 1;
3474
- }
3475
- const responseCode = context.response && context.response.status || 500;
3476
- if (retries > 0 && (Array.isArray(context.options.retryStatusCodes) ? context.options.retryStatusCodes.includes(responseCode) : retryStatusCodes.has(responseCode))) {
3477
- const retryDelay = typeof context.options.retryDelay === "function" ? context.options.retryDelay(context) : context.options.retryDelay || 0;
3478
- if (retryDelay > 0) {
3479
- await new Promise((resolve) => setTimeout(resolve, retryDelay));
3480
- }
3481
- return $fetchRaw(context.request, {
3482
- ...context.options,
3483
- retry: retries - 1
3484
- });
3485
- }
3486
- }
3487
- const error = createFetchError(context);
3488
- if (Error.captureStackTrace) {
3489
- Error.captureStackTrace(error, $fetchRaw);
3490
- }
3491
- throw error;
3492
- }
3493
- const $fetchRaw = async function $fetchRaw2(_request, _options = {}) {
3494
- const context = {
3495
- request: _request,
3496
- options: resolveFetchOptions(
3497
- _request,
3498
- _options,
3499
- globalOptions.defaults,
3500
- Headers
3501
- ),
3502
- response: void 0,
3503
- error: void 0
3504
- };
3505
- if (context.options.method) {
3506
- context.options.method = context.options.method.toUpperCase();
3507
- }
3508
- if (context.options.onRequest) {
3509
- await callHooks(context, context.options.onRequest);
3510
- if (!(context.options.headers instanceof Headers)) {
3511
- context.options.headers = new Headers(
3512
- context.options.headers || {}
3513
- /* compat */
3514
- );
3515
- }
3516
- }
3517
- if (typeof context.request === "string") {
3518
- if (context.options.baseURL) {
3519
- context.request = withBase(context.request, context.options.baseURL);
3520
- }
3521
- if (context.options.query) {
3522
- context.request = withQuery(context.request, context.options.query);
3523
- delete context.options.query;
3524
- }
3525
- if ("query" in context.options) {
3526
- delete context.options.query;
3527
- }
3528
- if ("params" in context.options) {
3529
- delete context.options.params;
3530
- }
3531
- }
3532
- if (context.options.body && isPayloadMethod(context.options.method)) {
3533
- if (isJSONSerializable(context.options.body)) {
3534
- const contentType = context.options.headers.get("content-type");
3535
- if (typeof context.options.body !== "string") {
3536
- context.options.body = contentType === "application/x-www-form-urlencoded" ? new URLSearchParams(
3537
- context.options.body
3538
- ).toString() : JSON.stringify(context.options.body);
3539
- }
3540
- if (!contentType) {
3541
- context.options.headers.set("content-type", "application/json");
3542
- }
3543
- if (!context.options.headers.has("accept")) {
3544
- context.options.headers.set("accept", "application/json");
3545
- }
3546
- } else if (
3547
- // ReadableStream Body
3548
- "pipeTo" in context.options.body && typeof context.options.body.pipeTo === "function" || // Node.js Stream Body
3549
- typeof context.options.body.pipe === "function"
3550
- ) {
3551
- if (!("duplex" in context.options)) {
3552
- context.options.duplex = "half";
3553
- }
3554
- }
3555
- }
3556
- let abortTimeout;
3557
- if (!context.options.signal && context.options.timeout) {
3558
- const controller = new AbortController();
3559
- abortTimeout = setTimeout(() => {
3560
- const error = new Error(
3561
- "[TimeoutError]: The operation was aborted due to timeout"
3562
- );
3563
- error.name = "TimeoutError";
3564
- error.code = 23;
3565
- controller.abort(error);
3566
- }, context.options.timeout);
3567
- context.options.signal = controller.signal;
3568
- }
3569
- try {
3570
- context.response = await fetch(
3571
- context.request,
3572
- context.options
3573
- );
3574
- } catch (error) {
3575
- context.error = error;
3576
- if (context.options.onRequestError) {
3577
- await callHooks(
3578
- context,
3579
- context.options.onRequestError
3580
- );
3581
- }
3582
- return await onError(context);
3583
- } finally {
3584
- if (abortTimeout) {
3585
- clearTimeout(abortTimeout);
3586
- }
3587
- }
3588
- const hasBody = (context.response.body || // https://github.com/unjs/ofetch/issues/324
3589
- // https://github.com/unjs/ofetch/issues/294
3590
- // https://github.com/JakeChampion/fetch/issues/1454
3591
- context.response._bodyInit) && !nullBodyResponses.has(context.response.status) && context.options.method !== "HEAD";
3592
- if (hasBody) {
3593
- const responseType = (context.options.parseResponse ? "json" : context.options.responseType) || detectResponseType(context.response.headers.get("content-type") || "");
3594
- switch (responseType) {
3595
- case "json": {
3596
- const data = await context.response.text();
3597
- const parseFunction = context.options.parseResponse || destr;
3598
- context.response._data = parseFunction(data);
3599
- break;
3600
- }
3601
- case "stream": {
3602
- context.response._data = context.response.body || context.response._bodyInit;
3603
- break;
3604
- }
3605
- default: {
3606
- context.response._data = await context.response[responseType]();
3607
- }
3608
- }
3609
- }
3610
- if (context.options.onResponse) {
3611
- await callHooks(
3612
- context,
3613
- context.options.onResponse
3614
- );
3615
- }
3616
- if (!context.options.ignoreResponseError && context.response.status >= 400 && context.response.status < 600) {
3617
- if (context.options.onResponseError) {
3618
- await callHooks(
3619
- context,
3620
- context.options.onResponseError
3621
- );
3622
- }
3623
- return await onError(context);
3624
- }
3625
- return context.response;
3626
- };
3627
- const $fetch = async function $fetch2(request, options) {
3628
- const r = await $fetchRaw(request, options);
3629
- return r._data;
3630
- };
3631
- $fetch.raw = $fetchRaw;
3632
- $fetch.native = (...args) => fetch(...args);
3633
- $fetch.create = (defaultOptions = {}, customGlobalOptions = {}) => createFetch({
3634
- ...globalOptions,
3635
- ...customGlobalOptions,
3636
- defaults: {
3637
- ...globalOptions.defaults,
3638
- ...customGlobalOptions.defaults,
3639
- ...defaultOptions
3640
- }
3641
- });
3642
- return $fetch;
3643
- }
3644
-
3645
- const _globalThis = (function() {
3646
- if (typeof globalThis !== "undefined") {
3647
- return globalThis;
3648
- }
3649
- if (typeof self !== "undefined") {
3650
- return self;
3651
- }
3652
- if (typeof window !== "undefined") {
3653
- return window;
3654
- }
3655
- if (typeof global !== "undefined") {
3656
- return global;
3657
- }
3658
- throw new Error("unable to locate global object");
3659
- })();
3660
- const fetch = _globalThis.fetch ? (...args) => _globalThis.fetch(...args) : () => Promise.reject(new Error("[ofetch] global.fetch is not supported!"));
3661
- const Headers = _globalThis.Headers;
3662
- const AbortController = _globalThis.AbortController;
3663
- const ofetch = createFetch({ fetch, Headers, AbortController });
3664
-
3665
- class TemplatesClient {
3666
- fetch;
3667
- baseURL;
3668
- language;
3669
- logger = consola.withTag("templates-client");
3670
- constructor(config = {}) {
3671
- this.baseURL = config.baseURL || CLOUD_ENDPOINTS.MAIN.BASE_URL;
3672
- this.language = config.language || "en";
3673
- this.fetch = ofetch.create({
3674
- baseURL: this.baseURL,
3675
- timeout: config.timeout || 1e4,
3676
- headers: {
3677
- "User-Agent": "CCJK/8.2.0"
3678
- },
3679
- retry: 2
3680
- });
3681
- }
3682
- // ==========================================================================
3683
- // Single Template
3684
- // ==========================================================================
3685
- /**
3686
- * Get a single template by ID
3687
- */
3688
- async getTemplate(templateId) {
3689
- try {
3690
- this.logger.debug(`Fetching template: ${templateId}`);
3691
- const response = await this.fetch(
3692
- `/api/v8/templates/${encodeURIComponent(templateId)}`
3693
- );
3694
- if (response.code === 200 && response.data) {
3695
- return response.data;
3696
- }
3697
- return null;
3698
- } catch (error) {
3699
- this.logger.warn(`Failed to fetch template ${templateId}:`, error);
3700
- return null;
3701
- }
3702
- }
3703
- // ==========================================================================
3704
- // Batch Templates
3705
- // ==========================================================================
3706
- /**
3707
- * Batch get templates by IDs
3708
- */
3709
- async getTemplates(ids, language) {
3710
- try {
3711
- this.logger.debug(`Batch fetching ${ids.length} templates`);
3712
- const response = await this.fetch(
3713
- "/api/v8/templates/batch",
3714
- {
3715
- method: "POST",
3716
- body: {
3717
- ids,
3718
- language: language || this.language,
3719
- includeStats: true
3720
- }
3721
- }
3722
- );
3723
- return {
3724
- requestId: response.requestId || "",
3725
- templates: response.templates || {},
3726
- notFound: response.notFound || [],
3727
- stats: response.stats
3728
- };
3729
- } catch (error) {
3730
- this.logger.warn("Failed to batch fetch templates:", error);
3731
- return {
3732
- requestId: "",
3733
- templates: {},
3734
- notFound: ids
3735
- };
3736
- }
3737
- }
3738
- // ==========================================================================
3739
- // Search & List
3740
- // ==========================================================================
3741
- /**
3742
- * Search templates
3743
- */
3744
- async searchTemplates(query, params = {}) {
3745
- try {
3746
- this.logger.debug(`Searching templates: ${query}`);
3747
- const searchParams = this.buildSearchParams({ ...params, query });
3748
- const response = await this.fetch(
3749
- `/api/v8/templates/search?${searchParams}`
3750
- );
3751
- if (response.code === 200 && response.data) {
3752
- return response.data;
3753
- }
3754
- return { items: [], total: 0, limit: 20, offset: 0 };
3755
- } catch (error) {
3756
- this.logger.warn("Failed to search templates:", error);
3757
- return { items: [], total: 0, limit: 20, offset: 0 };
3758
- }
3759
- }
3760
- /**
3761
- * List templates with filters
3762
- */
3763
- async listTemplates(params = {}) {
3764
- try {
3765
- this.logger.debug("Listing templates with params:", params);
3766
- const searchParams = this.buildSearchParams(params);
3767
- const response = await this.fetch(
3768
- `/api/v8/templates?${searchParams}`
3769
- );
3770
- if (response.code === 200 && response.data) {
3771
- return response.data;
3772
- }
3773
- return { items: [], total: 0, limit: 20, offset: 0 };
3774
- } catch (error) {
3775
- this.logger.warn("Failed to list templates:", error);
3776
- return { items: [], total: 0, limit: 20, offset: 0 };
3777
- }
3778
- }
3779
- // ==========================================================================
3780
- // Type-specific Methods
3781
- // ==========================================================================
3782
- /**
3783
- * Get templates by type
3784
- */
3785
- async getTemplatesByType(type, options = {}) {
3786
- const { items } = await this.listTemplates({
3787
- type,
3788
- category: options.category,
3789
- limit: options.limit || 50,
3790
- is_official: options.is_official
3791
- });
3792
- return items;
3793
- }
3794
- /**
3795
- * Get specialist agents
3796
- */
3797
- async getSpecialistAgents(category) {
3798
- return this.getTemplatesByType("agent", { category, limit: 50 });
3799
- }
3800
- /**
3801
- * Get official MCP servers
3802
- */
3803
- async getOfficialMcpServers() {
3804
- return this.getTemplatesByType("mcp", { is_official: true, limit: 50 });
3805
- }
3806
- /**
3807
- * Get skills by category
3808
- */
3809
- async getSkills(category) {
3810
- return this.getTemplatesByType("skill", { category, limit: 50 });
3811
- }
3812
- /**
3813
- * Get hooks by category
3814
- */
3815
- async getHooks(category) {
3816
- return this.getTemplatesByType("hook", { category, limit: 50 });
3817
- }
3818
- // ==========================================================================
3819
- // Featured & Popular
3820
- // ==========================================================================
3821
- /**
3822
- * Get featured templates
3823
- */
3824
- async getFeaturedTemplates(limit = 10) {
3825
- try {
3826
- const response = await this.fetch(
3827
- `/api/v8/templates/featured?limit=${limit}`
3828
- );
3829
- if (response.code === 200 && response.data) {
3830
- return response.data;
3831
- }
3832
- return [];
3833
- } catch (error) {
3834
- this.logger.warn("Failed to fetch featured templates:", error);
3835
- return [];
3836
- }
3837
- }
3838
- /**
3839
- * Get popular templates
3840
- */
3841
- async getPopularTemplates(limit = 20) {
3842
- try {
3843
- const response = await this.fetch(
3844
- `/api/v8/templates/popular?limit=${limit}`
3845
- );
3846
- if (response.code === 200 && response.data) {
3847
- return response.data;
3848
- }
3849
- return [];
3850
- } catch (error) {
3851
- this.logger.warn("Failed to fetch popular templates:", error);
3852
- return [];
3853
- }
3854
- }
3855
- // ==========================================================================
3856
- // Categories
3857
- // ==========================================================================
3858
- /**
3859
- * Get all categories
3860
- */
3861
- async getCategories() {
3862
- try {
3863
- const response = await this.fetch(
3864
- "/api/v8/templates/categories"
3865
- );
3866
- if (response.code === 200 && response.data) {
3867
- return response.data;
3868
- }
3869
- return [];
3870
- } catch (error) {
3871
- this.logger.warn("Failed to fetch categories:", error);
3872
- return [];
3873
- }
3874
- }
3875
- // ==========================================================================
3876
- // Download Tracking
3877
- // ==========================================================================
3878
- /**
3879
- * Track template download
3880
- */
3881
- async trackDownload(templateId) {
3882
- try {
3883
- const response = await this.fetch(
3884
- `/api/v8/templates/${encodeURIComponent(templateId)}/download`,
3885
- { method: "POST" }
3886
- );
3887
- return response.code === 200;
3888
- } catch (error) {
3889
- this.logger.warn(`Failed to track download for ${templateId}:`, error);
3890
- return false;
3891
- }
3892
- }
3893
- // ==========================================================================
3894
- // Helpers
3895
- // ==========================================================================
3896
- /**
3897
- * Build search params string
3898
- */
3899
- buildSearchParams(params) {
3900
- const searchParams = new URLSearchParams();
3901
- if (params.query)
3902
- searchParams.set("query", params.query);
3903
- if (params.type)
3904
- searchParams.set("type", params.type);
3905
- if (params.category)
3906
- searchParams.set("category", params.category);
3907
- if (params.tags?.length)
3908
- searchParams.set("tags", params.tags.join(","));
3909
- if (params.is_official !== void 0)
3910
- searchParams.set("is_official", String(params.is_official));
3911
- if (params.is_featured !== void 0)
3912
- searchParams.set("is_featured", String(params.is_featured));
3913
- if (params.is_verified !== void 0)
3914
- searchParams.set("is_verified", String(params.is_verified));
3915
- if (params.sortBy)
3916
- searchParams.set("sortBy", params.sortBy);
3917
- if (params.order)
3918
- searchParams.set("order", params.order);
3919
- if (params.limit)
3920
- searchParams.set("limit", String(params.limit));
3921
- if (params.offset)
3922
- searchParams.set("offset", String(params.offset));
3923
- return searchParams.toString();
3924
- }
3925
- /**
3926
- * Extract localized name from template
3927
- */
3928
- getLocalizedName(template, lang) {
3929
- const language = lang || this.language;
3930
- return language === "zh-CN" && template.name_zh_cn ? template.name_zh_cn : template.name_en;
3931
- }
3932
- /**
3933
- * Extract localized description from template
3934
- */
3935
- getLocalizedDescription(template, lang) {
3936
- const language = lang || this.language;
3937
- return language === "zh-CN" && template.description_zh_cn ? template.description_zh_cn : template.description_en || "";
3938
- }
3939
- }
3940
- let templatesClientInstance = null;
3941
- function getTemplatesClient(config) {
3942
- if (!templatesClientInstance) {
3943
- templatesClientInstance = new TemplatesClient(config);
3944
- }
3945
- return templatesClientInstance;
3946
- }
3947
- function createTemplatesClient(config) {
3948
- return new TemplatesClient(config);
3949
- }
3950
-
3951
- export { ProjectAnalyzer as P, TemplatesClient as T, analyzeProject as a, createTemplatesClient as b, consola as c, analyzeDependencies$1 as d, detectProject as e, detectProjectType as f, getTemplatesClient as g, batchAnalyze as h, ofetch as o };