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,2973 +0,0 @@
1
- import path__default from 'node:path';
2
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from '../shared/ccjk.BAGoDD49.mjs';
3
- import require$$0$2 from 'fs';
4
- import require$$0 from 'constants';
5
- import require$$0$1 from 'stream';
6
- import require$$4 from 'util';
7
- import require$$5 from 'assert';
8
- import sysPath from 'path';
9
- import { getConfiguredMemoryDirectories, getClaudeProjectsDir } from './memory-paths.mjs';
10
- import '../shared/ccjk.BBtCGd_g.mjs';
11
- import './index3.mjs';
12
- import './constants.mjs';
13
- import 'node:os';
14
- import './index2.mjs';
15
- import 'node:fs';
16
- import 'node:process';
17
- import 'node:url';
18
- import '../shared/ccjk.bQ7Dh1g4.mjs';
19
- import './fs-operations.mjs';
20
- import 'node:crypto';
21
- import 'node:fs/promises';
22
-
23
- var fs$1 = {};
24
-
25
- var universalify = {};
26
-
27
- var hasRequiredUniversalify;
28
-
29
- function requireUniversalify () {
30
- if (hasRequiredUniversalify) return universalify;
31
- hasRequiredUniversalify = 1;
32
-
33
- universalify.fromCallback = function (fn) {
34
- return Object.defineProperty(function (...args) {
35
- if (typeof args[args.length - 1] === 'function') fn.apply(this, args);
36
- else {
37
- return new Promise((resolve, reject) => {
38
- args.push((err, res) => (err != null) ? reject(err) : resolve(res));
39
- fn.apply(this, args);
40
- })
41
- }
42
- }, 'name', { value: fn.name })
43
- };
44
-
45
- universalify.fromPromise = function (fn) {
46
- return Object.defineProperty(function (...args) {
47
- const cb = args[args.length - 1];
48
- if (typeof cb !== 'function') return fn.apply(this, args)
49
- else {
50
- args.pop();
51
- fn.apply(this, args).then(r => cb(null, r), cb);
52
- }
53
- }, 'name', { value: fn.name })
54
- };
55
- return universalify;
56
- }
57
-
58
- var polyfills;
59
- var hasRequiredPolyfills;
60
-
61
- function requirePolyfills () {
62
- if (hasRequiredPolyfills) return polyfills;
63
- hasRequiredPolyfills = 1;
64
- var constants = require$$0;
65
-
66
- var origCwd = process.cwd;
67
- var cwd = null;
68
-
69
- var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
70
-
71
- process.cwd = function() {
72
- if (!cwd)
73
- cwd = origCwd.call(process);
74
- return cwd
75
- };
76
- try {
77
- process.cwd();
78
- } catch (er) {}
79
-
80
- // This check is needed until node.js 12 is required
81
- if (typeof process.chdir === 'function') {
82
- var chdir = process.chdir;
83
- process.chdir = function (d) {
84
- cwd = null;
85
- chdir.call(process, d);
86
- };
87
- if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
88
- }
89
-
90
- polyfills = patch;
91
-
92
- function patch (fs) {
93
- // (re-)implement some things that are known busted or missing.
94
-
95
- // lchmod, broken prior to 0.6.2
96
- // back-port the fix here.
97
- if (constants.hasOwnProperty('O_SYMLINK') &&
98
- process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
99
- patchLchmod(fs);
100
- }
101
-
102
- // lutimes implementation, or no-op
103
- if (!fs.lutimes) {
104
- patchLutimes(fs);
105
- }
106
-
107
- // https://github.com/isaacs/node-graceful-fs/issues/4
108
- // Chown should not fail on einval or eperm if non-root.
109
- // It should not fail on enosys ever, as this just indicates
110
- // that a fs doesn't support the intended operation.
111
-
112
- fs.chown = chownFix(fs.chown);
113
- fs.fchown = chownFix(fs.fchown);
114
- fs.lchown = chownFix(fs.lchown);
115
-
116
- fs.chmod = chmodFix(fs.chmod);
117
- fs.fchmod = chmodFix(fs.fchmod);
118
- fs.lchmod = chmodFix(fs.lchmod);
119
-
120
- fs.chownSync = chownFixSync(fs.chownSync);
121
- fs.fchownSync = chownFixSync(fs.fchownSync);
122
- fs.lchownSync = chownFixSync(fs.lchownSync);
123
-
124
- fs.chmodSync = chmodFixSync(fs.chmodSync);
125
- fs.fchmodSync = chmodFixSync(fs.fchmodSync);
126
- fs.lchmodSync = chmodFixSync(fs.lchmodSync);
127
-
128
- fs.stat = statFix(fs.stat);
129
- fs.fstat = statFix(fs.fstat);
130
- fs.lstat = statFix(fs.lstat);
131
-
132
- fs.statSync = statFixSync(fs.statSync);
133
- fs.fstatSync = statFixSync(fs.fstatSync);
134
- fs.lstatSync = statFixSync(fs.lstatSync);
135
-
136
- // if lchmod/lchown do not exist, then make them no-ops
137
- if (fs.chmod && !fs.lchmod) {
138
- fs.lchmod = function (path, mode, cb) {
139
- if (cb) process.nextTick(cb);
140
- };
141
- fs.lchmodSync = function () {};
142
- }
143
- if (fs.chown && !fs.lchown) {
144
- fs.lchown = function (path, uid, gid, cb) {
145
- if (cb) process.nextTick(cb);
146
- };
147
- fs.lchownSync = function () {};
148
- }
149
-
150
- // on Windows, A/V software can lock the directory, causing this
151
- // to fail with an EACCES or EPERM if the directory contains newly
152
- // created files. Try again on failure, for up to 60 seconds.
153
-
154
- // Set the timeout this long because some Windows Anti-Virus, such as Parity
155
- // bit9, may lock files for up to a minute, causing npm package install
156
- // failures. Also, take care to yield the scheduler. Windows scheduling gives
157
- // CPU to a busy looping process, which can cause the program causing the lock
158
- // contention to be starved of CPU by node, so the contention doesn't resolve.
159
- if (platform === "win32") {
160
- fs.rename = typeof fs.rename !== 'function' ? fs.rename
161
- : (function (fs$rename) {
162
- function rename (from, to, cb) {
163
- var start = Date.now();
164
- var backoff = 0;
165
- fs$rename(from, to, function CB (er) {
166
- if (er
167
- && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
168
- && Date.now() - start < 60000) {
169
- setTimeout(function() {
170
- fs.stat(to, function (stater, st) {
171
- if (stater && stater.code === "ENOENT")
172
- fs$rename(from, to, CB);
173
- else
174
- cb(er);
175
- });
176
- }, backoff);
177
- if (backoff < 100)
178
- backoff += 10;
179
- return;
180
- }
181
- if (cb) cb(er);
182
- });
183
- }
184
- if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
185
- return rename
186
- })(fs.rename);
187
- }
188
-
189
- // if read() returns EAGAIN, then just try it again.
190
- fs.read = typeof fs.read !== 'function' ? fs.read
191
- : (function (fs$read) {
192
- function read (fd, buffer, offset, length, position, callback_) {
193
- var callback;
194
- if (callback_ && typeof callback_ === 'function') {
195
- var eagCounter = 0;
196
- callback = function (er, _, __) {
197
- if (er && er.code === 'EAGAIN' && eagCounter < 10) {
198
- eagCounter ++;
199
- return fs$read.call(fs, fd, buffer, offset, length, position, callback)
200
- }
201
- callback_.apply(this, arguments);
202
- };
203
- }
204
- return fs$read.call(fs, fd, buffer, offset, length, position, callback)
205
- }
206
-
207
- // This ensures `util.promisify` works as it does for native `fs.read`.
208
- if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
209
- return read
210
- })(fs.read);
211
-
212
- fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
213
- : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
214
- var eagCounter = 0;
215
- while (true) {
216
- try {
217
- return fs$readSync.call(fs, fd, buffer, offset, length, position)
218
- } catch (er) {
219
- if (er.code === 'EAGAIN' && eagCounter < 10) {
220
- eagCounter ++;
221
- continue
222
- }
223
- throw er
224
- }
225
- }
226
- }})(fs.readSync);
227
-
228
- function patchLchmod (fs) {
229
- fs.lchmod = function (path, mode, callback) {
230
- fs.open( path
231
- , constants.O_WRONLY | constants.O_SYMLINK
232
- , mode
233
- , function (err, fd) {
234
- if (err) {
235
- if (callback) callback(err);
236
- return
237
- }
238
- // prefer to return the chmod error, if one occurs,
239
- // but still try to close, and report closing errors if they occur.
240
- fs.fchmod(fd, mode, function (err) {
241
- fs.close(fd, function(err2) {
242
- if (callback) callback(err || err2);
243
- });
244
- });
245
- });
246
- };
247
-
248
- fs.lchmodSync = function (path, mode) {
249
- var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
250
-
251
- // prefer to return the chmod error, if one occurs,
252
- // but still try to close, and report closing errors if they occur.
253
- var threw = true;
254
- var ret;
255
- try {
256
- ret = fs.fchmodSync(fd, mode);
257
- threw = false;
258
- } finally {
259
- if (threw) {
260
- try {
261
- fs.closeSync(fd);
262
- } catch (er) {}
263
- } else {
264
- fs.closeSync(fd);
265
- }
266
- }
267
- return ret
268
- };
269
- }
270
-
271
- function patchLutimes (fs) {
272
- if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
273
- fs.lutimes = function (path, at, mt, cb) {
274
- fs.open(path, constants.O_SYMLINK, function (er, fd) {
275
- if (er) {
276
- if (cb) cb(er);
277
- return
278
- }
279
- fs.futimes(fd, at, mt, function (er) {
280
- fs.close(fd, function (er2) {
281
- if (cb) cb(er || er2);
282
- });
283
- });
284
- });
285
- };
286
-
287
- fs.lutimesSync = function (path, at, mt) {
288
- var fd = fs.openSync(path, constants.O_SYMLINK);
289
- var ret;
290
- var threw = true;
291
- try {
292
- ret = fs.futimesSync(fd, at, mt);
293
- threw = false;
294
- } finally {
295
- if (threw) {
296
- try {
297
- fs.closeSync(fd);
298
- } catch (er) {}
299
- } else {
300
- fs.closeSync(fd);
301
- }
302
- }
303
- return ret
304
- };
305
-
306
- } else if (fs.futimes) {
307
- fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb); };
308
- fs.lutimesSync = function () {};
309
- }
310
- }
311
-
312
- function chmodFix (orig) {
313
- if (!orig) return orig
314
- return function (target, mode, cb) {
315
- return orig.call(fs, target, mode, function (er) {
316
- if (chownErOk(er)) er = null;
317
- if (cb) cb.apply(this, arguments);
318
- })
319
- }
320
- }
321
-
322
- function chmodFixSync (orig) {
323
- if (!orig) return orig
324
- return function (target, mode) {
325
- try {
326
- return orig.call(fs, target, mode)
327
- } catch (er) {
328
- if (!chownErOk(er)) throw er
329
- }
330
- }
331
- }
332
-
333
-
334
- function chownFix (orig) {
335
- if (!orig) return orig
336
- return function (target, uid, gid, cb) {
337
- return orig.call(fs, target, uid, gid, function (er) {
338
- if (chownErOk(er)) er = null;
339
- if (cb) cb.apply(this, arguments);
340
- })
341
- }
342
- }
343
-
344
- function chownFixSync (orig) {
345
- if (!orig) return orig
346
- return function (target, uid, gid) {
347
- try {
348
- return orig.call(fs, target, uid, gid)
349
- } catch (er) {
350
- if (!chownErOk(er)) throw er
351
- }
352
- }
353
- }
354
-
355
- function statFix (orig) {
356
- if (!orig) return orig
357
- // Older versions of Node erroneously returned signed integers for
358
- // uid + gid.
359
- return function (target, options, cb) {
360
- if (typeof options === 'function') {
361
- cb = options;
362
- options = null;
363
- }
364
- function callback (er, stats) {
365
- if (stats) {
366
- if (stats.uid < 0) stats.uid += 0x100000000;
367
- if (stats.gid < 0) stats.gid += 0x100000000;
368
- }
369
- if (cb) cb.apply(this, arguments);
370
- }
371
- return options ? orig.call(fs, target, options, callback)
372
- : orig.call(fs, target, callback)
373
- }
374
- }
375
-
376
- function statFixSync (orig) {
377
- if (!orig) return orig
378
- // Older versions of Node erroneously returned signed integers for
379
- // uid + gid.
380
- return function (target, options) {
381
- var stats = options ? orig.call(fs, target, options)
382
- : orig.call(fs, target);
383
- if (stats) {
384
- if (stats.uid < 0) stats.uid += 0x100000000;
385
- if (stats.gid < 0) stats.gid += 0x100000000;
386
- }
387
- return stats;
388
- }
389
- }
390
-
391
- // ENOSYS means that the fs doesn't support the op. Just ignore
392
- // that, because it doesn't matter.
393
- //
394
- // if there's no getuid, or if getuid() is something other
395
- // than 0, and the error is EINVAL or EPERM, then just ignore
396
- // it.
397
- //
398
- // This specific case is a silent failure in cp, install, tar,
399
- // and most other unix tools that manage permissions.
400
- //
401
- // When running as root, or if other types of errors are
402
- // encountered, then it's strict.
403
- function chownErOk (er) {
404
- if (!er)
405
- return true
406
-
407
- if (er.code === "ENOSYS")
408
- return true
409
-
410
- var nonroot = !process.getuid || process.getuid() !== 0;
411
- if (nonroot) {
412
- if (er.code === "EINVAL" || er.code === "EPERM")
413
- return true
414
- }
415
-
416
- return false
417
- }
418
- }
419
- return polyfills;
420
- }
421
-
422
- var legacyStreams;
423
- var hasRequiredLegacyStreams;
424
-
425
- function requireLegacyStreams () {
426
- if (hasRequiredLegacyStreams) return legacyStreams;
427
- hasRequiredLegacyStreams = 1;
428
- var Stream = require$$0$1.Stream;
429
-
430
- legacyStreams = legacy;
431
-
432
- function legacy (fs) {
433
- return {
434
- ReadStream: ReadStream,
435
- WriteStream: WriteStream
436
- }
437
-
438
- function ReadStream (path, options) {
439
- if (!(this instanceof ReadStream)) return new ReadStream(path, options);
440
-
441
- Stream.call(this);
442
-
443
- var self = this;
444
-
445
- this.path = path;
446
- this.fd = null;
447
- this.readable = true;
448
- this.paused = false;
449
-
450
- this.flags = 'r';
451
- this.mode = 438; /*=0666*/
452
- this.bufferSize = 64 * 1024;
453
-
454
- options = options || {};
455
-
456
- // Mixin options into this
457
- var keys = Object.keys(options);
458
- for (var index = 0, length = keys.length; index < length; index++) {
459
- var key = keys[index];
460
- this[key] = options[key];
461
- }
462
-
463
- if (this.encoding) this.setEncoding(this.encoding);
464
-
465
- if (this.start !== undefined) {
466
- if ('number' !== typeof this.start) {
467
- throw TypeError('start must be a Number');
468
- }
469
- if (this.end === undefined) {
470
- this.end = Infinity;
471
- } else if ('number' !== typeof this.end) {
472
- throw TypeError('end must be a Number');
473
- }
474
-
475
- if (this.start > this.end) {
476
- throw new Error('start must be <= end');
477
- }
478
-
479
- this.pos = this.start;
480
- }
481
-
482
- if (this.fd !== null) {
483
- process.nextTick(function() {
484
- self._read();
485
- });
486
- return;
487
- }
488
-
489
- fs.open(this.path, this.flags, this.mode, function (err, fd) {
490
- if (err) {
491
- self.emit('error', err);
492
- self.readable = false;
493
- return;
494
- }
495
-
496
- self.fd = fd;
497
- self.emit('open', fd);
498
- self._read();
499
- });
500
- }
501
-
502
- function WriteStream (path, options) {
503
- if (!(this instanceof WriteStream)) return new WriteStream(path, options);
504
-
505
- Stream.call(this);
506
-
507
- this.path = path;
508
- this.fd = null;
509
- this.writable = true;
510
-
511
- this.flags = 'w';
512
- this.encoding = 'binary';
513
- this.mode = 438; /*=0666*/
514
- this.bytesWritten = 0;
515
-
516
- options = options || {};
517
-
518
- // Mixin options into this
519
- var keys = Object.keys(options);
520
- for (var index = 0, length = keys.length; index < length; index++) {
521
- var key = keys[index];
522
- this[key] = options[key];
523
- }
524
-
525
- if (this.start !== undefined) {
526
- if ('number' !== typeof this.start) {
527
- throw TypeError('start must be a Number');
528
- }
529
- if (this.start < 0) {
530
- throw new Error('start must be >= zero');
531
- }
532
-
533
- this.pos = this.start;
534
- }
535
-
536
- this.busy = false;
537
- this._queue = [];
538
-
539
- if (this.fd === null) {
540
- this._open = fs.open;
541
- this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
542
- this.flush();
543
- }
544
- }
545
- }
546
- return legacyStreams;
547
- }
548
-
549
- var clone_1;
550
- var hasRequiredClone;
551
-
552
- function requireClone () {
553
- if (hasRequiredClone) return clone_1;
554
- hasRequiredClone = 1;
555
-
556
- clone_1 = clone;
557
-
558
- var getPrototypeOf = Object.getPrototypeOf || function (obj) {
559
- return obj.__proto__
560
- };
561
-
562
- function clone (obj) {
563
- if (obj === null || typeof obj !== 'object')
564
- return obj
565
-
566
- if (obj instanceof Object)
567
- var copy = { __proto__: getPrototypeOf(obj) };
568
- else
569
- var copy = Object.create(null);
570
-
571
- Object.getOwnPropertyNames(obj).forEach(function (key) {
572
- Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
573
- });
574
-
575
- return copy
576
- }
577
- return clone_1;
578
- }
579
-
580
- var gracefulFs;
581
- var hasRequiredGracefulFs;
582
-
583
- function requireGracefulFs () {
584
- if (hasRequiredGracefulFs) return gracefulFs;
585
- hasRequiredGracefulFs = 1;
586
- var fs = require$$0$2;
587
- var polyfills = requirePolyfills();
588
- var legacy = requireLegacyStreams();
589
- var clone = requireClone();
590
-
591
- var util = require$$4;
592
-
593
- /* istanbul ignore next - node 0.x polyfill */
594
- var gracefulQueue;
595
- var previousSymbol;
596
-
597
- /* istanbul ignore else - node 0.x polyfill */
598
- if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
599
- gracefulQueue = Symbol.for('graceful-fs.queue');
600
- // This is used in testing by future versions
601
- previousSymbol = Symbol.for('graceful-fs.previous');
602
- } else {
603
- gracefulQueue = '___graceful-fs.queue';
604
- previousSymbol = '___graceful-fs.previous';
605
- }
606
-
607
- function noop () {}
608
-
609
- function publishQueue(context, queue) {
610
- Object.defineProperty(context, gracefulQueue, {
611
- get: function() {
612
- return queue
613
- }
614
- });
615
- }
616
-
617
- var debug = noop;
618
- if (util.debuglog)
619
- debug = util.debuglog('gfs4');
620
- else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
621
- debug = function() {
622
- var m = util.format.apply(util, arguments);
623
- m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ');
624
- console.error(m);
625
- };
626
-
627
- // Once time initialization
628
- if (!fs[gracefulQueue]) {
629
- // This queue can be shared by multiple loaded instances
630
- var queue = commonjsGlobal[gracefulQueue] || [];
631
- publishQueue(fs, queue);
632
-
633
- // Patch fs.close/closeSync to shared queue version, because we need
634
- // to retry() whenever a close happens *anywhere* in the program.
635
- // This is essential when multiple graceful-fs instances are
636
- // in play at the same time.
637
- fs.close = (function (fs$close) {
638
- function close (fd, cb) {
639
- return fs$close.call(fs, fd, function (err) {
640
- // This function uses the graceful-fs shared queue
641
- if (!err) {
642
- resetQueue();
643
- }
644
-
645
- if (typeof cb === 'function')
646
- cb.apply(this, arguments);
647
- })
648
- }
649
-
650
- Object.defineProperty(close, previousSymbol, {
651
- value: fs$close
652
- });
653
- return close
654
- })(fs.close);
655
-
656
- fs.closeSync = (function (fs$closeSync) {
657
- function closeSync (fd) {
658
- // This function uses the graceful-fs shared queue
659
- fs$closeSync.apply(fs, arguments);
660
- resetQueue();
661
- }
662
-
663
- Object.defineProperty(closeSync, previousSymbol, {
664
- value: fs$closeSync
665
- });
666
- return closeSync
667
- })(fs.closeSync);
668
-
669
- if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
670
- process.on('exit', function() {
671
- debug(fs[gracefulQueue]);
672
- require$$5.equal(fs[gracefulQueue].length, 0);
673
- });
674
- }
675
- }
676
-
677
- if (!commonjsGlobal[gracefulQueue]) {
678
- publishQueue(commonjsGlobal, fs[gracefulQueue]);
679
- }
680
-
681
- gracefulFs = patch(clone(fs));
682
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
683
- gracefulFs = patch(fs);
684
- fs.__patched = true;
685
- }
686
-
687
- function patch (fs) {
688
- // Everything that references the open() function needs to be in here
689
- polyfills(fs);
690
- fs.gracefulify = patch;
691
-
692
- fs.createReadStream = createReadStream;
693
- fs.createWriteStream = createWriteStream;
694
- var fs$readFile = fs.readFile;
695
- fs.readFile = readFile;
696
- function readFile (path, options, cb) {
697
- if (typeof options === 'function')
698
- cb = options, options = null;
699
-
700
- return go$readFile(path, options, cb)
701
-
702
- function go$readFile (path, options, cb, startTime) {
703
- return fs$readFile(path, options, function (err) {
704
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
705
- enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()]);
706
- else {
707
- if (typeof cb === 'function')
708
- cb.apply(this, arguments);
709
- }
710
- })
711
- }
712
- }
713
-
714
- var fs$writeFile = fs.writeFile;
715
- fs.writeFile = writeFile;
716
- function writeFile (path, data, options, cb) {
717
- if (typeof options === 'function')
718
- cb = options, options = null;
719
-
720
- return go$writeFile(path, data, options, cb)
721
-
722
- function go$writeFile (path, data, options, cb, startTime) {
723
- return fs$writeFile(path, data, options, function (err) {
724
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
725
- enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
726
- else {
727
- if (typeof cb === 'function')
728
- cb.apply(this, arguments);
729
- }
730
- })
731
- }
732
- }
733
-
734
- var fs$appendFile = fs.appendFile;
735
- if (fs$appendFile)
736
- fs.appendFile = appendFile;
737
- function appendFile (path, data, options, cb) {
738
- if (typeof options === 'function')
739
- cb = options, options = null;
740
-
741
- return go$appendFile(path, data, options, cb)
742
-
743
- function go$appendFile (path, data, options, cb, startTime) {
744
- return fs$appendFile(path, data, options, function (err) {
745
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
746
- enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
747
- else {
748
- if (typeof cb === 'function')
749
- cb.apply(this, arguments);
750
- }
751
- })
752
- }
753
- }
754
-
755
- var fs$copyFile = fs.copyFile;
756
- if (fs$copyFile)
757
- fs.copyFile = copyFile;
758
- function copyFile (src, dest, flags, cb) {
759
- if (typeof flags === 'function') {
760
- cb = flags;
761
- flags = 0;
762
- }
763
- return go$copyFile(src, dest, flags, cb)
764
-
765
- function go$copyFile (src, dest, flags, cb, startTime) {
766
- return fs$copyFile(src, dest, flags, function (err) {
767
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
768
- enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()]);
769
- else {
770
- if (typeof cb === 'function')
771
- cb.apply(this, arguments);
772
- }
773
- })
774
- }
775
- }
776
-
777
- var fs$readdir = fs.readdir;
778
- fs.readdir = readdir;
779
- var noReaddirOptionVersions = /^v[0-5]\./;
780
- function readdir (path, options, cb) {
781
- if (typeof options === 'function')
782
- cb = options, options = null;
783
-
784
- var go$readdir = noReaddirOptionVersions.test(process.version)
785
- ? function go$readdir (path, options, cb, startTime) {
786
- return fs$readdir(path, fs$readdirCallback(
787
- path, options, cb, startTime
788
- ))
789
- }
790
- : function go$readdir (path, options, cb, startTime) {
791
- return fs$readdir(path, options, fs$readdirCallback(
792
- path, options, cb, startTime
793
- ))
794
- };
795
-
796
- return go$readdir(path, options, cb)
797
-
798
- function fs$readdirCallback (path, options, cb, startTime) {
799
- return function (err, files) {
800
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
801
- enqueue([
802
- go$readdir,
803
- [path, options, cb],
804
- err,
805
- startTime || Date.now(),
806
- Date.now()
807
- ]);
808
- else {
809
- if (files && files.sort)
810
- files.sort();
811
-
812
- if (typeof cb === 'function')
813
- cb.call(this, err, files);
814
- }
815
- }
816
- }
817
- }
818
-
819
- if (process.version.substr(0, 4) === 'v0.8') {
820
- var legStreams = legacy(fs);
821
- ReadStream = legStreams.ReadStream;
822
- WriteStream = legStreams.WriteStream;
823
- }
824
-
825
- var fs$ReadStream = fs.ReadStream;
826
- if (fs$ReadStream) {
827
- ReadStream.prototype = Object.create(fs$ReadStream.prototype);
828
- ReadStream.prototype.open = ReadStream$open;
829
- }
830
-
831
- var fs$WriteStream = fs.WriteStream;
832
- if (fs$WriteStream) {
833
- WriteStream.prototype = Object.create(fs$WriteStream.prototype);
834
- WriteStream.prototype.open = WriteStream$open;
835
- }
836
-
837
- Object.defineProperty(fs, 'ReadStream', {
838
- get: function () {
839
- return ReadStream
840
- },
841
- set: function (val) {
842
- ReadStream = val;
843
- },
844
- enumerable: true,
845
- configurable: true
846
- });
847
- Object.defineProperty(fs, 'WriteStream', {
848
- get: function () {
849
- return WriteStream
850
- },
851
- set: function (val) {
852
- WriteStream = val;
853
- },
854
- enumerable: true,
855
- configurable: true
856
- });
857
-
858
- // legacy names
859
- var FileReadStream = ReadStream;
860
- Object.defineProperty(fs, 'FileReadStream', {
861
- get: function () {
862
- return FileReadStream
863
- },
864
- set: function (val) {
865
- FileReadStream = val;
866
- },
867
- enumerable: true,
868
- configurable: true
869
- });
870
- var FileWriteStream = WriteStream;
871
- Object.defineProperty(fs, 'FileWriteStream', {
872
- get: function () {
873
- return FileWriteStream
874
- },
875
- set: function (val) {
876
- FileWriteStream = val;
877
- },
878
- enumerable: true,
879
- configurable: true
880
- });
881
-
882
- function ReadStream (path, options) {
883
- if (this instanceof ReadStream)
884
- return fs$ReadStream.apply(this, arguments), this
885
- else
886
- return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
887
- }
888
-
889
- function ReadStream$open () {
890
- var that = this;
891
- open(that.path, that.flags, that.mode, function (err, fd) {
892
- if (err) {
893
- if (that.autoClose)
894
- that.destroy();
895
-
896
- that.emit('error', err);
897
- } else {
898
- that.fd = fd;
899
- that.emit('open', fd);
900
- that.read();
901
- }
902
- });
903
- }
904
-
905
- function WriteStream (path, options) {
906
- if (this instanceof WriteStream)
907
- return fs$WriteStream.apply(this, arguments), this
908
- else
909
- return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
910
- }
911
-
912
- function WriteStream$open () {
913
- var that = this;
914
- open(that.path, that.flags, that.mode, function (err, fd) {
915
- if (err) {
916
- that.destroy();
917
- that.emit('error', err);
918
- } else {
919
- that.fd = fd;
920
- that.emit('open', fd);
921
- }
922
- });
923
- }
924
-
925
- function createReadStream (path, options) {
926
- return new fs.ReadStream(path, options)
927
- }
928
-
929
- function createWriteStream (path, options) {
930
- return new fs.WriteStream(path, options)
931
- }
932
-
933
- var fs$open = fs.open;
934
- fs.open = open;
935
- function open (path, flags, mode, cb) {
936
- if (typeof mode === 'function')
937
- cb = mode, mode = null;
938
-
939
- return go$open(path, flags, mode, cb)
940
-
941
- function go$open (path, flags, mode, cb, startTime) {
942
- return fs$open(path, flags, mode, function (err, fd) {
943
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
944
- enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()]);
945
- else {
946
- if (typeof cb === 'function')
947
- cb.apply(this, arguments);
948
- }
949
- })
950
- }
951
- }
952
-
953
- return fs
954
- }
955
-
956
- function enqueue (elem) {
957
- debug('ENQUEUE', elem[0].name, elem[1]);
958
- fs[gracefulQueue].push(elem);
959
- retry();
960
- }
961
-
962
- // keep track of the timeout between retry() calls
963
- var retryTimer;
964
-
965
- // reset the startTime and lastTime to now
966
- // this resets the start of the 60 second overall timeout as well as the
967
- // delay between attempts so that we'll retry these jobs sooner
968
- function resetQueue () {
969
- var now = Date.now();
970
- for (var i = 0; i < fs[gracefulQueue].length; ++i) {
971
- // entries that are only a length of 2 are from an older version, don't
972
- // bother modifying those since they'll be retried anyway.
973
- if (fs[gracefulQueue][i].length > 2) {
974
- fs[gracefulQueue][i][3] = now; // startTime
975
- fs[gracefulQueue][i][4] = now; // lastTime
976
- }
977
- }
978
- // call retry to make sure we're actively processing the queue
979
- retry();
980
- }
981
-
982
- function retry () {
983
- // clear the timer and remove it to help prevent unintended concurrency
984
- clearTimeout(retryTimer);
985
- retryTimer = undefined;
986
-
987
- if (fs[gracefulQueue].length === 0)
988
- return
989
-
990
- var elem = fs[gracefulQueue].shift();
991
- var fn = elem[0];
992
- var args = elem[1];
993
- // these items may be unset if they were added by an older graceful-fs
994
- var err = elem[2];
995
- var startTime = elem[3];
996
- var lastTime = elem[4];
997
-
998
- // if we don't have a startTime we have no way of knowing if we've waited
999
- // long enough, so go ahead and retry this item now
1000
- if (startTime === undefined) {
1001
- debug('RETRY', fn.name, args);
1002
- fn.apply(null, args);
1003
- } else if (Date.now() - startTime >= 60000) {
1004
- // it's been more than 60 seconds total, bail now
1005
- debug('TIMEOUT', fn.name, args);
1006
- var cb = args.pop();
1007
- if (typeof cb === 'function')
1008
- cb.call(null, err);
1009
- } else {
1010
- // the amount of time between the last attempt and right now
1011
- var sinceAttempt = Date.now() - lastTime;
1012
- // the amount of time between when we first tried, and when we last tried
1013
- // rounded up to at least 1
1014
- var sinceStart = Math.max(lastTime - startTime, 1);
1015
- // backoff. wait longer than the total time we've been retrying, but only
1016
- // up to a maximum of 100ms
1017
- var desiredDelay = Math.min(sinceStart * 1.2, 100);
1018
- // it's been long enough since the last retry, do it again
1019
- if (sinceAttempt >= desiredDelay) {
1020
- debug('RETRY', fn.name, args);
1021
- fn.apply(null, args.concat([startTime]));
1022
- } else {
1023
- // if we can't do this job yet, push it to the end of the queue
1024
- // and let the next iteration check again
1025
- fs[gracefulQueue].push(elem);
1026
- }
1027
- }
1028
-
1029
- // schedule our next run if one isn't already scheduled
1030
- if (retryTimer === undefined) {
1031
- retryTimer = setTimeout(retry, 0);
1032
- }
1033
- }
1034
- return gracefulFs;
1035
- }
1036
-
1037
- var hasRequiredFs;
1038
-
1039
- function requireFs () {
1040
- if (hasRequiredFs) return fs$1;
1041
- hasRequiredFs = 1;
1042
- (function (exports) {
1043
- // This is adapted from https://github.com/normalize/mz
1044
- // Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
1045
- const u = requireUniversalify().fromCallback;
1046
- const fs = requireGracefulFs();
1047
-
1048
- const api = [
1049
- 'access',
1050
- 'appendFile',
1051
- 'chmod',
1052
- 'chown',
1053
- 'close',
1054
- 'copyFile',
1055
- 'cp',
1056
- 'fchmod',
1057
- 'fchown',
1058
- 'fdatasync',
1059
- 'fstat',
1060
- 'fsync',
1061
- 'ftruncate',
1062
- 'futimes',
1063
- 'glob',
1064
- 'lchmod',
1065
- 'lchown',
1066
- 'lutimes',
1067
- 'link',
1068
- 'lstat',
1069
- 'mkdir',
1070
- 'mkdtemp',
1071
- 'open',
1072
- 'opendir',
1073
- 'readdir',
1074
- 'readFile',
1075
- 'readlink',
1076
- 'realpath',
1077
- 'rename',
1078
- 'rm',
1079
- 'rmdir',
1080
- 'stat',
1081
- 'statfs',
1082
- 'symlink',
1083
- 'truncate',
1084
- 'unlink',
1085
- 'utimes',
1086
- 'writeFile'
1087
- ].filter(key => {
1088
- // Some commands are not available on some systems. Ex:
1089
- // fs.cp was added in Node.js v16.7.0
1090
- // fs.statfs was added in Node v19.6.0, v18.15.0
1091
- // fs.glob was added in Node.js v22.0.0
1092
- // fs.lchown is not available on at least some Linux
1093
- return typeof fs[key] === 'function'
1094
- });
1095
-
1096
- // Export cloned fs:
1097
- Object.assign(exports, fs);
1098
-
1099
- // Universalify async methods:
1100
- api.forEach(method => {
1101
- exports[method] = u(fs[method]);
1102
- });
1103
-
1104
- // We differ from mz/fs in that we still ship the old, broken, fs.exists()
1105
- // since we are a drop-in replacement for the native module
1106
- exports.exists = function (filename, callback) {
1107
- if (typeof callback === 'function') {
1108
- return fs.exists(filename, callback)
1109
- }
1110
- return new Promise(resolve => {
1111
- return fs.exists(filename, resolve)
1112
- })
1113
- };
1114
-
1115
- // fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
1116
-
1117
- exports.read = function (fd, buffer, offset, length, position, callback) {
1118
- if (typeof callback === 'function') {
1119
- return fs.read(fd, buffer, offset, length, position, callback)
1120
- }
1121
- return new Promise((resolve, reject) => {
1122
- fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
1123
- if (err) return reject(err)
1124
- resolve({ bytesRead, buffer });
1125
- });
1126
- })
1127
- };
1128
-
1129
- // Function signature can be
1130
- // fs.write(fd, buffer[, offset[, length[, position]]], callback)
1131
- // OR
1132
- // fs.write(fd, string[, position[, encoding]], callback)
1133
- // We need to handle both cases, so we use ...args
1134
- exports.write = function (fd, buffer, ...args) {
1135
- if (typeof args[args.length - 1] === 'function') {
1136
- return fs.write(fd, buffer, ...args)
1137
- }
1138
-
1139
- return new Promise((resolve, reject) => {
1140
- fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
1141
- if (err) return reject(err)
1142
- resolve({ bytesWritten, buffer });
1143
- });
1144
- })
1145
- };
1146
-
1147
- // Function signature is
1148
- // s.readv(fd, buffers[, position], callback)
1149
- // We need to handle the optional arg, so we use ...args
1150
- exports.readv = function (fd, buffers, ...args) {
1151
- if (typeof args[args.length - 1] === 'function') {
1152
- return fs.readv(fd, buffers, ...args)
1153
- }
1154
-
1155
- return new Promise((resolve, reject) => {
1156
- fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
1157
- if (err) return reject(err)
1158
- resolve({ bytesRead, buffers });
1159
- });
1160
- })
1161
- };
1162
-
1163
- // Function signature is
1164
- // s.writev(fd, buffers[, position], callback)
1165
- // We need to handle the optional arg, so we use ...args
1166
- exports.writev = function (fd, buffers, ...args) {
1167
- if (typeof args[args.length - 1] === 'function') {
1168
- return fs.writev(fd, buffers, ...args)
1169
- }
1170
-
1171
- return new Promise((resolve, reject) => {
1172
- fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
1173
- if (err) return reject(err)
1174
- resolve({ bytesWritten, buffers });
1175
- });
1176
- })
1177
- };
1178
-
1179
- // fs.realpath.native sometimes not available if fs is monkey-patched
1180
- if (typeof fs.realpath.native === 'function') {
1181
- exports.realpath.native = u(fs.realpath.native);
1182
- } else {
1183
- process.emitWarning(
1184
- 'fs.realpath.native is not a function. Is fs being monkey-patched?',
1185
- 'Warning', 'fs-extra-WARN0003'
1186
- );
1187
- }
1188
- } (fs$1));
1189
- return fs$1;
1190
- }
1191
-
1192
- var makeDir = {};
1193
-
1194
- var utils$1 = {};
1195
-
1196
- var hasRequiredUtils$1;
1197
-
1198
- function requireUtils$1 () {
1199
- if (hasRequiredUtils$1) return utils$1;
1200
- hasRequiredUtils$1 = 1;
1201
- const path = sysPath;
1202
-
1203
- // https://github.com/nodejs/node/issues/8987
1204
- // https://github.com/libuv/libuv/pull/1088
1205
- utils$1.checkPath = function checkPath (pth) {
1206
- if (process.platform === 'win32') {
1207
- const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
1208
-
1209
- if (pathHasInvalidWinCharacters) {
1210
- const error = new Error(`Path contains invalid characters: ${pth}`);
1211
- error.code = 'EINVAL';
1212
- throw error
1213
- }
1214
- }
1215
- };
1216
- return utils$1;
1217
- }
1218
-
1219
- var hasRequiredMakeDir;
1220
-
1221
- function requireMakeDir () {
1222
- if (hasRequiredMakeDir) return makeDir;
1223
- hasRequiredMakeDir = 1;
1224
- const fs = /*@__PURE__*/ requireFs();
1225
- const { checkPath } = /*@__PURE__*/ requireUtils$1();
1226
-
1227
- const getMode = options => {
1228
- const defaults = { mode: 0o777 };
1229
- if (typeof options === 'number') return options
1230
- return ({ ...defaults, ...options }).mode
1231
- };
1232
-
1233
- makeDir.makeDir = async (dir, options) => {
1234
- checkPath(dir);
1235
-
1236
- return fs.mkdir(dir, {
1237
- mode: getMode(options),
1238
- recursive: true
1239
- })
1240
- };
1241
-
1242
- makeDir.makeDirSync = (dir, options) => {
1243
- checkPath(dir);
1244
-
1245
- return fs.mkdirSync(dir, {
1246
- mode: getMode(options),
1247
- recursive: true
1248
- })
1249
- };
1250
- return makeDir;
1251
- }
1252
-
1253
- var mkdirs;
1254
- var hasRequiredMkdirs;
1255
-
1256
- function requireMkdirs () {
1257
- if (hasRequiredMkdirs) return mkdirs;
1258
- hasRequiredMkdirs = 1;
1259
- const u = requireUniversalify().fromPromise;
1260
- const { makeDir: _makeDir, makeDirSync } = /*@__PURE__*/ requireMakeDir();
1261
- const makeDir = u(_makeDir);
1262
-
1263
- mkdirs = {
1264
- mkdirs: makeDir,
1265
- mkdirsSync: makeDirSync,
1266
- // alias
1267
- mkdirp: makeDir,
1268
- mkdirpSync: makeDirSync,
1269
- ensureDir: makeDir,
1270
- ensureDirSync: makeDirSync
1271
- };
1272
- return mkdirs;
1273
- }
1274
-
1275
- var pathExists_1;
1276
- var hasRequiredPathExists;
1277
-
1278
- function requirePathExists () {
1279
- if (hasRequiredPathExists) return pathExists_1;
1280
- hasRequiredPathExists = 1;
1281
- const u = requireUniversalify().fromPromise;
1282
- const fs = /*@__PURE__*/ requireFs();
1283
-
1284
- function pathExists (path) {
1285
- return fs.access(path).then(() => true).catch(() => false)
1286
- }
1287
-
1288
- pathExists_1 = {
1289
- pathExists: u(pathExists),
1290
- pathExistsSync: fs.existsSync
1291
- };
1292
- return pathExists_1;
1293
- }
1294
-
1295
- var utimes;
1296
- var hasRequiredUtimes;
1297
-
1298
- function requireUtimes () {
1299
- if (hasRequiredUtimes) return utimes;
1300
- hasRequiredUtimes = 1;
1301
-
1302
- const fs = /*@__PURE__*/ requireFs();
1303
- const u = requireUniversalify().fromPromise;
1304
-
1305
- async function utimesMillis (path, atime, mtime) {
1306
- // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
1307
- const fd = await fs.open(path, 'r+');
1308
-
1309
- let closeErr = null;
1310
-
1311
- try {
1312
- await fs.futimes(fd, atime, mtime);
1313
- } finally {
1314
- try {
1315
- await fs.close(fd);
1316
- } catch (e) {
1317
- closeErr = e;
1318
- }
1319
- }
1320
-
1321
- if (closeErr) {
1322
- throw closeErr
1323
- }
1324
- }
1325
-
1326
- function utimesMillisSync (path, atime, mtime) {
1327
- const fd = fs.openSync(path, 'r+');
1328
- fs.futimesSync(fd, atime, mtime);
1329
- return fs.closeSync(fd)
1330
- }
1331
-
1332
- utimes = {
1333
- utimesMillis: u(utimesMillis),
1334
- utimesMillisSync
1335
- };
1336
- return utimes;
1337
- }
1338
-
1339
- var stat;
1340
- var hasRequiredStat;
1341
-
1342
- function requireStat () {
1343
- if (hasRequiredStat) return stat;
1344
- hasRequiredStat = 1;
1345
-
1346
- const fs = /*@__PURE__*/ requireFs();
1347
- const path = sysPath;
1348
- const u = requireUniversalify().fromPromise;
1349
-
1350
- function getStats (src, dest, opts) {
1351
- const statFunc = opts.dereference
1352
- ? (file) => fs.stat(file, { bigint: true })
1353
- : (file) => fs.lstat(file, { bigint: true });
1354
- return Promise.all([
1355
- statFunc(src),
1356
- statFunc(dest).catch(err => {
1357
- if (err.code === 'ENOENT') return null
1358
- throw err
1359
- })
1360
- ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
1361
- }
1362
-
1363
- function getStatsSync (src, dest, opts) {
1364
- let destStat;
1365
- const statFunc = opts.dereference
1366
- ? (file) => fs.statSync(file, { bigint: true })
1367
- : (file) => fs.lstatSync(file, { bigint: true });
1368
- const srcStat = statFunc(src);
1369
- try {
1370
- destStat = statFunc(dest);
1371
- } catch (err) {
1372
- if (err.code === 'ENOENT') return { srcStat, destStat: null }
1373
- throw err
1374
- }
1375
- return { srcStat, destStat }
1376
- }
1377
-
1378
- async function checkPaths (src, dest, funcName, opts) {
1379
- const { srcStat, destStat } = await getStats(src, dest, opts);
1380
- if (destStat) {
1381
- if (areIdentical(srcStat, destStat)) {
1382
- const srcBaseName = path.basename(src);
1383
- const destBaseName = path.basename(dest);
1384
- if (funcName === 'move' &&
1385
- srcBaseName !== destBaseName &&
1386
- srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1387
- return { srcStat, destStat, isChangingCase: true }
1388
- }
1389
- throw new Error('Source and destination must not be the same.')
1390
- }
1391
- if (srcStat.isDirectory() && !destStat.isDirectory()) {
1392
- throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
1393
- }
1394
- if (!srcStat.isDirectory() && destStat.isDirectory()) {
1395
- throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
1396
- }
1397
- }
1398
-
1399
- if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1400
- throw new Error(errMsg(src, dest, funcName))
1401
- }
1402
-
1403
- return { srcStat, destStat }
1404
- }
1405
-
1406
- function checkPathsSync (src, dest, funcName, opts) {
1407
- const { srcStat, destStat } = getStatsSync(src, dest, opts);
1408
-
1409
- if (destStat) {
1410
- if (areIdentical(srcStat, destStat)) {
1411
- const srcBaseName = path.basename(src);
1412
- const destBaseName = path.basename(dest);
1413
- if (funcName === 'move' &&
1414
- srcBaseName !== destBaseName &&
1415
- srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1416
- return { srcStat, destStat, isChangingCase: true }
1417
- }
1418
- throw new Error('Source and destination must not be the same.')
1419
- }
1420
- if (srcStat.isDirectory() && !destStat.isDirectory()) {
1421
- throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
1422
- }
1423
- if (!srcStat.isDirectory() && destStat.isDirectory()) {
1424
- throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
1425
- }
1426
- }
1427
-
1428
- if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1429
- throw new Error(errMsg(src, dest, funcName))
1430
- }
1431
- return { srcStat, destStat }
1432
- }
1433
-
1434
- // recursively check if dest parent is a subdirectory of src.
1435
- // It works for all file types including symlinks since it
1436
- // checks the src and dest inodes. It starts from the deepest
1437
- // parent and stops once it reaches the src parent or the root path.
1438
- async function checkParentPaths (src, srcStat, dest, funcName) {
1439
- const srcParent = path.resolve(path.dirname(src));
1440
- const destParent = path.resolve(path.dirname(dest));
1441
- if (destParent === srcParent || destParent === path.parse(destParent).root) return
1442
-
1443
- let destStat;
1444
- try {
1445
- destStat = await fs.stat(destParent, { bigint: true });
1446
- } catch (err) {
1447
- if (err.code === 'ENOENT') return
1448
- throw err
1449
- }
1450
-
1451
- if (areIdentical(srcStat, destStat)) {
1452
- throw new Error(errMsg(src, dest, funcName))
1453
- }
1454
-
1455
- return checkParentPaths(src, srcStat, destParent, funcName)
1456
- }
1457
-
1458
- function checkParentPathsSync (src, srcStat, dest, funcName) {
1459
- const srcParent = path.resolve(path.dirname(src));
1460
- const destParent = path.resolve(path.dirname(dest));
1461
- if (destParent === srcParent || destParent === path.parse(destParent).root) return
1462
- let destStat;
1463
- try {
1464
- destStat = fs.statSync(destParent, { bigint: true });
1465
- } catch (err) {
1466
- if (err.code === 'ENOENT') return
1467
- throw err
1468
- }
1469
- if (areIdentical(srcStat, destStat)) {
1470
- throw new Error(errMsg(src, dest, funcName))
1471
- }
1472
- return checkParentPathsSync(src, srcStat, destParent, funcName)
1473
- }
1474
-
1475
- function areIdentical (srcStat, destStat) {
1476
- // stat.dev can be 0n on windows when node version >= 22.x.x
1477
- return destStat.ino !== undefined && destStat.dev !== undefined && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
1478
- }
1479
-
1480
- // return true if dest is a subdir of src, otherwise false.
1481
- // It only checks the path strings.
1482
- function isSrcSubdir (src, dest) {
1483
- const srcArr = path.resolve(src).split(path.sep).filter(i => i);
1484
- const destArr = path.resolve(dest).split(path.sep).filter(i => i);
1485
- return srcArr.every((cur, i) => destArr[i] === cur)
1486
- }
1487
-
1488
- function errMsg (src, dest, funcName) {
1489
- return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
1490
- }
1491
-
1492
- stat = {
1493
- // checkPaths
1494
- checkPaths: u(checkPaths),
1495
- checkPathsSync,
1496
- // checkParent
1497
- checkParentPaths: u(checkParentPaths),
1498
- checkParentPathsSync,
1499
- // Misc
1500
- isSrcSubdir,
1501
- areIdentical
1502
- };
1503
- return stat;
1504
- }
1505
-
1506
- var async;
1507
- var hasRequiredAsync;
1508
-
1509
- function requireAsync () {
1510
- if (hasRequiredAsync) return async;
1511
- hasRequiredAsync = 1;
1512
-
1513
- // https://github.com/jprichardson/node-fs-extra/issues/1056
1514
- // Performing parallel operations on each item of an async iterator is
1515
- // surprisingly hard; you need to have handlers in place to avoid getting an
1516
- // UnhandledPromiseRejectionWarning.
1517
- // NOTE: This function does not presently handle return values, only errors
1518
- async function asyncIteratorConcurrentProcess (iterator, fn) {
1519
- const promises = [];
1520
- for await (const item of iterator) {
1521
- promises.push(
1522
- fn(item).then(
1523
- () => null,
1524
- (err) => err ?? new Error('unknown error')
1525
- )
1526
- );
1527
- }
1528
- await Promise.all(
1529
- promises.map((promise) =>
1530
- promise.then((possibleErr) => {
1531
- if (possibleErr !== null) throw possibleErr
1532
- })
1533
- )
1534
- );
1535
- }
1536
-
1537
- async = {
1538
- asyncIteratorConcurrentProcess
1539
- };
1540
- return async;
1541
- }
1542
-
1543
- var copy_1;
1544
- var hasRequiredCopy$1;
1545
-
1546
- function requireCopy$1 () {
1547
- if (hasRequiredCopy$1) return copy_1;
1548
- hasRequiredCopy$1 = 1;
1549
-
1550
- const fs = /*@__PURE__*/ requireFs();
1551
- const path = sysPath;
1552
- const { mkdirs } = /*@__PURE__*/ requireMkdirs();
1553
- const { pathExists } = /*@__PURE__*/ requirePathExists();
1554
- const { utimesMillis } = /*@__PURE__*/ requireUtimes();
1555
- const stat = /*@__PURE__*/ requireStat();
1556
- const { asyncIteratorConcurrentProcess } = /*@__PURE__*/ requireAsync();
1557
-
1558
- async function copy (src, dest, opts = {}) {
1559
- if (typeof opts === 'function') {
1560
- opts = { filter: opts };
1561
- }
1562
-
1563
- opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
1564
- opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
1565
-
1566
- // Warn about using preserveTimestamps on 32-bit node
1567
- if (opts.preserveTimestamps && process.arch === 'ia32') {
1568
- process.emitWarning(
1569
- 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
1570
- '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
1571
- 'Warning', 'fs-extra-WARN0001'
1572
- );
1573
- }
1574
-
1575
- const { srcStat, destStat } = await stat.checkPaths(src, dest, 'copy', opts);
1576
-
1577
- await stat.checkParentPaths(src, srcStat, dest, 'copy');
1578
-
1579
- const include = await runFilter(src, dest, opts);
1580
-
1581
- if (!include) return
1582
-
1583
- // check if the parent of dest exists, and create it if it doesn't exist
1584
- const destParent = path.dirname(dest);
1585
- const dirExists = await pathExists(destParent);
1586
- if (!dirExists) {
1587
- await mkdirs(destParent);
1588
- }
1589
-
1590
- await getStatsAndPerformCopy(destStat, src, dest, opts);
1591
- }
1592
-
1593
- async function runFilter (src, dest, opts) {
1594
- if (!opts.filter) return true
1595
- return opts.filter(src, dest)
1596
- }
1597
-
1598
- async function getStatsAndPerformCopy (destStat, src, dest, opts) {
1599
- const statFn = opts.dereference ? fs.stat : fs.lstat;
1600
- const srcStat = await statFn(src);
1601
-
1602
- if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
1603
-
1604
- if (
1605
- srcStat.isFile() ||
1606
- srcStat.isCharacterDevice() ||
1607
- srcStat.isBlockDevice()
1608
- ) return onFile(srcStat, destStat, src, dest, opts)
1609
-
1610
- if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
1611
- if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
1612
- if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
1613
- throw new Error(`Unknown file: ${src}`)
1614
- }
1615
-
1616
- async function onFile (srcStat, destStat, src, dest, opts) {
1617
- if (!destStat) return copyFile(srcStat, src, dest, opts)
1618
-
1619
- if (opts.overwrite) {
1620
- await fs.unlink(dest);
1621
- return copyFile(srcStat, src, dest, opts)
1622
- }
1623
- if (opts.errorOnExist) {
1624
- throw new Error(`'${dest}' already exists`)
1625
- }
1626
- }
1627
-
1628
- async function copyFile (srcStat, src, dest, opts) {
1629
- await fs.copyFile(src, dest);
1630
- if (opts.preserveTimestamps) {
1631
- // Make sure the file is writable before setting the timestamp
1632
- // otherwise open fails with EPERM when invoked with 'r+'
1633
- // (through utimes call)
1634
- if (fileIsNotWritable(srcStat.mode)) {
1635
- await makeFileWritable(dest, srcStat.mode);
1636
- }
1637
-
1638
- // Set timestamps and mode correspondingly
1639
-
1640
- // Note that The initial srcStat.atime cannot be trusted
1641
- // because it is modified by the read(2) system call
1642
- // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
1643
- const updatedSrcStat = await fs.stat(src);
1644
- await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1645
- }
1646
-
1647
- return fs.chmod(dest, srcStat.mode)
1648
- }
1649
-
1650
- function fileIsNotWritable (srcMode) {
1651
- return (srcMode & 0o200) === 0
1652
- }
1653
-
1654
- function makeFileWritable (dest, srcMode) {
1655
- return fs.chmod(dest, srcMode | 0o200)
1656
- }
1657
-
1658
- async function onDir (srcStat, destStat, src, dest, opts) {
1659
- // the dest directory might not exist, create it
1660
- if (!destStat) {
1661
- await fs.mkdir(dest);
1662
- }
1663
-
1664
- // iterate through the files in the current directory to copy everything
1665
- await asyncIteratorConcurrentProcess(await fs.opendir(src), async (item) => {
1666
- const srcItem = path.join(src, item.name);
1667
- const destItem = path.join(dest, item.name);
1668
-
1669
- const include = await runFilter(srcItem, destItem, opts);
1670
- // only copy the item if it matches the filter function
1671
- if (include) {
1672
- const { destStat } = await stat.checkPaths(srcItem, destItem, 'copy', opts);
1673
- // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
1674
- // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
1675
- await getStatsAndPerformCopy(destStat, srcItem, destItem, opts);
1676
- }
1677
- });
1678
-
1679
- if (!destStat) {
1680
- await fs.chmod(dest, srcStat.mode);
1681
- }
1682
- }
1683
-
1684
- async function onLink (destStat, src, dest, opts) {
1685
- let resolvedSrc = await fs.readlink(src);
1686
- if (opts.dereference) {
1687
- resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
1688
- }
1689
- if (!destStat) {
1690
- return fs.symlink(resolvedSrc, dest)
1691
- }
1692
-
1693
- let resolvedDest = null;
1694
- try {
1695
- resolvedDest = await fs.readlink(dest);
1696
- } catch (e) {
1697
- // dest exists and is a regular file or directory,
1698
- // Windows may throw UNKNOWN error. If dest already exists,
1699
- // fs throws error anyway, so no need to guard against it here.
1700
- if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest)
1701
- throw e
1702
- }
1703
- if (opts.dereference) {
1704
- resolvedDest = path.resolve(process.cwd(), resolvedDest);
1705
- }
1706
- // If both symlinks resolve to the same target, they are still distinct symlinks
1707
- // that can be copied/overwritten. Only check subdirectory constraints when
1708
- // the resolved paths are different.
1709
- if (resolvedSrc !== resolvedDest) {
1710
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1711
- throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
1712
- }
1713
-
1714
- // do not copy if src is a subdir of dest since unlinking
1715
- // dest in this case would result in removing src contents
1716
- // and therefore a broken symlink would be created.
1717
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1718
- throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
1719
- }
1720
- }
1721
-
1722
- // copy the link
1723
- await fs.unlink(dest);
1724
- return fs.symlink(resolvedSrc, dest)
1725
- }
1726
-
1727
- copy_1 = copy;
1728
- return copy_1;
1729
- }
1730
-
1731
- var copySync_1;
1732
- var hasRequiredCopySync;
1733
-
1734
- function requireCopySync () {
1735
- if (hasRequiredCopySync) return copySync_1;
1736
- hasRequiredCopySync = 1;
1737
-
1738
- const fs = requireGracefulFs();
1739
- const path = sysPath;
1740
- const mkdirsSync = /*@__PURE__*/ requireMkdirs().mkdirsSync;
1741
- const utimesMillisSync = /*@__PURE__*/ requireUtimes().utimesMillisSync;
1742
- const stat = /*@__PURE__*/ requireStat();
1743
-
1744
- function copySync (src, dest, opts) {
1745
- if (typeof opts === 'function') {
1746
- opts = { filter: opts };
1747
- }
1748
-
1749
- opts = opts || {};
1750
- opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
1751
- opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
1752
-
1753
- // Warn about using preserveTimestamps on 32-bit node
1754
- if (opts.preserveTimestamps && process.arch === 'ia32') {
1755
- process.emitWarning(
1756
- 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
1757
- '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
1758
- 'Warning', 'fs-extra-WARN0002'
1759
- );
1760
- }
1761
-
1762
- const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts);
1763
- stat.checkParentPathsSync(src, srcStat, dest, 'copy');
1764
- if (opts.filter && !opts.filter(src, dest)) return
1765
- const destParent = path.dirname(dest);
1766
- if (!fs.existsSync(destParent)) mkdirsSync(destParent);
1767
- return getStats(destStat, src, dest, opts)
1768
- }
1769
-
1770
- function getStats (destStat, src, dest, opts) {
1771
- const statSync = opts.dereference ? fs.statSync : fs.lstatSync;
1772
- const srcStat = statSync(src);
1773
-
1774
- if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
1775
- else if (srcStat.isFile() ||
1776
- srcStat.isCharacterDevice() ||
1777
- srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
1778
- else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
1779
- else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
1780
- else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
1781
- throw new Error(`Unknown file: ${src}`)
1782
- }
1783
-
1784
- function onFile (srcStat, destStat, src, dest, opts) {
1785
- if (!destStat) return copyFile(srcStat, src, dest, opts)
1786
- return mayCopyFile(srcStat, src, dest, opts)
1787
- }
1788
-
1789
- function mayCopyFile (srcStat, src, dest, opts) {
1790
- if (opts.overwrite) {
1791
- fs.unlinkSync(dest);
1792
- return copyFile(srcStat, src, dest, opts)
1793
- } else if (opts.errorOnExist) {
1794
- throw new Error(`'${dest}' already exists`)
1795
- }
1796
- }
1797
-
1798
- function copyFile (srcStat, src, dest, opts) {
1799
- fs.copyFileSync(src, dest);
1800
- if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
1801
- return setDestMode(dest, srcStat.mode)
1802
- }
1803
-
1804
- function handleTimestamps (srcMode, src, dest) {
1805
- // Make sure the file is writable before setting the timestamp
1806
- // otherwise open fails with EPERM when invoked with 'r+'
1807
- // (through utimes call)
1808
- if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
1809
- return setDestTimestamps(src, dest)
1810
- }
1811
-
1812
- function fileIsNotWritable (srcMode) {
1813
- return (srcMode & 0o200) === 0
1814
- }
1815
-
1816
- function makeFileWritable (dest, srcMode) {
1817
- return setDestMode(dest, srcMode | 0o200)
1818
- }
1819
-
1820
- function setDestMode (dest, srcMode) {
1821
- return fs.chmodSync(dest, srcMode)
1822
- }
1823
-
1824
- function setDestTimestamps (src, dest) {
1825
- // The initial srcStat.atime cannot be trusted
1826
- // because it is modified by the read(2) system call
1827
- // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
1828
- const updatedSrcStat = fs.statSync(src);
1829
- return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
1830
- }
1831
-
1832
- function onDir (srcStat, destStat, src, dest, opts) {
1833
- if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
1834
- return copyDir(src, dest, opts)
1835
- }
1836
-
1837
- function mkDirAndCopy (srcMode, src, dest, opts) {
1838
- fs.mkdirSync(dest);
1839
- copyDir(src, dest, opts);
1840
- return setDestMode(dest, srcMode)
1841
- }
1842
-
1843
- function copyDir (src, dest, opts) {
1844
- const dir = fs.opendirSync(src);
1845
-
1846
- try {
1847
- let dirent;
1848
-
1849
- while ((dirent = dir.readSync()) !== null) {
1850
- copyDirItem(dirent.name, src, dest, opts);
1851
- }
1852
- } finally {
1853
- dir.closeSync();
1854
- }
1855
- }
1856
-
1857
- function copyDirItem (item, src, dest, opts) {
1858
- const srcItem = path.join(src, item);
1859
- const destItem = path.join(dest, item);
1860
- if (opts.filter && !opts.filter(srcItem, destItem)) return
1861
- const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts);
1862
- return getStats(destStat, srcItem, destItem, opts)
1863
- }
1864
-
1865
- function onLink (destStat, src, dest, opts) {
1866
- let resolvedSrc = fs.readlinkSync(src);
1867
- if (opts.dereference) {
1868
- resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
1869
- }
1870
-
1871
- if (!destStat) {
1872
- return fs.symlinkSync(resolvedSrc, dest)
1873
- } else {
1874
- let resolvedDest;
1875
- try {
1876
- resolvedDest = fs.readlinkSync(dest);
1877
- } catch (err) {
1878
- // dest exists and is a regular file or directory,
1879
- // Windows may throw UNKNOWN error. If dest already exists,
1880
- // fs throws error anyway, so no need to guard against it here.
1881
- if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)
1882
- throw err
1883
- }
1884
- if (opts.dereference) {
1885
- resolvedDest = path.resolve(process.cwd(), resolvedDest);
1886
- }
1887
- // If both symlinks resolve to the same target, they are still distinct symlinks
1888
- // that can be copied/overwritten. Only check subdirectory constraints when
1889
- // the resolved paths are different.
1890
- if (resolvedSrc !== resolvedDest) {
1891
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1892
- throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
1893
- }
1894
-
1895
- // prevent copy if src is a subdir of dest since unlinking
1896
- // dest in this case would result in removing src contents
1897
- // and therefore a broken symlink would be created.
1898
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1899
- throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
1900
- }
1901
- }
1902
- return copyLink(resolvedSrc, dest)
1903
- }
1904
- }
1905
-
1906
- function copyLink (resolvedSrc, dest) {
1907
- fs.unlinkSync(dest);
1908
- return fs.symlinkSync(resolvedSrc, dest)
1909
- }
1910
-
1911
- copySync_1 = copySync;
1912
- return copySync_1;
1913
- }
1914
-
1915
- var copy;
1916
- var hasRequiredCopy;
1917
-
1918
- function requireCopy () {
1919
- if (hasRequiredCopy) return copy;
1920
- hasRequiredCopy = 1;
1921
-
1922
- const u = requireUniversalify().fromPromise;
1923
- copy = {
1924
- copy: u(/*@__PURE__*/ requireCopy$1()),
1925
- copySync: /*@__PURE__*/ requireCopySync()
1926
- };
1927
- return copy;
1928
- }
1929
-
1930
- var remove_1;
1931
- var hasRequiredRemove;
1932
-
1933
- function requireRemove () {
1934
- if (hasRequiredRemove) return remove_1;
1935
- hasRequiredRemove = 1;
1936
-
1937
- const fs = requireGracefulFs();
1938
- const u = requireUniversalify().fromCallback;
1939
-
1940
- function remove (path, callback) {
1941
- fs.rm(path, { recursive: true, force: true }, callback);
1942
- }
1943
-
1944
- function removeSync (path) {
1945
- fs.rmSync(path, { recursive: true, force: true });
1946
- }
1947
-
1948
- remove_1 = {
1949
- remove: u(remove),
1950
- removeSync
1951
- };
1952
- return remove_1;
1953
- }
1954
-
1955
- var empty;
1956
- var hasRequiredEmpty;
1957
-
1958
- function requireEmpty () {
1959
- if (hasRequiredEmpty) return empty;
1960
- hasRequiredEmpty = 1;
1961
-
1962
- const u = requireUniversalify().fromPromise;
1963
- const fs = /*@__PURE__*/ requireFs();
1964
- const path = sysPath;
1965
- const mkdir = /*@__PURE__*/ requireMkdirs();
1966
- const remove = /*@__PURE__*/ requireRemove();
1967
-
1968
- const emptyDir = u(async function emptyDir (dir) {
1969
- let items;
1970
- try {
1971
- items = await fs.readdir(dir);
1972
- } catch {
1973
- return mkdir.mkdirs(dir)
1974
- }
1975
-
1976
- return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
1977
- });
1978
-
1979
- function emptyDirSync (dir) {
1980
- let items;
1981
- try {
1982
- items = fs.readdirSync(dir);
1983
- } catch {
1984
- return mkdir.mkdirsSync(dir)
1985
- }
1986
-
1987
- items.forEach(item => {
1988
- item = path.join(dir, item);
1989
- remove.removeSync(item);
1990
- });
1991
- }
1992
-
1993
- empty = {
1994
- emptyDirSync,
1995
- emptydirSync: emptyDirSync,
1996
- emptyDir,
1997
- emptydir: emptyDir
1998
- };
1999
- return empty;
2000
- }
2001
-
2002
- var file;
2003
- var hasRequiredFile;
2004
-
2005
- function requireFile () {
2006
- if (hasRequiredFile) return file;
2007
- hasRequiredFile = 1;
2008
-
2009
- const u = requireUniversalify().fromPromise;
2010
- const path = sysPath;
2011
- const fs = /*@__PURE__*/ requireFs();
2012
- const mkdir = /*@__PURE__*/ requireMkdirs();
2013
-
2014
- async function createFile (file) {
2015
- let stats;
2016
- try {
2017
- stats = await fs.stat(file);
2018
- } catch { }
2019
- if (stats && stats.isFile()) return
2020
-
2021
- const dir = path.dirname(file);
2022
-
2023
- let dirStats = null;
2024
- try {
2025
- dirStats = await fs.stat(dir);
2026
- } catch (err) {
2027
- // if the directory doesn't exist, make it
2028
- if (err.code === 'ENOENT') {
2029
- await mkdir.mkdirs(dir);
2030
- await fs.writeFile(file, '');
2031
- return
2032
- } else {
2033
- throw err
2034
- }
2035
- }
2036
-
2037
- if (dirStats.isDirectory()) {
2038
- await fs.writeFile(file, '');
2039
- } else {
2040
- // parent is not a directory
2041
- // This is just to cause an internal ENOTDIR error to be thrown
2042
- await fs.readdir(dir);
2043
- }
2044
- }
2045
-
2046
- function createFileSync (file) {
2047
- let stats;
2048
- try {
2049
- stats = fs.statSync(file);
2050
- } catch { }
2051
- if (stats && stats.isFile()) return
2052
-
2053
- const dir = path.dirname(file);
2054
- try {
2055
- if (!fs.statSync(dir).isDirectory()) {
2056
- // parent is not a directory
2057
- // This is just to cause an internal ENOTDIR error to be thrown
2058
- fs.readdirSync(dir);
2059
- }
2060
- } catch (err) {
2061
- // If the stat call above failed because the directory doesn't exist, create it
2062
- if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir);
2063
- else throw err
2064
- }
2065
-
2066
- fs.writeFileSync(file, '');
2067
- }
2068
-
2069
- file = {
2070
- createFile: u(createFile),
2071
- createFileSync
2072
- };
2073
- return file;
2074
- }
2075
-
2076
- var link;
2077
- var hasRequiredLink;
2078
-
2079
- function requireLink () {
2080
- if (hasRequiredLink) return link;
2081
- hasRequiredLink = 1;
2082
-
2083
- const u = requireUniversalify().fromPromise;
2084
- const path = sysPath;
2085
- const fs = /*@__PURE__*/ requireFs();
2086
- const mkdir = /*@__PURE__*/ requireMkdirs();
2087
- const { pathExists } = /*@__PURE__*/ requirePathExists();
2088
- const { areIdentical } = /*@__PURE__*/ requireStat();
2089
-
2090
- async function createLink (srcpath, dstpath) {
2091
- let dstStat;
2092
- try {
2093
- dstStat = await fs.lstat(dstpath);
2094
- } catch {
2095
- // ignore error
2096
- }
2097
-
2098
- let srcStat;
2099
- try {
2100
- srcStat = await fs.lstat(srcpath);
2101
- } catch (err) {
2102
- err.message = err.message.replace('lstat', 'ensureLink');
2103
- throw err
2104
- }
2105
-
2106
- if (dstStat && areIdentical(srcStat, dstStat)) return
2107
-
2108
- const dir = path.dirname(dstpath);
2109
-
2110
- const dirExists = await pathExists(dir);
2111
-
2112
- if (!dirExists) {
2113
- await mkdir.mkdirs(dir);
2114
- }
2115
-
2116
- await fs.link(srcpath, dstpath);
2117
- }
2118
-
2119
- function createLinkSync (srcpath, dstpath) {
2120
- let dstStat;
2121
- try {
2122
- dstStat = fs.lstatSync(dstpath);
2123
- } catch {}
2124
-
2125
- try {
2126
- const srcStat = fs.lstatSync(srcpath);
2127
- if (dstStat && areIdentical(srcStat, dstStat)) return
2128
- } catch (err) {
2129
- err.message = err.message.replace('lstat', 'ensureLink');
2130
- throw err
2131
- }
2132
-
2133
- const dir = path.dirname(dstpath);
2134
- const dirExists = fs.existsSync(dir);
2135
- if (dirExists) return fs.linkSync(srcpath, dstpath)
2136
- mkdir.mkdirsSync(dir);
2137
-
2138
- return fs.linkSync(srcpath, dstpath)
2139
- }
2140
-
2141
- link = {
2142
- createLink: u(createLink),
2143
- createLinkSync
2144
- };
2145
- return link;
2146
- }
2147
-
2148
- var symlinkPaths_1;
2149
- var hasRequiredSymlinkPaths;
2150
-
2151
- function requireSymlinkPaths () {
2152
- if (hasRequiredSymlinkPaths) return symlinkPaths_1;
2153
- hasRequiredSymlinkPaths = 1;
2154
-
2155
- const path = sysPath;
2156
- const fs = /*@__PURE__*/ requireFs();
2157
- const { pathExists } = /*@__PURE__*/ requirePathExists();
2158
-
2159
- const u = requireUniversalify().fromPromise;
2160
-
2161
- /**
2162
- * Function that returns two types of paths, one relative to symlink, and one
2163
- * relative to the current working directory. Checks if path is absolute or
2164
- * relative. If the path is relative, this function checks if the path is
2165
- * relative to symlink or relative to current working directory. This is an
2166
- * initiative to find a smarter `srcpath` to supply when building symlinks.
2167
- * This allows you to determine which path to use out of one of three possible
2168
- * types of source paths. The first is an absolute path. This is detected by
2169
- * `path.isAbsolute()`. When an absolute path is provided, it is checked to
2170
- * see if it exists. If it does it's used, if not an error is returned
2171
- * (callback)/ thrown (sync). The other two options for `srcpath` are a
2172
- * relative url. By default Node's `fs.symlink` works by creating a symlink
2173
- * using `dstpath` and expects the `srcpath` to be relative to the newly
2174
- * created symlink. If you provide a `srcpath` that does not exist on the file
2175
- * system it results in a broken symlink. To minimize this, the function
2176
- * checks to see if the 'relative to symlink' source file exists, and if it
2177
- * does it will use it. If it does not, it checks if there's a file that
2178
- * exists that is relative to the current working directory, if does its used.
2179
- * This preserves the expectations of the original fs.symlink spec and adds
2180
- * the ability to pass in `relative to current working direcotry` paths.
2181
- */
2182
-
2183
- async function symlinkPaths (srcpath, dstpath) {
2184
- if (path.isAbsolute(srcpath)) {
2185
- try {
2186
- await fs.lstat(srcpath);
2187
- } catch (err) {
2188
- err.message = err.message.replace('lstat', 'ensureSymlink');
2189
- throw err
2190
- }
2191
-
2192
- return {
2193
- toCwd: srcpath,
2194
- toDst: srcpath
2195
- }
2196
- }
2197
-
2198
- const dstdir = path.dirname(dstpath);
2199
- const relativeToDst = path.join(dstdir, srcpath);
2200
-
2201
- const exists = await pathExists(relativeToDst);
2202
- if (exists) {
2203
- return {
2204
- toCwd: relativeToDst,
2205
- toDst: srcpath
2206
- }
2207
- }
2208
-
2209
- try {
2210
- await fs.lstat(srcpath);
2211
- } catch (err) {
2212
- err.message = err.message.replace('lstat', 'ensureSymlink');
2213
- throw err
2214
- }
2215
-
2216
- return {
2217
- toCwd: srcpath,
2218
- toDst: path.relative(dstdir, srcpath)
2219
- }
2220
- }
2221
-
2222
- function symlinkPathsSync (srcpath, dstpath) {
2223
- if (path.isAbsolute(srcpath)) {
2224
- const exists = fs.existsSync(srcpath);
2225
- if (!exists) throw new Error('absolute srcpath does not exist')
2226
- return {
2227
- toCwd: srcpath,
2228
- toDst: srcpath
2229
- }
2230
- }
2231
-
2232
- const dstdir = path.dirname(dstpath);
2233
- const relativeToDst = path.join(dstdir, srcpath);
2234
- const exists = fs.existsSync(relativeToDst);
2235
- if (exists) {
2236
- return {
2237
- toCwd: relativeToDst,
2238
- toDst: srcpath
2239
- }
2240
- }
2241
-
2242
- const srcExists = fs.existsSync(srcpath);
2243
- if (!srcExists) throw new Error('relative srcpath does not exist')
2244
- return {
2245
- toCwd: srcpath,
2246
- toDst: path.relative(dstdir, srcpath)
2247
- }
2248
- }
2249
-
2250
- symlinkPaths_1 = {
2251
- symlinkPaths: u(symlinkPaths),
2252
- symlinkPathsSync
2253
- };
2254
- return symlinkPaths_1;
2255
- }
2256
-
2257
- var symlinkType_1;
2258
- var hasRequiredSymlinkType;
2259
-
2260
- function requireSymlinkType () {
2261
- if (hasRequiredSymlinkType) return symlinkType_1;
2262
- hasRequiredSymlinkType = 1;
2263
-
2264
- const fs = /*@__PURE__*/ requireFs();
2265
- const u = requireUniversalify().fromPromise;
2266
-
2267
- async function symlinkType (srcpath, type) {
2268
- if (type) return type
2269
-
2270
- let stats;
2271
- try {
2272
- stats = await fs.lstat(srcpath);
2273
- } catch {
2274
- return 'file'
2275
- }
2276
-
2277
- return (stats && stats.isDirectory()) ? 'dir' : 'file'
2278
- }
2279
-
2280
- function symlinkTypeSync (srcpath, type) {
2281
- if (type) return type
2282
-
2283
- let stats;
2284
- try {
2285
- stats = fs.lstatSync(srcpath);
2286
- } catch {
2287
- return 'file'
2288
- }
2289
- return (stats && stats.isDirectory()) ? 'dir' : 'file'
2290
- }
2291
-
2292
- symlinkType_1 = {
2293
- symlinkType: u(symlinkType),
2294
- symlinkTypeSync
2295
- };
2296
- return symlinkType_1;
2297
- }
2298
-
2299
- var symlink;
2300
- var hasRequiredSymlink;
2301
-
2302
- function requireSymlink () {
2303
- if (hasRequiredSymlink) return symlink;
2304
- hasRequiredSymlink = 1;
2305
-
2306
- const u = requireUniversalify().fromPromise;
2307
- const path = sysPath;
2308
- const fs = /*@__PURE__*/ requireFs();
2309
-
2310
- const { mkdirs, mkdirsSync } = /*@__PURE__*/ requireMkdirs();
2311
-
2312
- const { symlinkPaths, symlinkPathsSync } = /*@__PURE__*/ requireSymlinkPaths();
2313
- const { symlinkType, symlinkTypeSync } = /*@__PURE__*/ requireSymlinkType();
2314
-
2315
- const { pathExists } = /*@__PURE__*/ requirePathExists();
2316
-
2317
- const { areIdentical } = /*@__PURE__*/ requireStat();
2318
-
2319
- async function createSymlink (srcpath, dstpath, type) {
2320
- let stats;
2321
- try {
2322
- stats = await fs.lstat(dstpath);
2323
- } catch { }
2324
-
2325
- if (stats && stats.isSymbolicLink()) {
2326
- const [srcStat, dstStat] = await Promise.all([
2327
- fs.stat(srcpath),
2328
- fs.stat(dstpath)
2329
- ]);
2330
-
2331
- if (areIdentical(srcStat, dstStat)) return
2332
- }
2333
-
2334
- const relative = await symlinkPaths(srcpath, dstpath);
2335
- srcpath = relative.toDst;
2336
- const toType = await symlinkType(relative.toCwd, type);
2337
- const dir = path.dirname(dstpath);
2338
-
2339
- if (!(await pathExists(dir))) {
2340
- await mkdirs(dir);
2341
- }
2342
-
2343
- return fs.symlink(srcpath, dstpath, toType)
2344
- }
2345
-
2346
- function createSymlinkSync (srcpath, dstpath, type) {
2347
- let stats;
2348
- try {
2349
- stats = fs.lstatSync(dstpath);
2350
- } catch { }
2351
- if (stats && stats.isSymbolicLink()) {
2352
- const srcStat = fs.statSync(srcpath);
2353
- const dstStat = fs.statSync(dstpath);
2354
- if (areIdentical(srcStat, dstStat)) return
2355
- }
2356
-
2357
- const relative = symlinkPathsSync(srcpath, dstpath);
2358
- srcpath = relative.toDst;
2359
- type = symlinkTypeSync(relative.toCwd, type);
2360
- const dir = path.dirname(dstpath);
2361
- const exists = fs.existsSync(dir);
2362
- if (exists) return fs.symlinkSync(srcpath, dstpath, type)
2363
- mkdirsSync(dir);
2364
- return fs.symlinkSync(srcpath, dstpath, type)
2365
- }
2366
-
2367
- symlink = {
2368
- createSymlink: u(createSymlink),
2369
- createSymlinkSync
2370
- };
2371
- return symlink;
2372
- }
2373
-
2374
- var ensure;
2375
- var hasRequiredEnsure;
2376
-
2377
- function requireEnsure () {
2378
- if (hasRequiredEnsure) return ensure;
2379
- hasRequiredEnsure = 1;
2380
-
2381
- const { createFile, createFileSync } = /*@__PURE__*/ requireFile();
2382
- const { createLink, createLinkSync } = /*@__PURE__*/ requireLink();
2383
- const { createSymlink, createSymlinkSync } = /*@__PURE__*/ requireSymlink();
2384
-
2385
- ensure = {
2386
- // file
2387
- createFile,
2388
- createFileSync,
2389
- ensureFile: createFile,
2390
- ensureFileSync: createFileSync,
2391
- // link
2392
- createLink,
2393
- createLinkSync,
2394
- ensureLink: createLink,
2395
- ensureLinkSync: createLinkSync,
2396
- // symlink
2397
- createSymlink,
2398
- createSymlinkSync,
2399
- ensureSymlink: createSymlink,
2400
- ensureSymlinkSync: createSymlinkSync
2401
- };
2402
- return ensure;
2403
- }
2404
-
2405
- var utils;
2406
- var hasRequiredUtils;
2407
-
2408
- function requireUtils () {
2409
- if (hasRequiredUtils) return utils;
2410
- hasRequiredUtils = 1;
2411
- function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
2412
- const EOF = finalEOL ? EOL : '';
2413
- const str = JSON.stringify(obj, replacer, spaces);
2414
-
2415
- return str.replace(/\n/g, EOL) + EOF
2416
- }
2417
-
2418
- function stripBom (content) {
2419
- // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
2420
- if (Buffer.isBuffer(content)) content = content.toString('utf8');
2421
- return content.replace(/^\uFEFF/, '')
2422
- }
2423
-
2424
- utils = { stringify, stripBom };
2425
- return utils;
2426
- }
2427
-
2428
- var jsonfile$1;
2429
- var hasRequiredJsonfile$1;
2430
-
2431
- function requireJsonfile$1 () {
2432
- if (hasRequiredJsonfile$1) return jsonfile$1;
2433
- hasRequiredJsonfile$1 = 1;
2434
- let _fs;
2435
- try {
2436
- _fs = requireGracefulFs();
2437
- } catch (_) {
2438
- _fs = require$$0$2;
2439
- }
2440
- const universalify = requireUniversalify();
2441
- const { stringify, stripBom } = requireUtils();
2442
-
2443
- async function _readFile (file, options = {}) {
2444
- if (typeof options === 'string') {
2445
- options = { encoding: options };
2446
- }
2447
-
2448
- const fs = options.fs || _fs;
2449
-
2450
- const shouldThrow = 'throws' in options ? options.throws : true;
2451
-
2452
- let data = await universalify.fromCallback(fs.readFile)(file, options);
2453
-
2454
- data = stripBom(data);
2455
-
2456
- let obj;
2457
- try {
2458
- obj = JSON.parse(data, options ? options.reviver : null);
2459
- } catch (err) {
2460
- if (shouldThrow) {
2461
- err.message = `${file}: ${err.message}`;
2462
- throw err
2463
- } else {
2464
- return null
2465
- }
2466
- }
2467
-
2468
- return obj
2469
- }
2470
-
2471
- const readFile = universalify.fromPromise(_readFile);
2472
-
2473
- function readFileSync (file, options = {}) {
2474
- if (typeof options === 'string') {
2475
- options = { encoding: options };
2476
- }
2477
-
2478
- const fs = options.fs || _fs;
2479
-
2480
- const shouldThrow = 'throws' in options ? options.throws : true;
2481
-
2482
- try {
2483
- let content = fs.readFileSync(file, options);
2484
- content = stripBom(content);
2485
- return JSON.parse(content, options.reviver)
2486
- } catch (err) {
2487
- if (shouldThrow) {
2488
- err.message = `${file}: ${err.message}`;
2489
- throw err
2490
- } else {
2491
- return null
2492
- }
2493
- }
2494
- }
2495
-
2496
- async function _writeFile (file, obj, options = {}) {
2497
- const fs = options.fs || _fs;
2498
-
2499
- const str = stringify(obj, options);
2500
-
2501
- await universalify.fromCallback(fs.writeFile)(file, str, options);
2502
- }
2503
-
2504
- const writeFile = universalify.fromPromise(_writeFile);
2505
-
2506
- function writeFileSync (file, obj, options = {}) {
2507
- const fs = options.fs || _fs;
2508
-
2509
- const str = stringify(obj, options);
2510
- // not sure if fs.writeFileSync returns anything, but just in case
2511
- return fs.writeFileSync(file, str, options)
2512
- }
2513
-
2514
- // NOTE: do not change this export format; required for ESM compat
2515
- // see https://github.com/jprichardson/node-jsonfile/pull/162 for details
2516
- jsonfile$1 = {
2517
- readFile,
2518
- readFileSync,
2519
- writeFile,
2520
- writeFileSync
2521
- };
2522
- return jsonfile$1;
2523
- }
2524
-
2525
- var jsonfile;
2526
- var hasRequiredJsonfile;
2527
-
2528
- function requireJsonfile () {
2529
- if (hasRequiredJsonfile) return jsonfile;
2530
- hasRequiredJsonfile = 1;
2531
-
2532
- const jsonFile = requireJsonfile$1();
2533
-
2534
- jsonfile = {
2535
- // jsonfile exports
2536
- readJson: jsonFile.readFile,
2537
- readJsonSync: jsonFile.readFileSync,
2538
- writeJson: jsonFile.writeFile,
2539
- writeJsonSync: jsonFile.writeFileSync
2540
- };
2541
- return jsonfile;
2542
- }
2543
-
2544
- var outputFile_1;
2545
- var hasRequiredOutputFile;
2546
-
2547
- function requireOutputFile () {
2548
- if (hasRequiredOutputFile) return outputFile_1;
2549
- hasRequiredOutputFile = 1;
2550
-
2551
- const u = requireUniversalify().fromPromise;
2552
- const fs = /*@__PURE__*/ requireFs();
2553
- const path = sysPath;
2554
- const mkdir = /*@__PURE__*/ requireMkdirs();
2555
- const pathExists = /*@__PURE__*/ requirePathExists().pathExists;
2556
-
2557
- async function outputFile (file, data, encoding = 'utf-8') {
2558
- const dir = path.dirname(file);
2559
-
2560
- if (!(await pathExists(dir))) {
2561
- await mkdir.mkdirs(dir);
2562
- }
2563
-
2564
- return fs.writeFile(file, data, encoding)
2565
- }
2566
-
2567
- function outputFileSync (file, ...args) {
2568
- const dir = path.dirname(file);
2569
- if (!fs.existsSync(dir)) {
2570
- mkdir.mkdirsSync(dir);
2571
- }
2572
-
2573
- fs.writeFileSync(file, ...args);
2574
- }
2575
-
2576
- outputFile_1 = {
2577
- outputFile: u(outputFile),
2578
- outputFileSync
2579
- };
2580
- return outputFile_1;
2581
- }
2582
-
2583
- var outputJson_1;
2584
- var hasRequiredOutputJson;
2585
-
2586
- function requireOutputJson () {
2587
- if (hasRequiredOutputJson) return outputJson_1;
2588
- hasRequiredOutputJson = 1;
2589
-
2590
- const { stringify } = requireUtils();
2591
- const { outputFile } = /*@__PURE__*/ requireOutputFile();
2592
-
2593
- async function outputJson (file, data, options = {}) {
2594
- const str = stringify(data, options);
2595
-
2596
- await outputFile(file, str, options);
2597
- }
2598
-
2599
- outputJson_1 = outputJson;
2600
- return outputJson_1;
2601
- }
2602
-
2603
- var outputJsonSync_1;
2604
- var hasRequiredOutputJsonSync;
2605
-
2606
- function requireOutputJsonSync () {
2607
- if (hasRequiredOutputJsonSync) return outputJsonSync_1;
2608
- hasRequiredOutputJsonSync = 1;
2609
-
2610
- const { stringify } = requireUtils();
2611
- const { outputFileSync } = /*@__PURE__*/ requireOutputFile();
2612
-
2613
- function outputJsonSync (file, data, options) {
2614
- const str = stringify(data, options);
2615
-
2616
- outputFileSync(file, str, options);
2617
- }
2618
-
2619
- outputJsonSync_1 = outputJsonSync;
2620
- return outputJsonSync_1;
2621
- }
2622
-
2623
- var json;
2624
- var hasRequiredJson;
2625
-
2626
- function requireJson () {
2627
- if (hasRequiredJson) return json;
2628
- hasRequiredJson = 1;
2629
-
2630
- const u = requireUniversalify().fromPromise;
2631
- const jsonFile = /*@__PURE__*/ requireJsonfile();
2632
-
2633
- jsonFile.outputJson = u(/*@__PURE__*/ requireOutputJson());
2634
- jsonFile.outputJsonSync = /*@__PURE__*/ requireOutputJsonSync();
2635
- // aliases
2636
- jsonFile.outputJSON = jsonFile.outputJson;
2637
- jsonFile.outputJSONSync = jsonFile.outputJsonSync;
2638
- jsonFile.writeJSON = jsonFile.writeJson;
2639
- jsonFile.writeJSONSync = jsonFile.writeJsonSync;
2640
- jsonFile.readJSON = jsonFile.readJson;
2641
- jsonFile.readJSONSync = jsonFile.readJsonSync;
2642
-
2643
- json = jsonFile;
2644
- return json;
2645
- }
2646
-
2647
- var move_1;
2648
- var hasRequiredMove$1;
2649
-
2650
- function requireMove$1 () {
2651
- if (hasRequiredMove$1) return move_1;
2652
- hasRequiredMove$1 = 1;
2653
-
2654
- const fs = /*@__PURE__*/ requireFs();
2655
- const path = sysPath;
2656
- const { copy } = /*@__PURE__*/ requireCopy();
2657
- const { remove } = /*@__PURE__*/ requireRemove();
2658
- const { mkdirp } = /*@__PURE__*/ requireMkdirs();
2659
- const { pathExists } = /*@__PURE__*/ requirePathExists();
2660
- const stat = /*@__PURE__*/ requireStat();
2661
-
2662
- async function move (src, dest, opts = {}) {
2663
- const overwrite = opts.overwrite || opts.clobber || false;
2664
-
2665
- const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, 'move', opts);
2666
-
2667
- await stat.checkParentPaths(src, srcStat, dest, 'move');
2668
-
2669
- // If the parent of dest is not root, make sure it exists before proceeding
2670
- const destParent = path.dirname(dest);
2671
- const parsedParentPath = path.parse(destParent);
2672
- if (parsedParentPath.root !== destParent) {
2673
- await mkdirp(destParent);
2674
- }
2675
-
2676
- return doRename(src, dest, overwrite, isChangingCase)
2677
- }
2678
-
2679
- async function doRename (src, dest, overwrite, isChangingCase) {
2680
- if (!isChangingCase) {
2681
- if (overwrite) {
2682
- await remove(dest);
2683
- } else if (await pathExists(dest)) {
2684
- throw new Error('dest already exists.')
2685
- }
2686
- }
2687
-
2688
- try {
2689
- // Try w/ rename first, and try copy + remove if EXDEV
2690
- await fs.rename(src, dest);
2691
- } catch (err) {
2692
- if (err.code !== 'EXDEV') {
2693
- throw err
2694
- }
2695
- await moveAcrossDevice(src, dest, overwrite);
2696
- }
2697
- }
2698
-
2699
- async function moveAcrossDevice (src, dest, overwrite) {
2700
- const opts = {
2701
- overwrite,
2702
- errorOnExist: true,
2703
- preserveTimestamps: true
2704
- };
2705
-
2706
- await copy(src, dest, opts);
2707
- return remove(src)
2708
- }
2709
-
2710
- move_1 = move;
2711
- return move_1;
2712
- }
2713
-
2714
- var moveSync_1;
2715
- var hasRequiredMoveSync;
2716
-
2717
- function requireMoveSync () {
2718
- if (hasRequiredMoveSync) return moveSync_1;
2719
- hasRequiredMoveSync = 1;
2720
-
2721
- const fs = requireGracefulFs();
2722
- const path = sysPath;
2723
- const copySync = /*@__PURE__*/ requireCopy().copySync;
2724
- const removeSync = /*@__PURE__*/ requireRemove().removeSync;
2725
- const mkdirpSync = /*@__PURE__*/ requireMkdirs().mkdirpSync;
2726
- const stat = /*@__PURE__*/ requireStat();
2727
-
2728
- function moveSync (src, dest, opts) {
2729
- opts = opts || {};
2730
- const overwrite = opts.overwrite || opts.clobber || false;
2731
-
2732
- const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts);
2733
- stat.checkParentPathsSync(src, srcStat, dest, 'move');
2734
- if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest));
2735
- return doRename(src, dest, overwrite, isChangingCase)
2736
- }
2737
-
2738
- function isParentRoot (dest) {
2739
- const parent = path.dirname(dest);
2740
- const parsedPath = path.parse(parent);
2741
- return parsedPath.root === parent
2742
- }
2743
-
2744
- function doRename (src, dest, overwrite, isChangingCase) {
2745
- if (isChangingCase) return rename(src, dest, overwrite)
2746
- if (overwrite) {
2747
- removeSync(dest);
2748
- return rename(src, dest, overwrite)
2749
- }
2750
- if (fs.existsSync(dest)) throw new Error('dest already exists.')
2751
- return rename(src, dest, overwrite)
2752
- }
2753
-
2754
- function rename (src, dest, overwrite) {
2755
- try {
2756
- fs.renameSync(src, dest);
2757
- } catch (err) {
2758
- if (err.code !== 'EXDEV') throw err
2759
- return moveAcrossDevice(src, dest, overwrite)
2760
- }
2761
- }
2762
-
2763
- function moveAcrossDevice (src, dest, overwrite) {
2764
- const opts = {
2765
- overwrite,
2766
- errorOnExist: true,
2767
- preserveTimestamps: true
2768
- };
2769
- copySync(src, dest, opts);
2770
- return removeSync(src)
2771
- }
2772
-
2773
- moveSync_1 = moveSync;
2774
- return moveSync_1;
2775
- }
2776
-
2777
- var move;
2778
- var hasRequiredMove;
2779
-
2780
- function requireMove () {
2781
- if (hasRequiredMove) return move;
2782
- hasRequiredMove = 1;
2783
-
2784
- const u = requireUniversalify().fromPromise;
2785
- move = {
2786
- move: u(/*@__PURE__*/ requireMove$1()),
2787
- moveSync: /*@__PURE__*/ requireMoveSync()
2788
- };
2789
- return move;
2790
- }
2791
-
2792
- var lib;
2793
- var hasRequiredLib;
2794
-
2795
- function requireLib () {
2796
- if (hasRequiredLib) return lib;
2797
- hasRequiredLib = 1;
2798
-
2799
- lib = {
2800
- // Export promiseified graceful-fs:
2801
- .../*@__PURE__*/ requireFs(),
2802
- // Export extra methods:
2803
- .../*@__PURE__*/ requireCopy(),
2804
- .../*@__PURE__*/ requireEmpty(),
2805
- .../*@__PURE__*/ requireEnsure(),
2806
- .../*@__PURE__*/ requireJson(),
2807
- .../*@__PURE__*/ requireMkdirs(),
2808
- .../*@__PURE__*/ requireMove(),
2809
- .../*@__PURE__*/ requireOutputFile(),
2810
- .../*@__PURE__*/ requirePathExists(),
2811
- .../*@__PURE__*/ requireRemove()
2812
- };
2813
- return lib;
2814
- }
2815
-
2816
- var libExports = /*@__PURE__*/ requireLib();
2817
- const fs = /*@__PURE__*/getDefaultExportFromCjs(libExports);
2818
-
2819
- const MAX_MEMORY_SIZE_KB = 100;
2820
- const STALE_DAYS = 30;
2821
- const VERY_STALE_DAYS = 90;
2822
- const memoryCheck = {
2823
- name: "Memory Health",
2824
- weight: 10,
2825
- async check() {
2826
- const result = {
2827
- name: this.name,
2828
- status: "fail",
2829
- score: 0,
2830
- weight: this.weight,
2831
- message: "",
2832
- details: []
2833
- };
2834
- try {
2835
- const memoryDirs = getConfiguredMemoryDirectories();
2836
- const claudeProjectsDir = getClaudeProjectsDir(memoryDirs.claudeDir);
2837
- const settingsPath = path__default.join(memoryDirs.claudeDir, "settings.json");
2838
- let hasMemoryDir = false;
2839
- let hasMemoryContent = false;
2840
- let hasCcjkRules = false;
2841
- let memoryFileCount = 0;
2842
- let totalMemorySize = 0;
2843
- let lastSyncTime = null;
2844
- let largestFileSize = 0;
2845
- let largestFileName = "";
2846
- const warnings = [];
2847
- if (await fs.pathExists(claudeProjectsDir)) {
2848
- const projects = await fs.readdir(claudeProjectsDir);
2849
- for (const project of projects) {
2850
- const memoryDir = path__default.join(claudeProjectsDir, project, "memory");
2851
- if (await fs.pathExists(memoryDir)) {
2852
- hasMemoryDir = true;
2853
- const memoryFile = path__default.join(memoryDir, "MEMORY.md");
2854
- if (await fs.pathExists(memoryFile)) {
2855
- const content = await fs.readFile(memoryFile, "utf-8");
2856
- if (content.trim().length > 0) {
2857
- hasMemoryContent = true;
2858
- memoryFileCount++;
2859
- const stats = await fs.stat(memoryFile);
2860
- const fileSizeKB = stats.size / 1024;
2861
- totalMemorySize += stats.size;
2862
- if (stats.size > largestFileSize) {
2863
- largestFileSize = stats.size;
2864
- largestFileName = project;
2865
- }
2866
- if (fileSizeKB > MAX_MEMORY_SIZE_KB) {
2867
- warnings.push(`\u26A0 ${project}: ${fileSizeKB.toFixed(1)}KB (consider cleanup)`);
2868
- }
2869
- if (!lastSyncTime || stats.mtime > lastSyncTime) {
2870
- lastSyncTime = stats.mtime;
2871
- }
2872
- const daysSinceUpdate = (Date.now() - stats.mtime.getTime()) / (1e3 * 60 * 60 * 24);
2873
- if (daysSinceUpdate > VERY_STALE_DAYS) {
2874
- warnings.push(`\u26A0 ${project}: not updated in ${Math.floor(daysSinceUpdate)} days`);
2875
- }
2876
- }
2877
- }
2878
- }
2879
- }
2880
- }
2881
- if (await fs.pathExists(settingsPath)) {
2882
- const settings = await fs.readJson(settingsPath);
2883
- const claudeMd = settings?.claudeMd || "";
2884
- if (claudeMd.includes("MEMORY.md") || claudeMd.includes("auto-memory")) {
2885
- hasCcjkRules = true;
2886
- }
2887
- }
2888
- let score = 0;
2889
- if (hasMemoryDir) {
2890
- score += 20;
2891
- result.details?.push("\u2713 Memory directory exists");
2892
- } else {
2893
- result.details?.push("\u2717 Memory directory not found");
2894
- }
2895
- if (hasMemoryContent) {
2896
- score += 30;
2897
- const totalSizeKB = (totalMemorySize / 1024).toFixed(1);
2898
- result.details?.push(`\u2713 ${memoryFileCount} memory file${memoryFileCount > 1 ? "s" : ""} (${totalSizeKB}KB total)`);
2899
- if (memoryFileCount > 1 && largestFileName) {
2900
- const largestKB = (largestFileSize / 1024).toFixed(1);
2901
- result.details?.push(` Largest: ${largestFileName} (${largestKB}KB)`);
2902
- }
2903
- } else {
2904
- result.details?.push("\u2717 No memory content found");
2905
- }
2906
- if (hasCcjkRules) {
2907
- score += 20;
2908
- result.details?.push("\u2713 CCJK memory rules configured");
2909
- } else {
2910
- result.details?.push("\u26A0 CCJK memory rules not configured");
2911
- }
2912
- if (lastSyncTime) {
2913
- const daysSinceSync = (Date.now() - lastSyncTime.getTime()) / (1e3 * 60 * 60 * 24);
2914
- if (daysSinceSync < 7) {
2915
- score += 30;
2916
- result.details?.push(`\u2713 Recently updated (${Math.floor(daysSinceSync)}d ago)`);
2917
- } else if (daysSinceSync < STALE_DAYS) {
2918
- score += 20;
2919
- result.details?.push(`\u2713 Updated ${Math.floor(daysSinceSync)}d ago`);
2920
- } else if (daysSinceSync < VERY_STALE_DAYS) {
2921
- score += 10;
2922
- result.details?.push(`\u26A0 Stale: ${Math.floor(daysSinceSync)}d since update`);
2923
- } else {
2924
- result.details?.push(`\u2717 Very stale: ${Math.floor(daysSinceSync)}d since update`);
2925
- }
2926
- }
2927
- if (warnings.length > 0) {
2928
- result.details?.push(...warnings);
2929
- }
2930
- result.score = score;
2931
- if (score >= 80 && warnings.length === 0) {
2932
- result.status = "pass";
2933
- result.message = "Memory system healthy";
2934
- } else if (score >= 50 || score >= 40 && warnings.length <= 1) {
2935
- result.status = "warn";
2936
- result.message = warnings.length > 0 ? `Memory active but needs attention (${warnings.length} warning${warnings.length > 1 ? "s" : ""})` : "Memory system partially configured";
2937
- } else {
2938
- result.status = "fail";
2939
- result.message = "Memory system needs configuration";
2940
- }
2941
- const fixes = [];
2942
- if (!hasMemoryDir || !hasMemoryContent) {
2943
- fixes.push("Enable shared Claude-family memory in settings");
2944
- result.command = "ccjk menu";
2945
- }
2946
- if (!hasCcjkRules) {
2947
- fixes.push("Add MEMORY.md reference to CLAUDE.md for better context");
2948
- }
2949
- const oversizedCount = warnings.filter((w) => w.includes("KB")).length;
2950
- if (oversizedCount > 0) {
2951
- fixes.push(`Clean up ${oversizedCount} oversized memory file${oversizedCount > 1 ? "s" : ""}`);
2952
- }
2953
- if (lastSyncTime) {
2954
- const daysSinceSync = (Date.now() - lastSyncTime.getTime()) / (1e3 * 60 * 60 * 24);
2955
- if (daysSinceSync > VERY_STALE_DAYS) {
2956
- fixes.push("Review and archive old memory entries");
2957
- } else if (daysSinceSync > STALE_DAYS) {
2958
- fixes.push("Consider refreshing stale memory content");
2959
- }
2960
- }
2961
- if (fixes.length > 0) {
2962
- result.fix = fixes.join("; ");
2963
- }
2964
- return result;
2965
- } catch (error) {
2966
- result.status = "fail";
2967
- result.message = `Failed to check memory health: ${error instanceof Error ? error.message : String(error)}`;
2968
- return result;
2969
- }
2970
- }
2971
- };
2972
-
2973
- export { memoryCheck };