@readmagic/workmate 0.0.27 → 0.0.28

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 (216) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-DqlPtsVK.js → AddWorkspaceDirectory-Bmgh8VS3.js} +1 -1
  2. package/dist/chunks/{AgentsMdExternalIncludesDialog-rJS5l6yk.js → AgentsMdExternalIncludesDialog-BJfHqScU.js} +1 -1
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-BjbUilCE.js +1 -0
  4. package/dist/chunks/{App-DzRQpRKr.js → App-COdpsR2w.js} +1 -1
  5. package/dist/chunks/{BackgroundTasksDialog-CBhSmdz_.js → BackgroundTasksDialog-WkoL4g5Q.js} +1 -1
  6. package/dist/chunks/{BypassPermissionsModeDialog-zz-lnmJt.js → BypassPermissionsModeDialog-BT9yl0Qt.js} +1 -1
  7. package/dist/chunks/{CustomSelect-CYmc4vRh.js → CustomSelect-t4wXuXWH.js} +1 -1
  8. package/dist/chunks/{DiffDialog-CTUIAcEE.js → DiffDialog-CXZxnb7Y.js} +1 -1
  9. package/dist/chunks/Doctor-B6isid5K.js +1 -0
  10. package/dist/chunks/{Doctor-CLOYkPRR.js → Doctor-COj-tZBc.js} +1 -1
  11. package/dist/chunks/{ExitFlow-CATwJC4c.js → ExitFlow-CcMYH5iI.js} +1 -1
  12. package/dist/chunks/{InvalidConfigDialog-B-9Z58oD.js → InvalidConfigDialog-riLYEaUP.js} +1 -1
  13. package/dist/chunks/{InvalidSettingsDialog-B4EWjbp7.js → InvalidSettingsDialog-BGXl3V1A.js} +1 -1
  14. package/dist/chunks/{KeybindingProviderSetup-Dzg77_Xn.js → KeybindingProviderSetup-syiDgtpB.js} +1 -1
  15. package/dist/chunks/{MCPConnectionManager-CBY8nqdU.js → MCPConnectionManager-C7RmKzJh.js} +1 -1
  16. package/dist/chunks/{MCPToolListView-C7HT6rrl.js → MCPToolListView-CewNLJus.js} +1 -1
  17. package/dist/chunks/{McpParsingWarnings-Dj_Fu5o-.js → McpParsingWarnings-Czze2JPd.js} +1 -1
  18. package/dist/chunks/{MessageSelector-Dw_ERK_Z.js → MessageSelector-Kc6JlnDX.js} +1 -1
  19. package/dist/chunks/{Messages-RBfRELKn.js → Messages-BvFYO4Zn.js} +1 -1
  20. package/dist/chunks/{Onboarding-BRSXxc2E.js → Onboarding-CD_Uv5h9.js} +1 -1
  21. package/dist/chunks/{PromptInputFooterSuggestions-ChpyD9B7.js → PromptInputFooterSuggestions-CHXJsTtQ.js} +1 -1
  22. package/dist/chunks/{PromptInputHelpMenu-CrTT8MKE.js → PromptInputHelpMenu-BZIVCV7V.js} +1 -1
  23. package/dist/chunks/{ProviderSetup-BEV95bnz.js → ProviderSetup-CwMvjmjh.js} +1 -1
  24. package/dist/chunks/{QueryEngine-BBBkZWu2.js → QueryEngine-DAwfp_ht.js} +1 -1
  25. package/dist/chunks/{REPL-BDnZnm__.js → REPL-CtFtb35A.js} +4 -4
  26. package/dist/chunks/REPL-tFT1FGQF.js +1 -0
  27. package/dist/chunks/{ResumeConversation-BuSqBrm1.js → ResumeConversation-CERzSBvg.js} +1 -1
  28. package/dist/chunks/SearchExtraToolsTool-ndh4aEwQ.js +1 -0
  29. package/dist/chunks/{Settings-DYKmPdbd.js → Settings-CPaqWNdP.js} +2 -2
  30. package/dist/chunks/{Spinner-DOI8qqZi.js → Spinner-C0qHjfIY.js} +1 -1
  31. package/dist/chunks/{TextInput-ZKU-x_FD.js → TextInput-ou7ZhpVY.js} +1 -1
  32. package/dist/chunks/{ThemePicker-B69oDgXN.js → ThemePicker-CVFWqSc7.js} +1 -1
  33. package/dist/chunks/{TrustDialog-BSG8Ibh8.js → TrustDialog-CGXv_LF4.js} +1 -1
  34. package/dist/chunks/{ValidationErrorsList-BUYHEft4.js → ValidationErrorsList-CKeHoN2Z.js} +1 -1
  35. package/dist/chunks/{_baseEach-P0u1zIx6.js → _baseEach-BYhqv77g.js} +1 -1
  36. package/dist/chunks/{add-dir-C8RmmyQK.js → add-dir-BSizpuef.js} +1 -1
  37. package/dist/chunks/{agentDisplay-np7CH47m.js → agentDisplay-JKfYFD1m.js} +1 -1
  38. package/dist/chunks/{agents-DRQlR5M1.js → agents-BDTCH6YB.js} +1 -1
  39. package/dist/chunks/{agents-DedoH0Q4.js → agents-MEaV8P2G.js} +1 -1
  40. package/dist/chunks/{allErrors-DvcU0w0F.js → allErrors-Dhnf6rqg.js} +1 -1
  41. package/dist/chunks/{appleTerminalBackup-Bemd4RXh.js → appleTerminalBackup-CN8kS74J.js} +1 -1
  42. package/dist/chunks/backgroundHousekeeping-Bu-zRFCx.js +1 -0
  43. package/dist/chunks/{backgroundHousekeeping-BtEJ6TeC.js → backgroundHousekeeping-CsXlkIg3.js} +1 -1
  44. package/dist/chunks/{banner-CuoceXzz.js → banner-BKOzHotb.js} +1 -1
  45. package/dist/chunks/{branch-ClhlS7f8.js → branch-BllXcYwS.js} +1 -1
  46. package/dist/chunks/bridgeControl-aDnUrYZR.js +2 -0
  47. package/dist/chunks/{btw-B-FLxlx-.js → btw-DzaRBa6o.js} +1 -1
  48. package/dist/chunks/caches-CMF-MmR-.js +1 -0
  49. package/dist/chunks/{caches-Dn8yrJmL.js → caches-CW5YnYNS.js} +1 -1
  50. package/dist/chunks/channel-DVx21qde.js +1 -0
  51. package/dist/chunks/channel-Gw6skpUh.js +1 -0
  52. package/dist/chunks/{clear-BnWv0i65.js → clear-CDQs9_5P.js} +1 -1
  53. package/dist/chunks/commands-CfYMwgP7.js +1 -0
  54. package/dist/chunks/{compact-Banc-SNk.js → compact-6F2tuItE.js} +1 -1
  55. package/dist/chunks/config-BDkzWBnL.js +1 -0
  56. package/dist/chunks/{config-BDn2YIjC.js → config-Bio2EjUK.js} +1 -1
  57. package/dist/chunks/config-C_AEhZrn.js +1 -0
  58. package/dist/chunks/{context-BvDBAyJ9.js → context-TkdzCK3Y.js} +1 -1
  59. package/dist/chunks/{context-noninteractive-CuHHniJn.js → context-noninteractive-BcBo64vo.js} +1 -1
  60. package/dist/chunks/context-noninteractive-oFcnY1Er.js +1 -0
  61. package/dist/chunks/{conversation-Cjaftrrw.js → conversation-CYZyg1U1.js} +1 -1
  62. package/dist/chunks/conversation-DXzlRhNw.js +1 -0
  63. package/dist/chunks/{conversationRecovery-NL05oJb1.js → conversationRecovery-_hWC7JBO.js} +1 -1
  64. package/dist/chunks/{crossProjectResume-BzltC4NJ.js → crossProjectResume-CCo3iZrB.js} +1 -1
  65. package/dist/chunks/{diff--6gQCx_x.js → diff-BzVUPO4Z.js} +1 -1
  66. package/dist/chunks/doctor-B4jQbGQr.js +1 -0
  67. package/dist/chunks/{entry-DWYOrkFS.js → entry-333L52Lo.js} +1 -1
  68. package/dist/chunks/{exit-uKtXb5U3.js → exit-D5DYnRvR.js} +1 -1
  69. package/dist/chunks/{extraUsage-Dr0YXm1w.js → extraUsage-CmgRR-zH.js} +1 -1
  70. package/dist/chunks/extractMemories-CVUrBFMj.js +1 -0
  71. package/dist/chunks/fast-CRhW9zha.js +1 -0
  72. package/dist/chunks/{fast-C5-lNCQi.js → fast-D7oNjaZ3.js} +1 -1
  73. package/dist/chunks/{fetchModelList-9w1E4Ue8.js → fetchModelList-Cv1vWIpC.js} +1 -1
  74. package/dist/chunks/fetchModelList-DIa1HwAJ.js +1 -0
  75. package/dist/chunks/{fileSuggestions-BYD78vcF.js → fileSuggestions-DF3HTRKr.js} +1 -1
  76. package/dist/chunks/{gemini-BNBptTET.js → gemini-ou7_YyXc.js} +1 -1
  77. package/dist/chunks/{generateSessionName-CO2484aJ.js → generateSessionName-CeN9EZNY.js} +1 -1
  78. package/dist/chunks/{goal-j0wdadwM.js → goal-CCxo4Wyf.js} +1 -1
  79. package/dist/chunks/{grok-BpO1ZwK_.js → grok-BMmUcNbI.js} +1 -1
  80. package/dist/chunks/{help-DwhA0qQ6.js → help-CYtogTZk.js} +1 -1
  81. package/dist/chunks/{hooks-DG4_WdZ2.js → hooks-ByVkvodY.js} +1 -1
  82. package/dist/chunks/hooks-CBGUcyCs.js +1 -0
  83. package/dist/chunks/{install-BbmCNCuM.js → install-DIxyfdXG.js} +1 -1
  84. package/dist/chunks/{instrumentation-DpPmDyNF.js → instrumentation-BmHivmxs.js} +3 -3
  85. package/dist/chunks/{job-GcmX1ALd.js → job-D534P26R.js} +1 -1
  86. package/dist/chunks/{launchLocalMemory-CDgT5lst.js → launchLocalMemory-CWXLb3KF.js} +1 -1
  87. package/dist/chunks/{launchOnboarding-uQ_ux9sS.js → launchOnboarding-CocPmwzz.js} +1 -1
  88. package/dist/chunks/loadAgentsDir-Zw648oQO.js +1 -0
  89. package/dist/chunks/{loadAgentsDir-uuZYOgKn.js → loadAgentsDir-bmpKLPdG.js} +343 -343
  90. package/dist/chunks/{loadPluginHooks-QoVXsBjy.js → loadPluginHooks-BIfM53-_.js} +1 -1
  91. package/dist/chunks/{localSearch-yVCDrVrf.js → localSearch-Da8cVYoI.js} +1 -1
  92. package/dist/chunks/localSearch-Dbj8cXyO.js +1 -0
  93. package/dist/chunks/{logoUtils-B4wCDKs9.js → logoUtils-qNuBc2nI.js} +1 -1
  94. package/dist/chunks/{magicDocs-D53lV8b5.js → magicDocs-BsEiBLQl.js} +1 -1
  95. package/dist/chunks/{main-fy_XSXGj.js → main-B31aPMPP.js} +6 -6
  96. package/dist/chunks/managedEnv-DCGLDTP_.js +1 -0
  97. package/dist/chunks/{managedEnv-B8YWmM4A.js → managedEnv-EZ2IirNa.js} +1 -1
  98. package/dist/chunks/{mcp-DCl-Tz-C.js → mcp-BMeWtYCx.js} +1 -1
  99. package/dist/chunks/{mcp--LmEVBRg.js → mcp-CYbesbfl.js} +1 -1
  100. package/dist/chunks/{mcp-CZUVaPb3.js → mcp-Dd8TBfQQ.js} +1 -1
  101. package/dist/chunks/{memory-Bu5ku7y9.js → memory-DtQQGyPS.js} +1 -1
  102. package/dist/chunks/{mode-Bteqe2QG.js → mode-SM8doWgC.js} +1 -1
  103. package/dist/chunks/{model-CHDU5yqH.js → model-C2r-PaR4.js} +1 -1
  104. package/dist/chunks/{model-CcHyMyBv.js → model-Dd3x121y.js} +1 -1
  105. package/dist/chunks/{modelOptions-CJV1R3Jt.js → modelOptions-BQL4gbNk.js} +1 -1
  106. package/dist/chunks/{nativeInstaller-CIUYh1aD.js → nativeInstaller-DMkZdsof.js} +1 -1
  107. package/dist/chunks/{notifications-GLnjirCl.js → notifications-BwS1XsnZ.js} +1 -1
  108. package/dist/chunks/{onChangeAppState-CxGW2d-l.js → onChangeAppState-C9cYQJPF.js} +1 -1
  109. package/dist/chunks/{openai-BpGQT2Iv.js → openai-Bea4I2Od.js} +1 -1
  110. package/dist/chunks/{overlayContext-7wgLio1O.js → overlayContext-C5WPACKC.js} +1 -1
  111. package/dist/chunks/{partition-djFY9gGI.js → partition-CKgWl7p4.js} +1 -1
  112. package/dist/chunks/{permissions-DNedQyLg.js → permissions-Dv_PCfY0.js} +1 -1
  113. package/dist/chunks/{pidLock-CFUBtZck.js → pidLock-CqkC3-nD.js} +2 -2
  114. package/dist/chunks/{plan-DI0n7LIV.js → plan-Ce6wfjjI.js} +1 -1
  115. package/dist/chunks/{plugin-BQ8gRVYF.js → plugin-aK4tDrVg.js} +1 -1
  116. package/dist/chunks/{pluginAutoupdate-CNrHb4RJ.js → pluginAutoupdate-ByokIVEs.js} +1 -1
  117. package/dist/chunks/{pluginBlocklist-CKCsgWdY.js → pluginBlocklist-ByRQaVPu.js} +1 -1
  118. package/dist/chunks/{pluginCliCommands-CACeyIwz.js → pluginCliCommands-Dyk4HYHs.js} +1 -1
  119. package/dist/chunks/{pluginFlagging-CUvkKGOB.js → pluginFlagging-B2ZX5_oB.js} +1 -1
  120. package/dist/chunks/{pluginOperations-Ca_T-HYn.js → pluginOperations-BCvJvfOC.js} +1 -1
  121. package/dist/chunks/{pluginStartupCheck-DftTiXct.js → pluginStartupCheck-QG0d95dE.js} +1 -1
  122. package/dist/chunks/pluginStartupCheck-o_TC7wIt.js +1 -0
  123. package/dist/chunks/{plugins-Divl-P-X.js → plugins-DzsTDNWJ.js} +1 -1
  124. package/dist/chunks/{print-DSHypGJa.js → print-dUT7E1g9.js} +2 -2
  125. package/dist/chunks/{processBashCommand-BLcFmbyG.js → processBashCommand-DtGCgTkF.js} +1 -1
  126. package/dist/chunks/{processSlashCommand-Caif46Gi.js → processSlashCommand-wXblpK2C.js} +1 -1
  127. package/dist/chunks/{projectOnboardingState-nTCycGCD.js → projectOnboardingState-D-_ijZnG.js} +1 -1
  128. package/dist/chunks/prompt-BdH2zk0S.js +1 -0
  129. package/dist/chunks/{prompt-BfXryFt-.js → prompt-BnDapYGL.js} +1 -1
  130. package/dist/chunks/prompt-D0TFER0A.js +1 -0
  131. package/dist/chunks/{protocolHandler-VigBkAQQ.js → protocolHandler-CJO3CRYW.js} +1 -1
  132. package/dist/chunks/{reconciler-B9XFdL4f.js → reconciler-C_HKsocm.js} +1 -1
  133. package/dist/chunks/{refresh-CBHbWTGg.js → refresh-Cm4jZzLa.js} +1 -1
  134. package/dist/chunks/{reject-CBxnwckZ.js → reject-Tug1RmkE.js} +1 -1
  135. package/dist/chunks/{reload-plugins-5eFWrQlL.js → reload-plugins-CL9LWzpq.js} +1 -1
  136. package/dist/chunks/{rename-Cw7cMerG.js → rename-OfKJSazJ.js} +1 -1
  137. package/dist/chunks/{resume-U2D0ybfU.js → resume-BZ42SpS2.js} +1 -1
  138. package/dist/chunks/{runtimeObserver-DOYlxx9H.js → runtimeObserver-BLq2guVy.js} +1 -1
  139. package/dist/chunks/{runtimeObserver-CWaYMJG8.js → runtimeObserver-DT5P2_XL.js} +2 -2
  140. package/dist/chunks/sandbox-adapter-982rx2cm.js +1 -0
  141. package/dist/chunks/{sandbox-toggle-BtiPyjT3.js → sandbox-toggle-DghmaJhK.js} +1 -1
  142. package/dist/chunks/searchExtraTools-B4N1bpy0.js +1 -0
  143. package/dist/chunks/{select-BuTJbu_Q.js → select-CaxQ-BVq.js} +1 -1
  144. package/dist/chunks/sessionFileAccessHooks-BqQ58T7e.js +1 -0
  145. package/dist/chunks/{sessionObserver-cfwD8pV8.js → sessionObserver-DBoZUvWL.js} +1 -1
  146. package/dist/chunks/sessionObserver-qYpA90El.js +1 -0
  147. package/dist/chunks/sessionStorage-CC0v4zMs.js +1 -0
  148. package/dist/chunks/{sessionTracing-DsdcOqvc.js → sessionTracing-5a7HDF4e.js} +1 -1
  149. package/dist/chunks/{setup-DR-KEmxL.js → setup-DVLnIlse.js} +2 -2
  150. package/dist/chunks/{shadowedRuleDetection-DiZUDzxU.js → shadowedRuleDetection-L3tnySui.js} +1 -1
  151. package/dist/chunks/{sideQuestion-CdgUarC2.js → sideQuestion-BJTVma-5.js} +1 -1
  152. package/dist/chunks/sinks-C9NdbjLo.js +1 -0
  153. package/dist/chunks/{sinks-Cy3NqVbk.js → sinks-CV0SWuZW.js} +1 -1
  154. package/dist/chunks/{skillChangeDetector-CVFCJcG7.js → skillChangeDetector-DlodgOyC.js} +1 -1
  155. package/dist/chunks/{skillGapStore-BJV8ZIB1.js → skillGapStore-Cposc03e.js} +2 -2
  156. package/dist/chunks/{skillLifecycle-iO_3s9Ff.js → skillLifecycle-RXQp0JU7.js} +2 -2
  157. package/dist/chunks/{skillSearchPanel-BL5gXTHU.js → skillSearchPanel-B2pjskqk.js} +2 -2
  158. package/dist/chunks/{skills-BEp3_RyT.js → skills-D2ZjMtv4.js} +1 -1
  159. package/dist/chunks/status-BcSkj9nE.js +1 -0
  160. package/dist/chunks/{statusNoticeHelpers-BoloSeXY.js → statusNoticeHelpers-DsrqBOQt.js} +1 -1
  161. package/dist/chunks/switcher-BietN6il.js +1 -0
  162. package/dist/chunks/{switcher-DSt2cVjA.js → switcher-rep86o4_.js} +1 -1
  163. package/dist/chunks/{tasks-DyBUXnQb.js → tasks-B4coTfrq.js} +1 -1
  164. package/dist/chunks/{templateJobs-BBnReWWj.js → templateJobs-C5ukh6H3.js} +1 -1
  165. package/dist/chunks/{terminalSetup-CDpFfqqV.js → terminalSetup-CaGbEVjB.js} +1 -1
  166. package/dist/chunks/{terminalSetup-DedaY1P7.js → terminalSetup-xe_P98fY.js} +1 -1
  167. package/dist/chunks/{theme-BZOy9Iqh.js → theme-7RmvErYJ.js} +1 -1
  168. package/dist/chunks/{tipRegistry-Cl5sdLRX.js → tipRegistry-BYpJZIjR.js} +1 -1
  169. package/dist/chunks/{toolEventObserver-ClwWmVbH.js → toolEventObserver-Dzwzi5Vi.js} +1 -1
  170. package/dist/chunks/{toolPool-DSTbgGmX.js → toolPool-BGfiNj6h.js} +1 -1
  171. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ClN4NJnB.js → useExitOnCtrlCDWithKeybindings-BT0nexZw.js} +1 -1
  172. package/dist/chunks/useMainLoopModel-QuE7VkgX.js +1 -0
  173. package/dist/chunks/{useManagePlugins-CxHz-gUP.js → useManagePlugins-pGaGzsEg.js} +1 -1
  174. package/dist/chunks/{useMergedTools-BUuWew0-.js → useMergedTools-BLsIT3R_.js} +1 -1
  175. package/dist/chunks/{useSearchInput-BIQN_-Hm.js → useSearchInput-j12K4wEo.js} +1 -1
  176. package/dist/chunks/{useSettingsErrors-BDJCLei_.js → useSettingsErrors-C8VIzdws.js} +1 -1
  177. package/dist/chunks/{util-BHr5l6Bx.js → util-CCEK8oze.js} +1 -1
  178. package/dist/chunks/{validatePlugin-fx1Y8vam.js → validatePlugin-CTVnWx9H.js} +1 -1
  179. package/dist/chunks/{vim-CYjMtnwH.js → vim-BlO9V5_5.js} +1 -1
  180. package/dist/chunks/worktree-BWL0vR4o.js +1 -0
  181. package/dist/chunks/wrapper-B-Q3Illb.js +1 -0
  182. package/dist/chunks/{wrapper-K8ZapJVu.js → wrapper-DVKxC5fR.js} +1 -1
  183. package/dist/cli.js +1 -1
  184. package/package.json +2 -1
  185. package/dist/chunks/AgentsMdExternalIncludesDialog-CgSethgo.js +0 -1
  186. package/dist/chunks/Doctor-CiZNe_qx.js +0 -1
  187. package/dist/chunks/REPL-BHk0vZDf.js +0 -1
  188. package/dist/chunks/SearchExtraToolsTool-CdWB9sO8.js +0 -1
  189. package/dist/chunks/backgroundHousekeeping-B56nFTzq.js +0 -1
  190. package/dist/chunks/caches-D7arwhaa.js +0 -1
  191. package/dist/chunks/commands-AcfFLgl5.js +0 -1
  192. package/dist/chunks/config-BhBcadjZ.js +0 -1
  193. package/dist/chunks/config-Bm5pVdCq.js +0 -1
  194. package/dist/chunks/context-noninteractive-BK2IDLSS.js +0 -1
  195. package/dist/chunks/conversation-B2dX3X4Z.js +0 -1
  196. package/dist/chunks/doctor-CQf8xPZH.js +0 -1
  197. package/dist/chunks/extractMemories-8yvMGZ1J.js +0 -1
  198. package/dist/chunks/fast-aNkj6WvB.js +0 -1
  199. package/dist/chunks/fetchModelList-D2quBF6M.js +0 -1
  200. package/dist/chunks/hooks-B5Wq-KxE.js +0 -1
  201. package/dist/chunks/loadAgentsDir-BBbIAiay.js +0 -1
  202. package/dist/chunks/localSearch-D6MhwvnR.js +0 -1
  203. package/dist/chunks/managedEnv-ulQBH73B.js +0 -1
  204. package/dist/chunks/pluginStartupCheck-Du9yx2P8.js +0 -1
  205. package/dist/chunks/prompt-BZmu5CeK.js +0 -1
  206. package/dist/chunks/prompt-Cogr_WZr.js +0 -1
  207. package/dist/chunks/sandbox-adapter-Df7Wpt77.js +0 -1
  208. package/dist/chunks/searchExtraTools-CbJVb_Zk.js +0 -1
  209. package/dist/chunks/sessionFileAccessHooks-_mxyfQmn.js +0 -1
  210. package/dist/chunks/sessionObserver-BZVgzp3W.js +0 -1
  211. package/dist/chunks/sessionStorage-SC5RfnUP.js +0 -1
  212. package/dist/chunks/sinks-D41OiGE4.js +0 -1
  213. package/dist/chunks/status-6JMz8jmM.js +0 -1
  214. package/dist/chunks/switcher-95d4TrQH.js +0 -1
  215. package/dist/chunks/useMainLoopModel-Bgxpmn2Q.js +0 -1
  216. package/dist/chunks/worktree-CGu_58ue.js +0 -1
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,t as r}from"./src-BX54x08P.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as a,kt as o}from"./state-CXY-q5gr.js";import{D as s,Mg as c,aw as l,b as u,cw as d,iw as f,kg as p}from"./loadAgentsDir-uuZYOgKn.js";import{a as m,i as h,r as g,t as _}from"./promptEditor-14TB3MYt.js";import{r as v,t as y}from"./staticRender-Bt82RvGc.js";function b({planContent:e,planPath:r,editorName:i}){return(0,S.jsxs)(t,{flexDirection:`column`,children:[(0,S.jsx)(n,{bold:!0,children:`Current Plan`}),(0,S.jsx)(n,{dimColor:!0,children:r}),(0,S.jsx)(t,{marginTop:1,children:(0,S.jsx)(n,{children:e})}),i&&(0,S.jsxs)(t,{marginTop:1,children:[(0,S.jsx)(n,{dimColor:!0,children:`"/plan open"`}),(0,S.jsx)(n,{dimColor:!0,children:` to edit this plan in `}),(0,S.jsx)(n,{bold:!0,dimColor:!0,children:i})]})]})}async function x(e,t,n){let{getAppState:r,setAppState:i}=t,a=r().toolPermissionContext.mode;if(a!==`plan`){o(a,`plan`),i(e=>({...e,toolPermissionContext:p(s(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=n.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let c=f(),u=l();if(!c)return e(`Already in plan mode. No plan written yet.`),null;if(n.trim().split(/\s+/)[0]===`open`){let t=await _(u);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${u}`),null}return e(await v((0,S.jsx)(b,{planContent:c,planPath:u,editorName:h()??void 0}))),null}var S;e((()=>{a(),r(),m(),c(),u(),d(),g(),y(),S=i()}))();export{x as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,t as r}from"./src-BX54x08P.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as a,kt as o}from"./state-CXY-q5gr.js";import{D as s,Mg as c,aw as l,b as u,cw as d,iw as f,kg as p}from"./loadAgentsDir-bmpKLPdG.js";import{a as m,i as h,r as g,t as _}from"./promptEditor-14TB3MYt.js";import{r as v,t as y}from"./staticRender-Bt82RvGc.js";function b({planContent:e,planPath:r,editorName:i}){return(0,S.jsxs)(t,{flexDirection:`column`,children:[(0,S.jsx)(n,{bold:!0,children:`Current Plan`}),(0,S.jsx)(n,{dimColor:!0,children:r}),(0,S.jsx)(t,{marginTop:1,children:(0,S.jsx)(n,{children:e})}),i&&(0,S.jsxs)(t,{marginTop:1,children:[(0,S.jsx)(n,{dimColor:!0,children:`"/plan open"`}),(0,S.jsx)(n,{dimColor:!0,children:` to edit this plan in `}),(0,S.jsx)(n,{bold:!0,dimColor:!0,children:i})]})]})}async function x(e,t,n){let{getAppState:r,setAppState:i}=t,a=r().toolPermissionContext.mode;if(a!==`plan`){o(a,`plan`),i(e=>({...e,toolPermissionContext:p(s(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=n.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let c=f(),u=l();if(!c)return e(`Already in plan mode. No plan written yet.`),null;if(n.trim().split(/\s+/)[0]===`open`){let t=await _(u);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${u}`),null}return e(await v((0,S.jsx)(b,{planContent:c,planPath:u,editorName:h()??void 0}))),null}var S;e((()=>{a(),r(),m(),c(),u(),d(),g(),y(),S=i()}))();export{x as call};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{D as o,Gr as s,Gt as c,H as l,I as u,P as d,T as f,Wt as p,Xn as m,ai as h,hn as g,j as _,k as v,n as y,ot as b,r as x,t as S,x as C,y as ee}from"./src-BX54x08P.js";import{t as w}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as T,Qn as te,d as ne,gt as E,m as D,s as O,y as k,yt as re}from"./settings-D4M13toi.js";import{$a as ie,$d as A,$m as j,Ao as ae,Ax as M,Ba as N,Bh as oe,Co as se,Cx as P,Do as ce,Eo as le,Fa as ue,Ga as F,Hh as I,Ka as de,Mo as fe,Mx as pe,No as me,Nx as he,Oo as ge,Pa as L,Qa as R,Qm as _e,So as ve,To as ye,Tx as be,Va as xe,Xd as Se,Xm as Ce,Ya as we,Ym as z,Zm as Te,_f as Ee,bu as De,do as B,eh as Oe,gf as ke,go as Ae,hd as je,io as Me,kx as Ne,lx as Pe,md as V,mo as Fe,nh as Ie,ox as Le,rh as Re,sb as ze,so as Be,tb as Ve,th as He,to as Ue,uo as We,ux as Ge,vo as Ke,wo as qe,yo as Je,yu as Ye,yx as Xe,zh as Ze}from"./loadAgentsDir-uuZYOgKn.js";import{I as Qe,M as $e,S as et,V as tt,c as nt,i as rt,x as it}from"./debug-2pVES-2G.js";import{d as at,g as ot}from"./config-BDn2YIjC.js";import{o as st,s as ct}from"./log-L1kqxa_P.js";import{n as lt}from"./analytics-COpjZpvd.js";import{S as ut,v as dt}from"./startupProfiler-B9Qv2QGH.js";import{l as H,o as ft}from"./stringUtils-Cs6E5f-B.js";import{n as pt,t as mt}from"./pluginStartupCheck-DftTiXct.js";import{a as ht,d as gt,f as _t,i as vt,l as yt,o as bt,s as xt,u as St}from"./pluginOperations-Ca_T-HYn.js";import{a as Ct,c as wt,i as Tt,n as Et,o as Dt,s as Ot,t as kt}from"./validatePlugin-fx1Y8vam.js";import{a as At,n as jt,o as Mt,r as Nt}from"./pluginFlagging-CUvkKGOB.js";import{i as Pt,n as Ft}from"./MCPConnectionManager-CBY8nqdU.js";import{n as It,t as Lt}from"./useExitOnCtrlCDWithKeybindings-ClN4NJnB.js";import{n as Rt,t as zt}from"./TextInput-ZKU-x_FD.js";import{r as Bt,t as Vt}from"./Spinner-DOI8qqZi.js";import{t as Ht}from"./SearchBox-zA5QwIpO.js";import{n as Ut,t as Wt}from"./useSearchInput-BIQN_-Hm.js";import{a as Gt,c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./MCPToolListView-C7HT6rrl.js";import{i as $t,n as en}from"./pluginAutoupdate-CNrHb4RJ.js";import*as tn from"path";import*as nn from"fs/promises";function rn({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:s,setResult:c,setViewState:l,onAddComplete:p,cliMode:m=!1}){let h=(0,an.useRef)(!1),[g,_]=(0,an.useState)(!1),[v,y]=(0,an.useState)(``),b=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ct(t);if(!n){a(`Invalid marketplace source format. Try: owner/repo, https://..., or ./path`);return}if(`error`in n){a(n.error);return}a(null);try{_(!0),y(``);let{name:e,resolvedSource:t}=await Me(n,e=>{y(e)});Ke(e,{source:t}),fe(),n.source,n.source===`github`&&n.repo,p&&await p(),y(``),_(!1),m?c(`Successfully added marketplace: ${e}`):l({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=tt(e);ct(t),a(t.message),y(``),_(!1),c(m?`Error: ${t.message}`:null)}};return(0,an.useEffect)(()=>{e&&!h.current&&!i&&!s&&(h.current=!0,b())},[]),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsxs)(u,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(u,{marginBottom:1,children:(0,U.jsx)(d,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsx)(d,{children:`Enter marketplace source:`}),(0,U.jsx)(d,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(d,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(d,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(d,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(d,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(zt,{value:e,onChange:t,onSubmit:b,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),g&&(0,U.jsxs)(u,{marginTop:1,children:[(0,U.jsx)(Vt,{}),(0,U.jsx)(d,{children:v||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{color:`error`,children:i})}),s&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{children:s})})]}),(0,U.jsx)(u,{marginLeft:3,children:(0,U.jsx)(d,{dimColor:!0,italic:!0,children:(0,U.jsxs)(f,{children:[(0,U.jsx)(o,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(V,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var an,U,on=e((()=>{an=t(h(),1),lt(),je(),S(),Bt(),Rt(),Qe(),st(),me(),We(),Tt(),U=w()}));function sn(e,t,r,i){let a={};for(let o of e){let e=r[o],s=t[o]??``;if(!(e?.sensitive===!0&&s===``&&i?.[o]!==void 0))if(e?.type===`number`){if(s.trim()===``)continue;let e=Number(s);a[o]=Number.isNaN(e)?s:e}else e?.type===`boolean`?a[o]=n(s):a[o]=s}return a}function cn({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let l=Object.keys(n),f=(0,ln.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[m,h]=(0,ln.useState)(0),[_,v]=(0,ln.useState)({}),[y,b]=(0,ln.useState)(()=>l[0]?f(l[0]):``),x=l[m],S=x?n[x]:null;if(p(`confirm:no`,o,{context:`Settings`}),c({"confirm:nextField":(0,ln.useCallback)(()=>{if(m<l.length-1&&x){v(e=>({...e,[x]:y})),h(e=>e+1);let e=l[m+1];b(e?f(e):``)}},[m,l,x,y,f]),"confirm:yes":(0,ln.useCallback)(()=>{if(!x)return;let e={..._,[x]:y};if(m===l.length-1)i(sn(l,e,n,r));else{v(e),h(e=>e+1);let t=l[m+1];b(t?f(t):``)}},[x,_,y,m,l,n,i,f,r])},{context:`Confirmation`}),g((e,t)=>{if(t.backspace||t.delete){b(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&b(t=>t+e)}),!S||!x)return null;let C=S.sensitive===!0,w=S.required===!0,T=C?`*`.repeat(s(y)):y;return(0,un.jsxs)(ee,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,un.jsxs)(u,{flexDirection:`column`,children:[(0,un.jsxs)(d,{bold:!0,children:[S.title||x,w&&(0,un.jsx)(d,{color:`error`,children:` *`})]}),S.description&&(0,un.jsx)(d,{dimColor:!0,children:S.description}),(0,un.jsxs)(u,{marginTop:1,children:[(0,un.jsxs)(d,{children:[a.pointerSmall,` `]}),(0,un.jsx)(d,{children:T}),(0,un.jsx)(d,{children:`█`})]})]}),(0,un.jsxs)(u,{flexDirection:`column`,children:[(0,un.jsxs)(d,{dimColor:!0,children:[`Field `,m+1,` of `,l.length]}),m<l.length-1&&(0,un.jsx)(d,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),m===l.length-1&&(0,un.jsx)(d,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var ln,un,dn=e((()=>{i(),ln=t(h(),1),S(),Ve(),r(),un=w()}));async function fn(e){let{enabled:t,disabled:n}=await ue();return[...t,...n].find(t=>t.repository===e||t.source===e)}function pn({plugin:e,pluginId:t,onDone:n}){let[r]=mn.useState(()=>{let n=[],r=z(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>Te(t),save:n=>_e(t,n,e.manifest.userConfig)});let i=ke(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>He(t,r.server)??void 0,save:e=>Re(t,r.server,e,r.configSchema)});return n}),[i,a]=mn.useState(0),o=mn.useRef(n);if(o.current=n,mn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function c(e){try{s.save(e)}catch(e){n(`error`,$e(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,hn.jsx)(cn,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:c,onCancel:()=>n(`skipped`)},s.key)}var mn,hn,gn=e((()=>{mn=t(h(),1),Qe(),j(),Ee(),L(),Ce(),dn(),hn=w()}));function _n(){let e=ce();return(0,vn.jsxs)(u,{marginBottom:1,children:[(0,vn.jsxs)(d,{color:`claude`,children:[a.warning,` `]}),(0,vn.jsxs)(d,{dimColor:!0,italic:!0,children:[`Make sure you trust a plugin before installing, updating, or using it. We do not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.`,e?` ${e}`:``]})]})}var vn,yn=e((()=>{i(),S(),ge(),vn=w()}));function bn(e){return e.entry.source&&typeof e.entry.source==`object`&&`source`in e.entry.source&&e.entry.source.source===`github`&&typeof e.entry.source==`object`&&`repo`in e.entry.source?e.entry.source.repo:null}function xn(e,t){let n=[{label:`Install for you (user scope)`,action:`install-user`},{label:`Install for all collaborators on this repository (project scope)`,action:`install-project`},{label:`Install for you, in this repo only (local scope)`,action:`install-local`}];return e&&n.push({label:`Open homepage`,action:`homepage`}),t&&n.push({label:`View on GitHub`,action:`github`}),n.push({label:`Back to plugin list`,action:`back`}),n}function Sn({hasSelection:e}){return(0,Cn.jsx)(u,{marginTop:1,children:(0,Cn.jsx)(d,{dimColor:!0,italic:!0,children:(0,Cn.jsxs)(f,{children:[e&&(0,Cn.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,Cn.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Cn.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Cn.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var Cn,wn=e((()=>{je(),S(),Cn=w()}));function Tn({totalItems:e,maxVisible:t=Dn,selectedIndex:n=0}){let r=e>t,i=(0,En.useRef)(0),a=(0,En.useMemo)(()=>{if(!r)return 0;let a=i.current;if(n<a)return i.current=n,n;if(n>=a+t){let e=n-t+1;return i.current=e,e}let o=Math.max(0,e-t),s=Math.min(a,o);return i.current=s,s},[n,t,r,e]),o=a,s=Math.min(a+t,e),c=(0,En.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,En.useCallback)(e=>o+e,[o]),u=(0,En.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,En.useCallback)(e=>{},[]),f=(0,En.useCallback)(()=>{},[]),p=(0,En.useCallback)(()=>{},[]),m=(0,En.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,En.useCallback)((e,t)=>!1,[]),g=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:g,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:p,handleSelectionChange:m,handlePageNavigation:h,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var En,Dn,On=e((()=>{En=t(h(),1),Dn=5}));function kn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:l}){let[m,h]=(0,W.useState)(`marketplace-list`),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)([]),[S,C]=(0,W.useState)([]),[ee,w]=(0,W.useState)(!0),[T,ne]=(0,W.useState)(null),[E,D]=(0,W.useState)(0),[O,k]=(0,W.useState)(new Set),[re,A]=(0,W.useState)(new Set),j=Tn({totalItems:S.length,selectedIndex:E}),[M,N]=(0,W.useState)(0),[oe,se]=(0,W.useState)(!1),[P,ce]=(0,W.useState)(null),[ue,F]=(0,W.useState)(null);p(`confirm:no`,An.useCallback(()=>{m===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):b.length===1?i({type:`menu`}):(h(`marketplace-list`),_(null),k(new Set)):m===`plugin-details`?(h(`plugin-list`),y(null)):i({type:`menu`})},[m,s,i,b.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await B(),{marketplaces:n,failures:r}=await ae(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=te(r.plugins,t=>ie(ve(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:le(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),x(i);let a=ye(r,te(n,e=>e.data!==null));if(a)if(a.type===`warning`)F(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!l){let e=i[0];e&&(_(e.name),h(`plugin-list`))}if(l){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await Be(t);if(e){let i=e.plugins.find(e=>e.name===l);if(i){let e=ve(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:R(e)},r=t;break}}}if(n&&r){let e=n.pluginId;R(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(_(r),y(n),h(`plugin-details`))}else t(`Plugin "${l}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(_(s),h(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{w(!1)}}e()},[t,s,l]),(0,W.useEffect)(()=>{if(!g)return;let e=!1;async function n(n){w(!0);try{let t=await Be(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=ve(e.name,n);de(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:R(t)})}try{let t=await Ot();if(e)return;ne(t),t?r.sort((e,n)=>{let r=t.get(e.pluginId)??0,i=t.get(n.pluginId)??0;return r===i?e.entry.name.localeCompare(n.entry.name):i-r}):r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(t){if(e)return;nt(`Failed to fetch install counts: ${$e(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}C(r),D(0),k(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{w(!1)}}return n(g),()=>{e=!0}},[g,t]);let I=async()=>{if(O.size===0)return;let e=S.filter(e=>O.has(e.pluginId));A(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await xe({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}A(new Set),k(new Set),fe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${qe(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${qe(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},pe=async(e,t=`user`)=>{se(!0),ce(null);let n=await xe({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await fn(e.pluginId);if(t){se(!1),h({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else se(!1),ce(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),c({"select:previous":()=>{E>0&&D(E-1)},"select:next":()=>{E<b.length-1&&D(E+1)},"select:accept":()=>{let e=b[E];e&&(_(e.name),h(`plugin-list`))}},{context:`Select`,isActive:m===`marketplace-list`}),c({"select:previous":()=>{E>0&&j.handleSelectionChange(E-1,D)},"select:next":()=>{E<S.length-1&&j.handleSelectionChange(E+1,D)},"select:accept":()=>{if(E===S.length&&O.size>0)I();else if(E<S.length){let e=S[E];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(y(e),h(`plugin-details`),N(0),ce(null)))}}},{context:`Select`,isActive:m===`plugin-list`}),c({"plugin:toggle":()=>{if(E<S.length){let e=S[E];if(e&&!e.isInstalled){let t=new Set(O);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),k(t)}}},"plugin:install":()=>{O.size>0&&I()}},{context:`Plugin`,isActive:m===`plugin-list`});let me=An.useMemo(()=>{if(!v)return[];let e=v.entry.homepage;return xn(e,bn(v))},[v]);if(c({"select:previous":()=>{M>0&&N(M-1)},"select:next":()=>{M<me.length-1&&N(M+1)},"select:accept":()=>{if(!v)return;let e=me[M]?.action,t=v.entry.homepage,n=bn(v);e===`install-user`?pe(v,`user`):e===`install-project`?pe(v,`project`):e===`install-local`?pe(v,`local`):e===`homepage`&&t?De(t):e===`github`&&n?De(`https://github.com/${n}`):e===`back`&&(h(`plugin-list`),y(null))}},{context:`Select`,isActive:m===`plugin-details`&&!!v}),typeof m==`object`&&m.type===`plugin-options`){let{plugin:e,pluginId:t}=m;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(pn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ee)return(0,G.jsx)(d,{children:`Loading…`});if(e)return(0,G.jsx)(d,{color:`error`,children:e});if(m===`marketplace-list`)return b.length===0?(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(d,{children:`No marketplaces configured.`}),(0,G.jsxs)(d,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),ue&&(0,G.jsx)(u,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(d,{color:`warning`,children:[a.warning,` `,ue]})}),b.map((e,t)=>(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:+(t<b.length-1),children:[(0,G.jsx)(u,{children:(0,G.jsxs)(d,{color:E===t?`suggestion`:void 0,children:[E===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(u,{marginLeft:2,children:(0,G.jsxs)(d,{dimColor:!0,children:[e.totalPlugins,` `,H(e.totalPlugins,`plugin`),` available`,e.installedCount>0&&` · ${e.installedCount} already installed`,e.source&&` · ${e.source}`]})})]},e.name)),(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(m===`plugin-details`&&v){let e=v.entry.homepage,t=xn(e,bn(v));return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:v.entry.name}),v.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[`Version: `,v.entry.version]}),v.entry.description&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{children:v.entry.description})}),v.entry.author&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof v.entry.author==`string`?v.entry.author:v.entry.author.name]})})]}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:`Will install:`}),v.entry.commands&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(v.entry.commands)?v.entry.commands.join(`, `):Object.keys(v.entry.commands).join(`, `)]}),v.entry.agents&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(v.entry.agents)?v.entry.agents.join(`, `):Object.keys(v.entry.agents).join(`, `)]}),v.entry.hooks&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Hooks: `,Object.keys(v.entry.hooks).join(`, `)]}),v.entry.mcpServers&&(0,G.jsxs)(d,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(v.entry.mcpServers)?v.entry.mcpServers.join(`, `):typeof v.entry.mcpServers==`object`?Object.keys(v.entry.mcpServers).join(`, `):`configured`]}),!v.entry.commands&&!v.entry.agents&&!v.entry.hooks&&!v.entry.mcpServers&&(typeof v.entry.source==`object`&&`source`in v.entry.source&&(v.entry.source.source===`github`||v.entry.source.source===`url`||v.entry.source.source===`npm`||v.entry.source.source===`pip`)?(0,G.jsx)(d,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(d,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(_n,{}),P&&(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsxs)(d,{color:`error`,children:[`Error: `,P]})}),(0,G.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(u,{children:[M===t&&(0,G.jsx)(d,{children:`> `}),M!==t&&(0,G.jsx)(d,{children:` `}),(0,G.jsx)(d,{bold:M===t,children:oe&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(S.length===0)return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(d,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(d,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(u,{marginLeft:3,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let he=j.getVisibleItems(S);return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install Plugins`})}),j.scrollPosition.canScrollUp&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),he.map((t,n)=>{let r=j.toActualIndex(n),i=E===r,o=O.has(t.pluginId),s=re.has(t.pluginId);return(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:n===he.length-1&&!e?0:1,children:[(0,G.jsxs)(u,{children:[(0,G.jsxs)(d,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(d,{color:t.isInstalled?`success`:void 0,children:[t.isInstalled?a.tick:s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,t.entry.category&&(0,G.jsxs)(d,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(d,{dimColor:!0,children:` (installed)`}),T&&g===`claude-plugins-official`&&(0,G.jsxs)(d,{dimColor:!0,children:[` · `,Dt(T.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(u,{marginLeft:4,children:[(0,G.jsx)(d,{dimColor:!0,children:ut(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),j.scrollPosition.canScrollDown&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Sn,{hasSelection:O.size>0})]})}var An,W,G,jn=e((()=>{i(),An=t(h(),1),W=t(h(),1),je(),S(),Ve(),T(),Ye(),rt(),Qe(),me(),wt(),we(),ge(),We(),Xe(),N(),F(),ft(),dt(),gn(),yn(),wn(),On(),G=w()}));function Mn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:l}){let[h,_]=(0,K.useState)(`plugin-list`),[y,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[ee,w]=(0,K.useState)(!0),[T,ne]=(0,K.useState)(null),[E,D]=(0,K.useState)(!1),O=(0,K.useCallback)(e=>{D(e),s?.(e)},[s]),{query:k,setQuery:re,cursorOffset:ie}=Ut({isActive:h===`plugin-list`&&E&&!ee,onExit:()=>{O(!1)}}),A=m(),{columns:j}=b(),M=(0,K.useMemo)(()=>{if(!k)return S;let e=k.toLowerCase();return S.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[S,k]),[N,oe]=(0,K.useState)(0),[P,ce]=(0,K.useState)(new Set),[le,ue]=(0,K.useState)(new Set),F=Tn({totalItems:M.length,selectedIndex:N});(0,K.useEffect)(()=>{oe(0)},[k]);let[I,pe]=(0,K.useState)(0),[me,he]=(0,K.useState)(!1),[ge,L]=(0,K.useState)(null),[_e,be]=(0,K.useState)(null),[Se,Ce]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await B(),{marketplaces:n,failures:r}=await ae(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=ve(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:R(t)})}let a=i.filter(e=>!e.isInstalled&&!de(e.pluginId));try{let e=await Ot();ne(e),e?a.sort((t,n)=>{let r=e.get(t.pluginId)??0,i=e.get(n.pluginId)??0;return r===i?t.entry.name.localeCompare(n.entry.name):i-r}):a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(e){nt(`Failed to fetch install counts: ${$e(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}C(a);let o=Object.keys(e).length;if(a.length===0){let e=await se({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});Ce(e)}let s=ye(r,te(n,e=>e.data!==null));if(s)if(s.type===`warning`)be(`${s.message}. Showing available plugins.`);else throw Error(s.message);if(l){let e=i.find(e=>e.entry.name===l);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(x(e),_(`plugin-details`)):t(`Plugin "${l}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{w(!1)}}e()},[t,l]);let we=async()=>{if(P.size===0)return;let e=S.filter(e=>P.has(e.pluginId));ue(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await xe({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ue(new Set),ce(new Set),fe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${qe(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${qe(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},z=async(e,t=`user`)=>{he(!0),L(null);let n=await xe({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await fn(e.pluginId);if(t){he(!1),_({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else he(!1),L(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),p(`confirm:no`,()=>{_(`plugin-list`),x(null)},{context:`Confirmation`,isActive:h===`plugin-details`}),p(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:h===`plugin-list`&&!E}),g((e,t)=>{let n=!t.ctrl&&!t.meta;E||(e===`/`&&n?(O(!0),re(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(O(!0),re(e)))},{isActive:h===`plugin-list`&&!ee}),c({"select:previous":()=>{N===0?O(!0):F.handleSelectionChange(N-1,oe)},"select:next":()=>{N<M.length-1&&F.handleSelectionChange(N+1,oe)},"select:accept":()=>{if(N===M.length&&P.size>0)we();else if(N<M.length){let e=M[N];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(x(e),_(`plugin-details`),pe(0),L(null)))}}},{context:`Select`,isActive:h===`plugin-list`&&!E}),c({"plugin:toggle":()=>{if(N<M.length){let e=M[N];if(e&&!e.isInstalled){let t=new Set(P);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ce(t)}}},"plugin:install":()=>{P.size>0&&we()}},{context:`Plugin`,isActive:h===`plugin-list`&&!E});let Te=Fn.useMemo(()=>{if(!y)return[];let e=y.entry.homepage;return xn(e,bn(y))},[y]);if(c({"select:previous":()=>{I>0&&pe(I-1)},"select:next":()=>{I<Te.length-1&&pe(I+1)},"select:accept":()=>{if(!y)return;let e=Te[I]?.action,t=y.entry.homepage,n=bn(y);e===`install-user`?z(y,`user`):e===`install-project`?z(y,`project`):e===`install-local`?z(y,`local`):e===`homepage`&&t?De(t):e===`github`&&n?De(`https://github.com/${n}`):e===`back`&&(_(`plugin-list`),x(null))}},{context:`Select`,isActive:h===`plugin-details`&&!!y}),typeof h==`object`&&h.type===`plugin-options`){let{plugin:e,pluginId:t}=h;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(pn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ee)return(0,q.jsx)(d,{children:`Loading…`});if(e)return(0,q.jsx)(d,{color:`error`,children:e});if(h===`plugin-details`&&y){let e=y.entry.homepage,t=xn(e,bn(y));return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(d,{bold:!0,children:y.entry.name}),(0,q.jsxs)(d,{dimColor:!0,children:[`from `,y.marketplaceName]}),y.entry.version&&(0,q.jsxs)(d,{dimColor:!0,children:[`Version: `,y.entry.version]}),y.entry.description&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{children:y.entry.description})}),y.entry.author&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof y.entry.author==`string`?y.entry.author:y.entry.author.name]})})]}),(0,q.jsx)(_n,{}),ge&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`error`,children:[`Error: `,ge]})}),(0,q.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(u,{children:[I===t&&(0,q.jsx)(d,{children:`> `}),I!==t&&(0,q.jsx)(d,{children:` `}),(0,q.jsx)(d,{bold:I===t,children:me&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,children:(0,q.jsxs)(f,{children:[(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(S.length===0)return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Pn,{reason:Se}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let Ee=F.getVisibleItems(M);return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsxs)(u,{children:[(0,q.jsx)(d,{bold:!0,children:`Discover plugins`}),F.needsPagination&&(0,q.jsxs)(d,{dimColor:!0,children:[` `,`(`,F.scrollPosition.current,`/`,F.scrollPosition.total,`)`]})]}),(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(v,{query:k,isFocused:E,isTerminalFocused:A,width:j-4,cursorOffset:ie})}),_e&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`warning`,children:[a.warning,` `,_e]})}),M.length===0&&k&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`No plugins match "`,k,`"`]})}),F.scrollPosition.canScrollUp&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Ee.map((t,n)=>{let r=F.toActualIndex(n),i=N===r,o=P.has(t.pluginId),s=le.has(t.pluginId);return(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:n===Ee.length-1&&!e?0:1,children:[(0,q.jsxs)(u,{children:[(0,q.jsxs)(d,{color:i&&!E?`suggestion`:void 0,children:[i&&!E?a.pointer:` `,` `]}),(0,q.jsxs)(d,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(d,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),T&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(d,{dimColor:!0,children:[` · `,Dt(T.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(u,{marginLeft:4,children:(0,q.jsx)(d,{dimColor:!0,children:ut(t.entry.description,60)})})]},`${F.startIndex}-${t.pluginId}`)}),F.scrollPosition.canScrollDown&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Nn,{hasSelection:P.size>0,canToggle:N<M.length&&!M[N]?.isInstalled})]})}function Nn({hasSelection:e,canToggle:t}){return(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:(0,q.jsxs)(f,{children:[e&&(0,q.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(d,{children:`type to search`}),t&&(0,q.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Pn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Please install git and restart Work Mate.`})]});case`all-blocked-by-policy`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(d,{dimColor:!0,children:`Switch to the Marketplaces tab to view allowed sources.`})]});case`all-marketplaces-failed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(d,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var Fn,K,q,In=e((()=>{i(),Fn=t(h(),1),K=t(h(),1),je(),Ht(),S(),Wt(),ze(),Ve(),T(),Ye(),rt(),Qe(),me(),wt(),we(),ge(),We(),Xe(),N(),F(),ft(),dt(),gn(),yn(),wn(),On(),q=w()}));function Ln({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:l}){let[m,h]=(0,zn.useState)([]),[_,v]=(0,zn.useState)(!0),[y,b]=(0,zn.useState)(0),[x,S]=(0,zn.useState)(!1),[C,ee]=(0,zn.useState)(null),[w,T]=(0,zn.useState)(null),[ne,E]=(0,zn.useState)(null),[D,ie]=(0,zn.useState)(`list`),[A,j]=(0,zn.useState)(null),[M,N]=(0,zn.useState)(0),oe=(0,zn.useRef)(!1);(0,zn.useEffect)(()=>{async function e(){try{let e=await B(),{enabled:r,disabled:i}=await ue(),a=[...r,...i],{marketplaces:o,failures:c}=await ae(e),u=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));u.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:re(e,t)})}u.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),h(u);let d=ye(c,te(o,e=>e.data!==null));if(d)if(d.type===`warning`)ee(d.message);else throw Error(d.message);if(s&&!oe.current&&!t){oe.current=!0;let e=u.findIndex(e=>e.name===s);if(e>=0){let t=u[e];if(l){b(e+1);let t=[...u];l===`update`?t[e].pendingUpdate=!0:l===`remove`&&(t[e].pendingRemove=!0),h(t),setTimeout(ce,100,t)}else t&&(b(e+1),j(t),ie(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),ee(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{v(!1)}}e()},[s,l,t]);let se=()=>m.some(e=>e.pendingUpdate||e.pendingRemove),P=()=>({updateCount:te(m,e=>e.pendingUpdate),removeCount:te(m,e=>e.pendingRemove)}),ce=async t=>{let i=t||m,s=D===`details`;S(!0),ee(null),T(null),E(null);try{let t=O(`userSettings`),n=0,c=0,l=new Set;for(let e of i){if(e.pendingRemove){if(e.installedPlugins&&e.installedPlugins.length>0){let n={...t?.enabledPlugins};for(let t of e.installedPlugins){let r=ve(t.name,e.name);n[r]=!1}k(`userSettings`,{enabledPlugins:n})}await Ae(e.name),c++,e.name,e.installedPlugins?.length;continue}e.pendingUpdate&&(await Fe(e.name,e=>{E(e)}),n++,l.add(e.name.toLowerCase()),e.name)}let u=0;l.size>0&&(u=(await $t(l)).length),fe(),o&&await o();let d=await B(),{enabled:f,disabled:p}=await ue(),m=[...f,...p],{marketplaces:g}=await ae(d),_=[];for(let{name:e,config:t,data:n}of g){let r=m.filter(t=>t.source.endsWith(`@${e}`));_.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:re(e,t)})}if(_.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),h(_),s&&A){let e=_.find(e=>e.name===A.name);e&&j(e)}let v=[];if(n>0){let e=u>0?` (${u} ${H(u,`plugin`)} bumped)`:``;v.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&v.push(`Removed ${c} ${H(c,`marketplace`)}`),v.length>0){let t=`${a.tick} ${v.join(`, `)}`;s?T(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=$e(e);ee(t),n&&n(t)}finally{S(!1),E(null)}},F=async()=>{if(!A)return;let e=m.map(e=>e.name===A.name?{...e,pendingRemove:!0}:e);h(e),await ce(e)},I=e=>{if(!e)return[];let t=[{label:`Browse plugins (${e.pluginCount??0})`,value:`browse`},{label:`Update marketplace`,secondaryLabel:e.lastUpdated?`(last updated ${new Date(e.lastUpdated).toLocaleDateString()})`:void 0,value:`update`}];return ot()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},de=async e=>{let t=!e.autoUpdate;try{await Je(e.name,t),h(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),j(e=>e&&{...e,autoUpdate:t})}catch(e){ee(e instanceof Error?e.message:`Failed to update setting`)}};if(p(`confirm:no`,()=>{ie(`list`),N(0)},{context:`Confirmation`,isActive:!x&&(D===`details`||D===`confirm-remove`)}),p(`confirm:no`,()=>{h(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),b(0)},{context:`Confirmation`,isActive:!x&&D===`list`&&se()}),p(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!x&&D===`list`&&!se()}),c({"select:previous":()=>b(e=>Math.max(0,e-1)),"select:next":()=>{let e=m.length+1;b(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=y-1;if(y===0)e({type:`add-marketplace`});else if(se())ce();else{let e=m[t];e&&(j(e),ie(`details`),N(0))}}},{context:`Select`,isActive:!x&&D===`list`}),g(e=>{let t=y-1;if((e===`u`||e===`U`)&&t>=0)h(e=>e.map((e,n)=>n===t?{...e,pendingUpdate:!e.pendingUpdate,pendingRemove:e.pendingUpdate?e.pendingRemove:!1}:e));else if((e===`r`||e===`R`)&&t>=0){let e=m[t];e&&(j(e),ie(`confirm-remove`))}},{isActive:!x&&D===`list`}),c({"select:previous":()=>N(e=>Math.max(0,e-1)),"select:next":()=>{let e=I(A);N(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!A)return;let t=I(A)[M];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:A.name});else if(t?.value===`update`){let e=m.map(e=>e.name===A.name?{...e,pendingUpdate:!0}:e);h(e),ce(e)}else t?.value===`toggle-auto-update`?de(A):t?.value===`remove`&&ie(`confirm-remove`)}},{context:`Select`,isActive:!x&&D===`details`}),g(e=>{e===`y`||e===`Y`?F():(e===`n`||e===`N`)&&(ie(`list`),j(null))},{isActive:!x&&D===`confirm-remove`}),_)return(0,J.jsx)(d,{children:`Loading marketplaces…`});if(m.length===0)return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(d,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(D===`confirm-remove`&&A){let e=A.installedPlugins?.length||0;return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsxs)(d,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(d,{italic:!0,children:A.name}),`?`]}),(0,J.jsxs)(u,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),A.installedPlugins&&A.installedPlugins.length>0&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,marginLeft:2,children:A.installedPlugins.map(e=>(0,J.jsxs)(d,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[`Press `,(0,J.jsx)(d,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(d,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(D===`details`&&A){let e=A.pendingUpdate||x,t=I(A);return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{bold:!0,children:A.name}),(0,J.jsx)(d,{dimColor:!0,children:A.source}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[A.pluginCount||0,` available `,H(A.pluginCount||0,`plugin`)]})}),A.installedPlugins&&A.installedPlugins.length>0&&(0,J.jsxs)(u,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(d,{bold:!0,children:[`Installed plugins (`,A.installedPlugins.length,`):`]}),(0,J.jsx)(u,{flexDirection:`column`,marginLeft:1,children:A.installedPlugins.map(e=>(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(d,{children:a.bullet}),(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{children:e.name}),(0,J.jsx)(d,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(d,{color:`claude`,children:`Updating marketplace…`}),ne&&(0,J.jsx)(d,{dimColor:!0,children:ne})]}),!e&&w&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:w})}),!e&&C&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:C})}),!e&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===M;return(0,J.jsxs)(u,{children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(d,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!ot()&&A.autoUpdate&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:pe,removeCount:me}=P();return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:y===0?`suggestion`:void 0,children:[y===0?a.pointer:` `,` +`]}),(0,J.jsx)(d,{bold:!0,color:y===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(u,{flexDirection:`column`,children:m.map((e,t)=>{let n=t+1===y,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(u,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(d,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(d,{dimColor:!0,children:e.source}),(0,J.jsxs)(d,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),se()&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(d,{children:[(0,J.jsx)(d,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(d,{dimColor:!0,children:`Enter to apply`})]}),pe>0&&(0,J.jsxs)(d,{children:[`• Update `,pe,` `,H(pe,`marketplace`)]}),me>0&&(0,J.jsxs)(d,{color:`warning`,children:[`• Remove `,me,` `,H(me,`marketplace`)]})]}),x&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:`Processing changes…`})}),C&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:C})}),(0,J.jsx)(Rn,{exitState:i,hasPendingActions:se()})]})}function Rn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:(0,J.jsxs)(f,{children:[t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(o,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(o,{shortcut:`r`,action:`remove`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var zn,J,Bn=e((()=>{i(),zn=t(h(),1),lt(),je(),S(),Ve(),T(),at(),Qe(),me(),ge(),We(),en(),L(),E(),D(),ft(),J=w()}));function Vn(e){switch(e.type){case`path-not-found`:return`${e.component} path not found: ${e.path}`;case`git-auth-failed`:return`Git ${e.authType.toUpperCase()} authentication failed for ${e.gitUrl}`;case`git-timeout`:return`Git ${e.operation} timed out for ${e.gitUrl}`;case`network-error`:return`Network error accessing ${e.url}${e.details?`: ${e.details}`:``}`;case`manifest-parse-error`:return`Failed to parse manifest at ${e.manifestPath}: ${e.parseError}`;case`manifest-validation-error`:return`Invalid manifest at ${e.manifestPath}: ${e.validationErrors.join(`, `)}`;case`plugin-not-found`:return`Plugin "${e.pluginId}" not found in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return`Marketplace "${e.marketplace}" not found`;case`marketplace-load-failed`:return`Failed to load marketplace "${e.marketplace}": ${e.reason}`;case`mcp-config-invalid`:return`Invalid MCP server config for "${e.serverName}": ${e.validationError}`;case`mcp-server-suppressed-duplicate`:{let t=e.duplicateOf.startsWith(`plugin:`)?`server provided by plugin "${e.duplicateOf.split(`:`)[1]??`?`}"`:`already-configured "${e.duplicateOf}"`;return`MCP server "${e.serverName}" skipped — same command/URL as ${t}`}case`hook-load-failed`:return`Failed to load hooks from ${e.hookPath}: ${e.reason}`;case`component-load-failed`:return`Failed to load ${e.component} from ${e.path}: ${e.reason}`;case`mcpb-download-failed`:return`Failed to download MCPB from ${e.url}: ${e.reason}`;case`mcpb-extract-failed`:return`Failed to extract MCPB ${e.mcpbPath}: ${e.reason}`;case`mcpb-invalid-manifest`:return`MCPB manifest invalid at ${e.mcpbPath}: ${e.validationError}`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`Marketplace "${e.marketplace}" is blocked by enterprise policy`:`Marketplace "${e.marketplace}" is not in the allowed marketplace list`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Dependency "${e.dependency}" is disabled`:`Dependency "${e.dependency}" is not installed`;case`lsp-config-invalid`:return`Invalid LSP server config for "${e.serverName}": ${e.validationError}`;case`lsp-server-start-failed`:return`LSP server "${e.serverName}" failed to start: ${e.reason}`;case`lsp-server-crashed`:return e.signal?`LSP server "${e.serverName}" crashed with signal ${e.signal}`:`LSP server "${e.serverName}" crashed with exit code ${e.exitCode??`unknown`}`;case`lsp-request-timeout`:return`LSP server "${e.serverName}" timed out on ${e.method} after ${e.timeoutMs}ms`;case`lsp-request-failed`:return`LSP server "${e.serverName}" ${e.method} failed: ${e.error}`;case`plugin-cache-miss`:return`Plugin "${e.plugin}" not cached at ${e.installPath}`;case`generic-error`:return e.error}return pe(e)}function Hn(e){switch(e.type){case`path-not-found`:return`Check that the path in your manifest or marketplace config is correct`;case`git-auth-failed`:return e.authType===`ssh`?`Configure SSH keys or use HTTPS URL instead`:`Configure credentials or use SSH URL instead`;case`git-timeout`:case`network-error`:return`Check your internet connection and try again`;case`manifest-parse-error`:return`Check manifest file syntax in the plugin directory`;case`manifest-validation-error`:return`Check manifest file follows the required schema`;case`plugin-not-found`:return`Plugin may not exist in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return e.availableMarketplaces.length>0?`Available marketplaces: ${e.availableMarketplaces.join(`, `)}`:`Add the marketplace first using /plugin marketplace add`;case`mcp-config-invalid`:return`Check MCP server configuration in .mcp.json or manifest`;case`mcp-server-suppressed-duplicate`:return e.duplicateOf.startsWith(`plugin:`)?`Disable plugin "${e.duplicateOf.split(`:`)[1]??`the other plugin`}" if you want this plugin's version instead`:`Remove "${e.duplicateOf}" from your MCP config if you want the plugin's version instead`;case`hook-load-failed`:return`Check hooks.json file syntax and structure`;case`component-load-failed`:return`Check ${e.component} directory structure and file permissions`;case`mcpb-download-failed`:return`Check your internet connection and URL accessibility`;case`mcpb-extract-failed`:return`Verify the MCPB file is valid and not corrupted`;case`mcpb-invalid-manifest`:return`Contact the plugin author about the invalid manifest`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`This marketplace source is explicitly blocked by your administrator`:e.allowedSources.length>0?`Allowed sources: ${e.allowedSources.join(`, `)}`:`Contact your administrator to configure allowed marketplace sources`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Enable "${e.dependency}" or uninstall "${e.plugin}"`:`Install "${e.dependency}" or uninstall "${e.plugin}"`;case`lsp-config-invalid`:return`Check LSP server configuration in the plugin manifest`;case`lsp-server-start-failed`:case`lsp-server-crashed`:case`lsp-request-timeout`:case`lsp-request-failed`:return`Check LSP server logs with --debug for details`;case`plugin-cache-miss`:return`Run /plugins to refresh the plugin cache`;case`marketplace-load-failed`:case`generic-error`:return null}return null}var Un=e((()=>{he()}));function Wn({item:e,isSelected:t}){let[n]=l();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=_(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=_(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=_(`success`,n)(a.tick),i=`enabled`):(r=_(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=_(`warning`,n)(a.warning);return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=_(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=_(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=_(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=_(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=_(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=_(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{dimColor:!t,children:`└ `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]}):(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}var Y,Gn=e((()=>{i(),S(),ft(),Y=w()}));async function Kn(e){try{return(await nn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>tn.basename(e.name,`.md`))}catch(t){return nt(`Failed to read plugin components from ${e}: ${$e(t)}`,{level:`error`}),ct(tt(t)),[]}}async function qn(e){try{let t=await nn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=tn.join(e,r.name,`SKILL.md`);try{(await nn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return nt(`Failed to read skill directories from ${e}: ${$e(t)}`,{level:`error`}),ct(tt(t)),[]}}function Jn({plugin:e,marketplace:t}){let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(null);return(0,X.useEffect)(()=>{async function n(){try{if(t===`builtin`){let t=Ne(e.name);if(t){let e=t.skills?.map(e=>e.name)??[],n=t.hooks?Object.keys(t.hooks):[],i=t.mcpServers?Object.keys(t.mcpServers):[];r({commands:null,agents:null,skills:e.length>0?e:null,hooks:n.length>0?n:null,mcpServers:i.length>0?i:null})}else s(`Built-in plugin ${e.name} not found`);a(!1);return}let n=(await Be(t)).plugins.find(t=>t.name===e.name);if(n){let t=[];e.commandsPath&&t.push(e.commandsPath),e.commandsPaths&&t.push(...e.commandsPaths);let i=[];for(let e of t)if(typeof e==`string`){let t=await Kn(e);i.push(...t)}let a=[];e.agentsPath&&a.push(e.agentsPath),e.agentsPaths&&a.push(...e.agentsPaths);let o=[];for(let e of a)if(typeof e==`string`){let t=await Kn(e);o.push(...t)}let s=[];e.skillsPath&&s.push(e.skillsPath),e.skillsPaths&&s.push(...e.skillsPaths);let c=[];for(let e of s)if(typeof e==`string`){let t=await qn(e);c.push(...t)}let l=[];e.hooksConfig&&l.push(Object.keys(e.hooksConfig)),n.hooks&&l.push(n.hooks);let u=[];e.mcpServers&&u.push(Object.keys(e.mcpServers)),n.mcpServers&&u.push(n.mcpServers),r({commands:i.length>0?i:null,agents:o.length>0?o:null,skills:c.length>0?c:null,hooks:l.length>0?l:null,mcpServers:u.length>0?u:null})}else s(`Plugin ${e.name} not found in marketplace`)}catch(e){s(e instanceof Error?e.message:`Failed to load components`)}finally{a(!1)}}n()},[e.name,e.commandsPath,e.commandsPaths,e.agentsPath,e.agentsPaths,e.skillsPath,e.skillsPaths,e.hooksConfig,e.mcpServers,t]),i?null:o?(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Components:`}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Commands:`,` `,typeof n.commands==`string`?n.commands:Array.isArray(n.commands)?n.commands.join(`, `):Object.keys(n.commands).join(`, `)]}):null,n.agents?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Agents:`,` `,typeof n.agents==`string`?n.agents:Array.isArray(n.agents)?n.agents.join(`, `):Object.keys(n.agents).join(`, `)]}):null,n.skills?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Skills:`,` `,typeof n.skills==`string`?n.skills:Array.isArray(n.skills)?n.skills.join(`, `):Object.keys(n.skills).join(`, `)]}):null,n.hooks?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Hooks:`,` `,typeof n.hooks==`string`?n.hooks:Array.isArray(n.hooks)?n.hooks.map(String).join(`, `):typeof n.hooks==`object`&&n.hooks!==null?Object.keys(n.hooks).join(`, `):String(n.hooks)]}):null,n.mcpServers?(0,Z.jsxs)(d,{dimColor:!0,children:[`• MCP Servers:`,` `,typeof n.mcpServers==`string`?n.mcpServers:Array.isArray(n.mcpServers)?n.mcpServers.map(String).join(`, `):typeof n.mcpServers==`object`&&n.mcpServers!==null?Object.keys(n.mcpServers).join(`, `):String(n.mcpServers)]}):null]})}async function Yn(e,t){let n=(await Be(t))?.plugins.find(t=>t.name===e);return n&&typeof n.source==`string`?`Local plugins cannot be updated remotely. To update, modify the source at: ${n.source}`:null}function Xn(e){return e.filter(e=>{let t=e.source.split(`@`)[1]||`local`;return!de(`${e.name}@${t}`)})}function Zn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=oe(e=>e.mcp.clients),h=oe(e=>e.mcp.tools),_=oe(e=>e.plugins.errors),y=jt(),[x,S]=(0,X.useState)(!1),C=(0,X.useCallback)(e=>{S(e),r?.(e)},[r]),ee=m(),{columns:w}=b(),[T,E]=(0,X.useState)(`plugin-list`),{query:D,setQuery:re,cursorOffset:ie}=Ut({isActive:T===`plugin-list`&&x,onExit:()=>{C(!1)}}),[A,j]=(0,X.useState)(null),[ae,M]=(0,X.useState)([]),[N,se]=(0,X.useState)([]),[P,ce]=(0,X.useState)(!0),[le,F]=(0,X.useState)(new Map),I=(0,X.useRef)(!1),de=(0,X.useRef)(void 0),pe=Pt();p(`confirm:no`,Qn.useCallback(()=>{if(T===`plugin-details`)E(`plugin-list`),j(null),B(null);else if(typeof T==`object`&&T.type===`failed-plugin-details`)E(`plugin-list`),B(null);else if(T===`configuring`)E(`plugin-details`),Ae(null);else if(typeof T==`object`&&(T.type===`plugin-options`||T.type===`configuring-options`))E(`plugin-list`),j(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof T==`object`&&T.type===`flagged-detail`)E(`plugin-list`),B(null);else if(typeof T==`object`&&T.type===`mcp-detail`)E(`plugin-list`),B(null);else if(typeof T==`object`&&T.type===`mcp-tools`)E({type:`mcp-detail`,client:T.client});else if(typeof T==`object`&&T.type===`mcp-tool-detail`)E({type:`mcp-tools`,client:T.client});else{if(le.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[T,e,le,t]),{context:`Confirmation`,isActive:(T!==`plugin-list`||!x)&&T!==`confirm-project-uninstall`&&!(typeof T==`object`&&T.type===`confirm-data-cleanup`)});let me=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,he=(0,X.useMemo)(()=>{let e=ne(),t=new Map;for(let e of l)if(e.name.startsWith(`plugin:`)){let n=e.name.split(`:`);if(n.length>=3){let r=n[1],i=n.slice(2).join(`:`),a=t.get(r)||[];a.push({displayName:i,client:e}),t.set(r,a)}}let n=[];for(let r of N){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=_.filter(e=>`plugin`in e&&e.plugin===r.plugin.name||e.source===i||e.source.startsWith(`${r.plugin.name}@`)),s=r.plugin.isBuiltin?`builtin`:r.scope||`user`;n.push({item:{type:`plugin`,id:i,name:r.plugin.name,description:r.plugin.manifest.description,marketplace:r.marketplace,scope:s,isEnabled:a,errorCount:o.length,errors:o,plugin:r.plugin,pendingEnable:r.pendingEnable,pendingUpdate:r.pendingUpdate,pendingToggle:le.get(i)},originalScope:s,childMcps:t.get(r.plugin.name)||[]})}let r=new Set(n.map(({item:e})=>e.id)),i=new Set(n.map(({item:e})=>e.name)),a=new Map;for(let e of _){if(r.has(e.source)||`plugin`in e&&typeof e.plugin==`string`&&i.has(e.plugin))continue;let t=a.get(e.source)||[];t.push(e),a.set(e.source,t)}let o=mt(),s=[];for(let[e,t]of a){if(e in y)continue;let n=be(e),r=n.name||e,i=n.marketplace||`unknown`,a=o.get(e),c=a===`flag`||a===void 0?`user`:a;s.push({type:`failed-plugin`,id:e,name:r,marketplace:i,scope:c,errorCount:t.length,errors:t})}let c=[];for(let e of l)e.name!==`ide`&&(e.name.startsWith(`plugin:`)||c.push({type:`mcp`,id:`mcp:${e.name}`,name:e.name,description:void 0,scope:e.config.scope,status:me(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},d=[],f=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;f.has(n)||f.set(n,[]),f.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;f.has(r)||f.set(r,[]),f.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:me(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let e of s){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let[e,t]of Object.entries(y)){let n=be(e),r=n.name||e,i=n.marketplace||`unknown`;f.has(`flagged`)||f.set(`flagged`,[]),f.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let p=[...f.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of p){let t=f.get(e),n=[],r=[],i=0;for(;i<t.length;){let e=t[i];if(e.type===`plugin`||e.type===`failed-plugin`||e.type===`flagged-plugin`){let r=[e];i++;let a=t[i];for(;a?.type===`mcp`&&a.indented;)r.push(a),i++,a=t[i];n.push(r)}else e.type===`mcp`&&!e.indented&&r.push(e),i++}n.sort((e,t)=>e[0].name.localeCompare(t[0].name)),r.sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)d.push(...e);d.push(...r)}return d},[N,l,_,le,y]),ge=(0,X.useMemo)(()=>he.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[he]);(0,X.useEffect)(()=>{ge.length>0&&At(ge)},[ge]);let L=(0,X.useMemo)(()=>{if(!D)return he;let e=D.toLowerCase();return he.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[he,D]),[R,ve]=(0,X.useState)(0),ye=Tn({totalItems:L.length,selectedIndex:R,maxVisible:8}),[xe,Ce]=(0,X.useState)(0),[we,z]=(0,X.useState)(!1),[Ee,B]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[je,Me]=(0,X.useState)(!1),[Ne,Pe]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!A){Pe(!1);return}async function e(){let e=A.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&Oe(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Oe(e))),!t)try{let e=tn.join(A.plugin.path,`..`),n=tn.join(e,`.claude-plugin`,`marketplace.json`),r=et(await nn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===A.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&Oe(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Oe(e))}}catch(e){nt(`Failed to read raw marketplace.json: ${e}`)}Pe(t)}e()},[A]),(0,X.useEffect)(()=>{async function e(){ce(!0);try{let{enabled:e,disabled:t}=await ue(),n=ne(),r=Xn([...e,...t]),i={};for(let e of r){let t=e.source.split(`@`)[1]||`local`;i[t]||(i[t]=[]),i[t].push(e)}let a=[];for(let[e,t]of Object.entries(i)){let r=te(t,t=>{let r=`${t.name}@${e}`;return n?.enabledPlugins?.[r]!==!1}),i=t.length-r;a.push({name:e,installedPlugins:t,enabledCount:r,disabledCount:i})}a.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),M(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:bt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}se(o),ve(0)}finally{ce(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!I.current&&i&&ae.length>0&&!P){let{name:e,marketplace:n}=be(i),r=o??n,a=r?ae.filter(e=>e.name===r):ae;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=bt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};j(r),E(`plugin-details`),de.current=s,I.current=!0;return}}let c=he.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(E({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),I.current=!0),!I.current&&s&&(I.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,ae,P,he,s,t]);let Fe=async r=>{if(!A)return;let i=A.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){B(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!yt(i)&&r!==`update`){B(`This plugin is managed by your organization. Contact your admin to disable it.`);return}z(!0),B(null);try{let o=`${A.plugin.name}@${A.marketplace}`,s;switch(r){case`enable`:{let e=await ht(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await vt(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!yt(i))break;if(St(o)){z(!1),E(`confirm-project-uninstall`);return}let e=Ue().plugins[o],t=!e||e.length<=1?await Le(o):null;if(t){z(!1),E({type:`confirm-data-cleanup`,size:t});return}let n=await gt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await _t(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${A.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}fe();let c=`${A.plugin.name}@${A.marketplace}`;if(ne()?.enabledPlugins?.[c]!==!1){z(!1),E({type:`plugin-options`});return}let l=r===`enable`?`Enabled`:r===`disable`?`Disabled`:r===`update`?`Updated`:`Uninstalled`,u=s&&s.length>0?` · required by ${s.join(`, `)}`:``;t(`✓ ${l} ${A.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){z(!1);let t=e instanceof Error?e.message:String(e);B(`Failed to ${r}: ${t}`),ct(tt(e))}},Re=(0,X.useRef)(Fe);Re.current=Fe,(0,X.useEffect)(()=>{if(T===`plugin-details`&&A&&de.current){let e=de.current;de.current=void 0,Re.current(e)}},[T,A]);let ze=Qn.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=ne(),r=le.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||yt(a)){let e=new Map(le);r?(e.delete(t),(async()=>{try{r===`will-disable`?await ht(t):await vt(t),fe()}catch(e){ct(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await vt(t):await ht(t),fe()}catch(e){ct(e)}})()),F(e)}}else e?.type===`mcp`&&pe(e.client.name)},[R,L,le,N,pe]);c({"select:previous":()=>{R===0?C(!0):ye.handleSelectionChange(R-1,ve)},"select:next":()=>{R<L.length-1&&ye.handleSelectionChange(R+1,ve)},"select:accept":Qn.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type===`plugin`){let t=N.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(j(t),E(`plugin-details`),Ce(0),B(null))}else e?.type===`flagged-plugin`?(E({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),B(null)):e?.type===`failed-plugin`?(E({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),Ce(0),B(null)):e?.type===`mcp`&&(E({type:`mcp-detail`,client:e.client}),B(null))},[R,L,N])},{context:`Select`,isActive:T===`plugin-list`&&!x}),c({"plugin:toggle":ze},{context:`Plugin`,isActive:T===`plugin-list`&&!x}),c({"select:accept":Qn.useCallback(()=>{typeof T!=`object`||T.type!==`flagged-detail`||(Mt(T.plugin.id),E(`plugin-list`))},[T])},{context:`Select`,isActive:typeof T==`object`&&T.type===`flagged-detail`});let Be=Qn.useMemo(()=>{if(T!==`plugin-details`||!A)return[];let e=ne(),t=`${A.plugin.name}@${A.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=A.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void Fe(n?`disable`:`enable`)}),r||(i.push({label:A.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Yn(A.plugin.name,A.marketplace);if(e){B(e);return}let t=[...N],n=t.findIndex(e=>e.plugin.name===A.plugin.name&&e.marketplace===A.marketplace);n!==-1&&(t[n].pendingUpdate=!A.pendingUpdate,se(t),j({...A,pendingUpdate:!A.pendingUpdate}))}catch(e){B(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Ne&&i.push({label:`Configure`,action:async()=>{Me(!0);try{let e=A.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&Oe(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&Oe(n)){t=n;break}}if(!t){B(`No MCPB file found in plugin`),Me(!1);return}let n=`${A.plugin.name}@${A.marketplace}`,r=await Ie(t,A.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ae(r),E(`configuring`)):B(`Failed to load MCPB for configuration`)}catch(e){let t=$e(e);B(`Failed to load configuration: ${t}`)}finally{Me(!1)}}}),A.plugin.manifest.userConfig&&Object.keys(A.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{E({type:`configuring-options`,schema:A.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void Fe(`update`)}),i.push({label:`Uninstall`,action:()=>void Fe(`uninstall`)})),A.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void De(A.plugin.manifest.homepage)}),A.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void De(A.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{E(`plugin-list`),j(null),B(null)}}),i},[T,A,Ne,N]);if(c({"select:previous":()=>{xe>0&&Ce(xe-1)},"select:next":()=>{xe<Be.length-1&&Ce(xe+1)},"select:accept":()=>{Be[xe]&&Be[xe].action()}},{context:`Select`,isActive:T===`plugin-details`&&!!A}),c({"select:accept":()=>{typeof T==`object`&&T.type===`failed-plugin-details`&&(async()=>{z(!0),B(null);let e=T.plugin.id,t=T.plugin.scope,r=yt(t)?await gt(e,t,!1):await gt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=O(t);n?.enabledPlugins?.[e]!==void 0&&(k(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}fe()}i?(n&&await n(),z(!1),E(`plugin-list`)):(z(!1),B(r.message))})()}},{context:`Select`,isActive:typeof T==`object`&&T.type===`failed-plugin-details`&&T.plugin.scope!==`managed`}),c({"confirm:yes":()=>{if(!A)return;z(!0),B(null);let r=`${A.plugin.name}@${A.marketplace}`,{error:i}=k(`localSettings`,{enabledPlugins:{...O(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){z(!1),B(`Failed to write settings: ${i.message}`);return}fe(),t(`✓ Disabled ${A.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{E(`plugin-details`),B(null)}},{context:`Confirmation`,isActive:T===`confirm-project-uninstall`&&!!A&&!we}),g((r,i)=>{if(!A)return;let o=`${A.plugin.name}@${A.marketplace}`,s=A.scope;if(!s||s===`builtin`||!yt(s))return;let c=async r=>{z(!0),B(null);try{let i=await gt(o,s,r);if(!i.success)throw Error(i.message);fe();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){z(!1),B(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(E(`plugin-details`),B(null))},{isActive:typeof T==`object`&&T.type===`confirm-data-cleanup`&&!!A&&!we}),Qn.useEffect(()=>{ve(0)},[D]),g((e,t)=>{let n=!t.ctrl&&!t.meta;x||(e===`/`&&n?(C(!0),re(``),ve(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(C(!0),re(e),ve(0)))},{isActive:T===`plugin-list`}),P)return(0,Z.jsx)(d,{children:`Loading installed plugins…`});if(he.length===0)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(d,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Esc to go back`})})]});if(typeof T==`object`&&T.type===`plugin-options`&&A){let r=`${A.plugin.name}@${A.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(pn,{plugin:A.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${A.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${A.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof T==`object`&&T.type===`configuring-options`&&A){let e=`${A.plugin.name}@${A.marketplace}`;return(0,Z.jsx)(cn,{title:`Configure ${A.plugin.name}`,subtitle:`Plugin options`,configSchema:T.schema,initialValues:Te(e),onSave:n=>{try{_e(e,n,T.schema),fe(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){B(`Failed to save configuration: ${$e(e)}`)}E(`plugin-details`)},onCancel:()=>E(`plugin-details`)})}if(T===`configuring`&&ke&&A){let e=`${A.plugin.name}@${A.marketplace}`;async function n(n){if(!(!ke||!A))try{let r=A.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&Oe(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&Oe(e)){i=e;break}}if(!i){B(`No MCPB file found`),E(`plugin-details`);return}await Ie(i,A.plugin.path,e,void 0,n),B(null),Ae(null),E(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=$e(e);B(`Failed to save configuration: ${t}`),E(`plugin-details`)}}function r(){Ae(null),E(`plugin-details`)}return(0,Z.jsx)(cn,{title:`Configure ${ke.manifest.name}`,subtitle:`Plugin: ${A.plugin.name}`,configSchema:ke.configSchema,initialValues:ke.existingConfig,onSave:n,onCancel:r})}if(typeof T==`object`&&T.type===`flagged-detail`){let e=T.plugin;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(u,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(d,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(d,{children:e.text}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(u,{children:[(0,Z.jsxs)(d,{children:[a.pointer,` `]}),(0,Z.jsx)(d,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(T===`confirm-project-uninstall`&&A)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,color:`warning`,children:[A.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(d,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:we?(0,Z.jsx)(d,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof T==`object`&&T.type===`confirm-data-cleanup`&&A)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,children:[A.plugin.name,` has `,T.size.human,` of persistent data`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(d,{dimColor:!0,children:Ge(`${A.plugin.name}@${A.marketplace}`)})]}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:we?(0,Z.jsx)(d,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(d,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(d,{bold:!0,children:`esc`}),` to cancel`]})})]});if(T===`plugin-details`&&A){let e=ne(),t=`${A.plugin.name}@${A.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=_.filter(e=>`plugin`in e&&e.plugin===A.plugin.name||e.source===t||e.source.startsWith(`${A.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(d,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Hn(e);return(0,Z.jsxs)(u,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(d,{color:`error`,children:Vn(e)}),n&&(0,Z.jsxs)(d,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[A.plugin.name,` @ `,A.marketplace]})}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(d,{children:A.scope||`user`})]}),A.plugin.manifest.version&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(d,{children:A.plugin.manifest.version})]}),A.plugin.manifest.description&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{children:A.plugin.manifest.description})}),A.plugin.manifest.author&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(d,{children:A.plugin.manifest.author.name})]}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),A.pendingUpdate&&(0,Z.jsx)(d,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Jn,{plugin:A.plugin,marketplace:A.marketplace}),i,(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:Be.map((e,t)=>{let n=t===xe;return(0,Z.jsxs)(u,{children:[n&&(0,Z.jsxs)(d,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(d,{children:` `}),(0,Z.jsx)(d,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),we&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{children:`Processing…`})}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof T==`object`&&T.type===`failed-plugin-details`){let e=T.plugin,t=e.errors[0],n=t?Vn(t):`Failed to load`;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:e.name}),(0,Z.jsxs)(d,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(d,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(d,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(u,{marginTop:1,children:[(0,Z.jsxs)(d,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(d,{bold:!0,children:`Remove`})]}),we&&(0,Z.jsx)(d,{children:`Processing…`}),Ee&&(0,Z.jsx)(d,{color:`error`,children:Ee}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[e.scope!==`managed`&&(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof T==`object`&&T.type===`mcp-detail`){let e=T.client,n=Se(h,e.name).length,r=()=>{E({type:`mcp-tools`,client:e})},i=()=>{E(`plugin-list`)},a=e=>{e&&t(e),E(`plugin-list`)},o=e.config.scope,s=e.config.type;return s===`stdio`?(0,Z.jsx)(Gt,{server:{name:e.name,client:e,scope:o,transport:`stdio`,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`sse`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`sse`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`http`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`http`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`claudeai-proxy`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):(E(`plugin-list`),null)}if(typeof T==`object`&&T.type===`mcp-tools`){let e=T.client,t=e.config.scope,n=e.config.type,r;return r=n===`stdio`?{name:e.name,client:e,scope:t,transport:`stdio`,config:e.config}:n===`sse`?{name:e.name,client:e,scope:t,transport:`sse`,isAuthenticated:void 0,config:e.config}:n===`http`?{name:e.name,client:e,scope:t,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:t,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Qt,{server:r,onSelectTool:t=>{E({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>E({type:`mcp-detail`,client:e})})}if(typeof T==`object`&&T.type===`mcp-tool-detail`){let{client:e,tool:t}=T,n=e.config.scope,r=e.config.type,i;return i=r===`stdio`?{name:e.name,client:e,scope:n,transport:`stdio`,config:e.config}:r===`sse`?{name:e.name,client:e,scope:n,transport:`sse`,isAuthenticated:void 0,config:e.config}:r===`http`?{name:e.name,client:e,scope:n,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:n,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Xt,{tool:t,server:i,onBack:()=>E({type:`mcp-tools`,client:e})})}let Ve=ye.getVisibleItems(L);return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(v,{query:D,isFocused:x,isTerminalFocused:ee,width:w-4,cursorOffset:ie})}),L.length===0&&D&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsxs)(d,{dimColor:!0,children:[`No items match "`,D,`"`]})}),ye.scrollPosition.canScrollUp&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Ve.map((e,t)=>{let n=ye.toActualIndex(t)===R&&!x,r=t>0?Ve[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)(Qn.Fragment,{children:[i&&(0,Z.jsx)(u,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(d,{dimColor:e.scope!==`flagged`,color:e.scope===`flagged`?`warning`:void 0,bold:e.scope===`flagged`,children:(e=>{switch(e){case`flagged`:return`Flagged`;case`project`:return`Project`;case`local`:return`Local`;case`user`:return`User`;case`enterprise`:return`Enterprise`;case`managed`:return`Managed`;case`builtin`:return`Built-in`;case`dynamic`:return`Built-in`;default:return e}})(e.scope)})}),(0,Z.jsx)(Wn,{item:e,isSelected:n})]},e.id)}),ye.scrollPosition.canScrollDown&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(u,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(d,{children:`type to search`}),(0,Z.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),le.size>0&&(0,Z.jsx)(u,{marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var Qn,X,Z,$n=e((()=>{i(),Qn=t(h(),1),X=t(h(),1),je(),S(),Kt(),Yt(),qt(),Jt(),Ht(),Wt(),ze(),Ve(),M(),Ft(),A(),xt(),Ze(),T(),Ye(),rt(),Qe(),st(),me(),we(),We(),j(),Pe(),Nt(),P(),L(),Ce(),F(),pt(),D(),it(),ft(),Un(),dn(),gn(),Gn(),On(),Z=w()}));function er(e){if(!e)return{type:`menu`};let t=e.trim().split(/\s+/);switch(t[0]?.toLowerCase()){case`help`:case`--help`:case`-h`:return{type:`help`};case`install`:case`i`:{let e=t[1];if(!e)return{type:`install`};if(e.includes(`@`)){let[t,n]=e.split(`@`);return{type:`install`,plugin:t,marketplace:n}}return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`file://`)||e.includes(`/`)||e.includes(`\\`)?{type:`install`,marketplace:e}:{type:`install`,plugin:e}}case`manage`:return{type:`manage`};case`uninstall`:return{type:`uninstall`,plugin:t[1]};case`enable`:return{type:`enable`,plugin:t[1]};case`disable`:return{type:`disable`,plugin:t[1]};case`validate`:return{type:`validate`,path:t.slice(1).join(` `).trim()||void 0};case`marketplace`:case`market`:{let e=t[1]?.toLowerCase(),n=t.slice(2).join(` `);switch(e){case`add`:return{type:`marketplace`,action:`add`,target:n};case`remove`:case`rm`:return{type:`marketplace`,action:`remove`,target:n};case`update`:return{type:`marketplace`,action:`update`,target:n};case`list`:return{type:`marketplace`,action:`list`};default:return{type:`marketplace`}}}default:return{type:`menu`}}}var tr=e((()=>{}));function nr({onComplete:e,path:t}){return(0,rr.useEffect)(()=>{async function n(){if(!t){e(`Usage: /plugin validate <path>
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{l as n,o as r}from"./envUtils-QyzA_cFM.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{D as o,Gr as s,Gt as c,H as l,I as u,P as d,T as f,Wt as p,Xn as m,ai as h,hn as g,j as _,k as v,n as y,ot as b,r as x,t as S,x as C,y as ee}from"./src-BX54x08P.js";import{t as w}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as T,Qn as te,d as ne,gt as E,m as D,s as O,y as k,yt as re}from"./settings-D4M13toi.js";import{$a as ie,$d as A,$m as j,Ao as ae,Ax as M,Ba as N,Bh as oe,Co as se,Cx as P,Do as ce,Eo as le,Fa as ue,Ga as F,Hh as I,Ka as de,Mo as fe,Mx as pe,No as me,Nx as he,Oo as ge,Pa as L,Qa as R,Qm as _e,So as ve,To as ye,Tx as be,Va as xe,Xd as Se,Xm as Ce,Ya as we,Ym as z,Zm as Te,_f as Ee,bu as De,do as B,eh as Oe,gf as ke,go as Ae,hd as je,io as Me,kx as Ne,lx as Pe,md as V,mo as Fe,nh as Ie,ox as Le,rh as Re,sb as ze,so as Be,tb as Ve,th as He,to as Ue,uo as We,ux as Ge,vo as Ke,wo as qe,yo as Je,yu as Ye,yx as Xe,zh as Ze}from"./loadAgentsDir-bmpKLPdG.js";import{I as Qe,M as $e,S as et,V as tt,c as nt,i as rt,x as it}from"./debug-2pVES-2G.js";import{d as at,g as ot}from"./config-Bio2EjUK.js";import{o as st,s as ct}from"./log-L1kqxa_P.js";import{n as lt}from"./analytics-COpjZpvd.js";import{S as ut,v as dt}from"./startupProfiler-B9Qv2QGH.js";import{l as H,o as ft}from"./stringUtils-Cs6E5f-B.js";import{n as pt,t as mt}from"./pluginStartupCheck-QG0d95dE.js";import{a as ht,d as gt,f as _t,i as vt,l as yt,o as bt,s as xt,u as St}from"./pluginOperations-BCvJvfOC.js";import{a as Ct,c as wt,i as Tt,n as Et,o as Dt,s as Ot,t as kt}from"./validatePlugin-CTVnWx9H.js";import{a as At,n as jt,o as Mt,r as Nt}from"./pluginFlagging-B2ZX5_oB.js";import{i as Pt,n as Ft}from"./MCPConnectionManager-C7RmKzJh.js";import{n as It,t as Lt}from"./useExitOnCtrlCDWithKeybindings-BT0nexZw.js";import{n as Rt,t as zt}from"./TextInput-ou7ZhpVY.js";import{r as Bt,t as Vt}from"./Spinner-C0qHjfIY.js";import{t as Ht}from"./SearchBox-zA5QwIpO.js";import{n as Ut,t as Wt}from"./useSearchInput-j12K4wEo.js";import{a as Gt,c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./MCPToolListView-CewNLJus.js";import{i as $t,n as en}from"./pluginAutoupdate-ByokIVEs.js";import*as tn from"path";import*as nn from"fs/promises";function rn({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:s,setResult:c,setViewState:l,onAddComplete:p,cliMode:m=!1}){let h=(0,an.useRef)(!1),[g,_]=(0,an.useState)(!1),[v,y]=(0,an.useState)(``),b=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ct(t);if(!n){a(`Invalid marketplace source format. Try: owner/repo, https://..., or ./path`);return}if(`error`in n){a(n.error);return}a(null);try{_(!0),y(``);let{name:e,resolvedSource:t}=await Me(n,e=>{y(e)});Ke(e,{source:t}),fe(),n.source,n.source===`github`&&n.repo,p&&await p(),y(``),_(!1),m?c(`Successfully added marketplace: ${e}`):l({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=tt(e);ct(t),a(t.message),y(``),_(!1),c(m?`Error: ${t.message}`:null)}};return(0,an.useEffect)(()=>{e&&!h.current&&!i&&!s&&(h.current=!0,b())},[]),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsxs)(u,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(u,{marginBottom:1,children:(0,U.jsx)(d,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(u,{flexDirection:`column`,children:[(0,U.jsx)(d,{children:`Enter marketplace source:`}),(0,U.jsx)(d,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(d,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(d,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(d,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(d,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(zt,{value:e,onChange:t,onSubmit:b,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),g&&(0,U.jsxs)(u,{marginTop:1,children:[(0,U.jsx)(Vt,{}),(0,U.jsx)(d,{children:v||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{color:`error`,children:i})}),s&&(0,U.jsx)(u,{marginTop:1,children:(0,U.jsx)(d,{children:s})})]}),(0,U.jsx)(u,{marginLeft:3,children:(0,U.jsx)(d,{dimColor:!0,italic:!0,children:(0,U.jsxs)(f,{children:[(0,U.jsx)(o,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(V,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var an,U,on=e((()=>{an=t(h(),1),lt(),je(),S(),Bt(),Rt(),Qe(),st(),me(),We(),Tt(),U=w()}));function sn(e,t,r,i){let a={};for(let o of e){let e=r[o],s=t[o]??``;if(!(e?.sensitive===!0&&s===``&&i?.[o]!==void 0))if(e?.type===`number`){if(s.trim()===``)continue;let e=Number(s);a[o]=Number.isNaN(e)?s:e}else e?.type===`boolean`?a[o]=n(s):a[o]=s}return a}function cn({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let l=Object.keys(n),f=(0,ln.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[m,h]=(0,ln.useState)(0),[_,v]=(0,ln.useState)({}),[y,b]=(0,ln.useState)(()=>l[0]?f(l[0]):``),x=l[m],S=x?n[x]:null;if(p(`confirm:no`,o,{context:`Settings`}),c({"confirm:nextField":(0,ln.useCallback)(()=>{if(m<l.length-1&&x){v(e=>({...e,[x]:y})),h(e=>e+1);let e=l[m+1];b(e?f(e):``)}},[m,l,x,y,f]),"confirm:yes":(0,ln.useCallback)(()=>{if(!x)return;let e={..._,[x]:y};if(m===l.length-1)i(sn(l,e,n,r));else{v(e),h(e=>e+1);let t=l[m+1];b(t?f(t):``)}},[x,_,y,m,l,n,i,f,r])},{context:`Confirmation`}),g((e,t)=>{if(t.backspace||t.delete){b(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&b(t=>t+e)}),!S||!x)return null;let C=S.sensitive===!0,w=S.required===!0,T=C?`*`.repeat(s(y)):y;return(0,un.jsxs)(ee,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,un.jsxs)(u,{flexDirection:`column`,children:[(0,un.jsxs)(d,{bold:!0,children:[S.title||x,w&&(0,un.jsx)(d,{color:`error`,children:` *`})]}),S.description&&(0,un.jsx)(d,{dimColor:!0,children:S.description}),(0,un.jsxs)(u,{marginTop:1,children:[(0,un.jsxs)(d,{children:[a.pointerSmall,` `]}),(0,un.jsx)(d,{children:T}),(0,un.jsx)(d,{children:`█`})]})]}),(0,un.jsxs)(u,{flexDirection:`column`,children:[(0,un.jsxs)(d,{dimColor:!0,children:[`Field `,m+1,` of `,l.length]}),m<l.length-1&&(0,un.jsx)(d,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),m===l.length-1&&(0,un.jsx)(d,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var ln,un,dn=e((()=>{i(),ln=t(h(),1),S(),Ve(),r(),un=w()}));async function fn(e){let{enabled:t,disabled:n}=await ue();return[...t,...n].find(t=>t.repository===e||t.source===e)}function pn({plugin:e,pluginId:t,onDone:n}){let[r]=mn.useState(()=>{let n=[],r=z(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>Te(t),save:n=>_e(t,n,e.manifest.userConfig)});let i=ke(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>He(t,r.server)??void 0,save:e=>Re(t,r.server,e,r.configSchema)});return n}),[i,a]=mn.useState(0),o=mn.useRef(n);if(o.current=n,mn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function c(e){try{s.save(e)}catch(e){n(`error`,$e(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,hn.jsx)(cn,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:c,onCancel:()=>n(`skipped`)},s.key)}var mn,hn,gn=e((()=>{mn=t(h(),1),Qe(),j(),Ee(),L(),Ce(),dn(),hn=w()}));function _n(){let e=ce();return(0,vn.jsxs)(u,{marginBottom:1,children:[(0,vn.jsxs)(d,{color:`claude`,children:[a.warning,` `]}),(0,vn.jsxs)(d,{dimColor:!0,italic:!0,children:[`Make sure you trust a plugin before installing, updating, or using it. We do not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.`,e?` ${e}`:``]})]})}var vn,yn=e((()=>{i(),S(),ge(),vn=w()}));function bn(e){return e.entry.source&&typeof e.entry.source==`object`&&`source`in e.entry.source&&e.entry.source.source===`github`&&typeof e.entry.source==`object`&&`repo`in e.entry.source?e.entry.source.repo:null}function xn(e,t){let n=[{label:`Install for you (user scope)`,action:`install-user`},{label:`Install for all collaborators on this repository (project scope)`,action:`install-project`},{label:`Install for you, in this repo only (local scope)`,action:`install-local`}];return e&&n.push({label:`Open homepage`,action:`homepage`}),t&&n.push({label:`View on GitHub`,action:`github`}),n.push({label:`Back to plugin list`,action:`back`}),n}function Sn({hasSelection:e}){return(0,Cn.jsx)(u,{marginTop:1,children:(0,Cn.jsx)(d,{dimColor:!0,italic:!0,children:(0,Cn.jsxs)(f,{children:[e&&(0,Cn.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,Cn.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Cn.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Cn.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var Cn,wn=e((()=>{je(),S(),Cn=w()}));function Tn({totalItems:e,maxVisible:t=Dn,selectedIndex:n=0}){let r=e>t,i=(0,En.useRef)(0),a=(0,En.useMemo)(()=>{if(!r)return 0;let a=i.current;if(n<a)return i.current=n,n;if(n>=a+t){let e=n-t+1;return i.current=e,e}let o=Math.max(0,e-t),s=Math.min(a,o);return i.current=s,s},[n,t,r,e]),o=a,s=Math.min(a+t,e),c=(0,En.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,En.useCallback)(e=>o+e,[o]),u=(0,En.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,En.useCallback)(e=>{},[]),f=(0,En.useCallback)(()=>{},[]),p=(0,En.useCallback)(()=>{},[]),m=(0,En.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,En.useCallback)((e,t)=>!1,[]),g=Math.max(1,Math.ceil(e/t));return{currentPage:Math.floor(a/t),totalPages:g,startIndex:o,endIndex:s,needsPagination:r,pageSize:t,getVisibleItems:c,toActualIndex:l,isOnCurrentPage:u,goToPage:d,nextPage:f,prevPage:p,handleSelectionChange:m,handlePageNavigation:h,scrollPosition:{current:n+1,total:e,canScrollUp:a>0,canScrollDown:a+t<e}}}var En,Dn,On=e((()=>{En=t(h(),1),Dn=5}));function kn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:l}){let[m,h]=(0,W.useState)(`marketplace-list`),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)([]),[S,C]=(0,W.useState)([]),[ee,w]=(0,W.useState)(!0),[T,ne]=(0,W.useState)(null),[E,D]=(0,W.useState)(0),[O,k]=(0,W.useState)(new Set),[re,A]=(0,W.useState)(new Set),j=Tn({totalItems:S.length,selectedIndex:E}),[M,N]=(0,W.useState)(0),[oe,se]=(0,W.useState)(!1),[P,ce]=(0,W.useState)(null),[ue,F]=(0,W.useState)(null);p(`confirm:no`,An.useCallback(()=>{m===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):b.length===1?i({type:`menu`}):(h(`marketplace-list`),_(null),k(new Set)):m===`plugin-details`?(h(`plugin-list`),y(null)):i({type:`menu`})},[m,s,i,b.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await B(),{marketplaces:n,failures:r}=await ae(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=te(r.plugins,t=>ie(ve(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:le(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),x(i);let a=ye(r,te(n,e=>e.data!==null));if(a)if(a.type===`warning`)F(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!l){let e=i[0];e&&(_(e.name),h(`plugin-list`))}if(l){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await Be(t);if(e){let i=e.plugins.find(e=>e.name===l);if(i){let e=ve(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:R(e)},r=t;break}}}if(n&&r){let e=n.pluginId;R(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(_(r),y(n),h(`plugin-details`))}else t(`Plugin "${l}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(_(s),h(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{w(!1)}}e()},[t,s,l]),(0,W.useEffect)(()=>{if(!g)return;let e=!1;async function n(n){w(!0);try{let t=await Be(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=ve(e.name,n);de(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:R(t)})}try{let t=await Ot();if(e)return;ne(t),t?r.sort((e,n)=>{let r=t.get(e.pluginId)??0,i=t.get(n.pluginId)??0;return r===i?e.entry.name.localeCompare(n.entry.name):i-r}):r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(t){if(e)return;nt(`Failed to fetch install counts: ${$e(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}C(r),D(0),k(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{w(!1)}}return n(g),()=>{e=!0}},[g,t]);let I=async()=>{if(O.size===0)return;let e=S.filter(e=>O.has(e.pluginId));A(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await xe({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}A(new Set),k(new Set),fe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${qe(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${qe(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},pe=async(e,t=`user`)=>{se(!0),ce(null);let n=await xe({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await fn(e.pluginId);if(t){se(!1),h({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else se(!1),ce(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),c({"select:previous":()=>{E>0&&D(E-1)},"select:next":()=>{E<b.length-1&&D(E+1)},"select:accept":()=>{let e=b[E];e&&(_(e.name),h(`plugin-list`))}},{context:`Select`,isActive:m===`marketplace-list`}),c({"select:previous":()=>{E>0&&j.handleSelectionChange(E-1,D)},"select:next":()=>{E<S.length-1&&j.handleSelectionChange(E+1,D)},"select:accept":()=>{if(E===S.length&&O.size>0)I();else if(E<S.length){let e=S[E];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(y(e),h(`plugin-details`),N(0),ce(null)))}}},{context:`Select`,isActive:m===`plugin-list`}),c({"plugin:toggle":()=>{if(E<S.length){let e=S[E];if(e&&!e.isInstalled){let t=new Set(O);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),k(t)}}},"plugin:install":()=>{O.size>0&&I()}},{context:`Plugin`,isActive:m===`plugin-list`});let me=An.useMemo(()=>{if(!v)return[];let e=v.entry.homepage;return xn(e,bn(v))},[v]);if(c({"select:previous":()=>{M>0&&N(M-1)},"select:next":()=>{M<me.length-1&&N(M+1)},"select:accept":()=>{if(!v)return;let e=me[M]?.action,t=v.entry.homepage,n=bn(v);e===`install-user`?pe(v,`user`):e===`install-project`?pe(v,`project`):e===`install-local`?pe(v,`local`):e===`homepage`&&t?De(t):e===`github`&&n?De(`https://github.com/${n}`):e===`back`&&(h(`plugin-list`),y(null))}},{context:`Select`,isActive:m===`plugin-details`&&!!v}),typeof m==`object`&&m.type===`plugin-options`){let{plugin:e,pluginId:t}=m;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(pn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ee)return(0,G.jsx)(d,{children:`Loading…`});if(e)return(0,G.jsx)(d,{color:`error`,children:e});if(m===`marketplace-list`)return b.length===0?(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(d,{children:`No marketplaces configured.`}),(0,G.jsxs)(d,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Select marketplace`})}),ue&&(0,G.jsx)(u,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(d,{color:`warning`,children:[a.warning,` `,ue]})}),b.map((e,t)=>(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:+(t<b.length-1),children:[(0,G.jsx)(u,{children:(0,G.jsxs)(d,{color:E===t?`suggestion`:void 0,children:[E===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(u,{marginLeft:2,children:(0,G.jsxs)(d,{dimColor:!0,children:[e.totalPlugins,` `,H(e.totalPlugins,`plugin`),` available`,e.installedCount>0&&` · ${e.installedCount} already installed`,e.source&&` · ${e.source}`]})})]},e.name)),(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(m===`plugin-details`&&v){let e=v.entry.homepage,t=xn(e,bn(v));return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:v.entry.name}),v.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[`Version: `,v.entry.version]}),v.entry.description&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsx)(d,{children:v.entry.description})}),v.entry.author&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof v.entry.author==`string`?v.entry.author:v.entry.author.name]})})]}),(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(d,{bold:!0,children:`Will install:`}),v.entry.commands&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(v.entry.commands)?v.entry.commands.join(`, `):Object.keys(v.entry.commands).join(`, `)]}),v.entry.agents&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(v.entry.agents)?v.entry.agents.join(`, `):Object.keys(v.entry.agents).join(`, `)]}),v.entry.hooks&&(0,G.jsxs)(d,{dimColor:!0,children:[`· Hooks: `,Object.keys(v.entry.hooks).join(`, `)]}),v.entry.mcpServers&&(0,G.jsxs)(d,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(v.entry.mcpServers)?v.entry.mcpServers.join(`, `):typeof v.entry.mcpServers==`object`?Object.keys(v.entry.mcpServers).join(`, `):`configured`]}),!v.entry.commands&&!v.entry.agents&&!v.entry.hooks&&!v.entry.mcpServers&&(typeof v.entry.source==`object`&&`source`in v.entry.source&&(v.entry.source.source===`github`||v.entry.source.source===`url`||v.entry.source.source===`npm`||v.entry.source.source===`pip`)?(0,G.jsx)(d,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(d,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(_n,{}),P&&(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsxs)(d,{color:`error`,children:[`Error: `,P]})}),(0,G.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(u,{children:[M===t&&(0,G.jsx)(d,{children:`> `}),M!==t&&(0,G.jsx)(d,{children:` `}),(0,G.jsx)(d,{bold:M===t,children:oe&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(u,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(d,{dimColor:!0,children:(0,G.jsxs)(f,{children:[(0,G.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(S.length===0)return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(d,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(d,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(u,{marginLeft:3,children:(0,G.jsx)(d,{dimColor:!0,italic:!0,children:(0,G.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let he=j.getVisibleItems(S);return(0,G.jsxs)(u,{flexDirection:`column`,children:[(0,G.jsx)(u,{marginBottom:1,children:(0,G.jsx)(d,{bold:!0,children:`Install Plugins`})}),j.scrollPosition.canScrollUp&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),he.map((t,n)=>{let r=j.toActualIndex(n),i=E===r,o=O.has(t.pluginId),s=re.has(t.pluginId);return(0,G.jsxs)(u,{flexDirection:`column`,marginBottom:n===he.length-1&&!e?0:1,children:[(0,G.jsxs)(u,{children:[(0,G.jsxs)(d,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(d,{color:t.isInstalled?`success`:void 0,children:[t.isInstalled?a.tick:s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,t.entry.category&&(0,G.jsxs)(d,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(d,{dimColor:!0,children:` (installed)`}),T&&g===`claude-plugins-official`&&(0,G.jsxs)(d,{dimColor:!0,children:[` · `,Dt(T.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(u,{marginLeft:4,children:[(0,G.jsx)(d,{dimColor:!0,children:ut(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(d,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),j.scrollPosition.canScrollDown&&(0,G.jsx)(u,{children:(0,G.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(u,{marginTop:1,children:(0,G.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Sn,{hasSelection:O.size>0})]})}var An,W,G,jn=e((()=>{i(),An=t(h(),1),W=t(h(),1),je(),S(),Ve(),T(),Ye(),rt(),Qe(),me(),wt(),we(),ge(),We(),Xe(),N(),F(),ft(),dt(),gn(),yn(),wn(),On(),G=w()}));function Mn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:l}){let[h,_]=(0,K.useState)(`plugin-list`),[y,x]=(0,K.useState)(null),[S,C]=(0,K.useState)([]),[ee,w]=(0,K.useState)(!0),[T,ne]=(0,K.useState)(null),[E,D]=(0,K.useState)(!1),O=(0,K.useCallback)(e=>{D(e),s?.(e)},[s]),{query:k,setQuery:re,cursorOffset:ie}=Ut({isActive:h===`plugin-list`&&E&&!ee,onExit:()=>{O(!1)}}),A=m(),{columns:j}=b(),M=(0,K.useMemo)(()=>{if(!k)return S;let e=k.toLowerCase();return S.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[S,k]),[N,oe]=(0,K.useState)(0),[P,ce]=(0,K.useState)(new Set),[le,ue]=(0,K.useState)(new Set),F=Tn({totalItems:M.length,selectedIndex:N});(0,K.useEffect)(()=>{oe(0)},[k]);let[I,pe]=(0,K.useState)(0),[me,he]=(0,K.useState)(!1),[ge,L]=(0,K.useState)(null),[_e,be]=(0,K.useState)(null),[Se,Ce]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await B(),{marketplaces:n,failures:r}=await ae(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=ve(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:R(t)})}let a=i.filter(e=>!e.isInstalled&&!de(e.pluginId));try{let e=await Ot();ne(e),e?a.sort((t,n)=>{let r=e.get(t.pluginId)??0,i=e.get(n.pluginId)??0;return r===i?t.entry.name.localeCompare(n.entry.name):i-r}):a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}catch(e){nt(`Failed to fetch install counts: ${$e(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}C(a);let o=Object.keys(e).length;if(a.length===0){let e=await se({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});Ce(e)}let s=ye(r,te(n,e=>e.data!==null));if(s)if(s.type===`warning`)be(`${s.message}. Showing available plugins.`);else throw Error(s.message);if(l){let e=i.find(e=>e.entry.name===l);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(x(e),_(`plugin-details`)):t(`Plugin "${l}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{w(!1)}}e()},[t,l]);let we=async()=>{if(P.size===0)return;let e=S.filter(e=>P.has(e.pluginId));ue(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await xe({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ue(new Set),ce(new Set),fe(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${qe(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${qe(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},z=async(e,t=`user`)=>{he(!0),L(null);let n=await xe({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await fn(e.pluginId);if(t){he(!1),_({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else he(!1),L(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),p(`confirm:no`,()=>{_(`plugin-list`),x(null)},{context:`Confirmation`,isActive:h===`plugin-details`}),p(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:h===`plugin-list`&&!E}),g((e,t)=>{let n=!t.ctrl&&!t.meta;E||(e===`/`&&n?(O(!0),re(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(O(!0),re(e)))},{isActive:h===`plugin-list`&&!ee}),c({"select:previous":()=>{N===0?O(!0):F.handleSelectionChange(N-1,oe)},"select:next":()=>{N<M.length-1&&F.handleSelectionChange(N+1,oe)},"select:accept":()=>{if(N===M.length&&P.size>0)we();else if(N<M.length){let e=M[N];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(x(e),_(`plugin-details`),pe(0),L(null)))}}},{context:`Select`,isActive:h===`plugin-list`&&!E}),c({"plugin:toggle":()=>{if(N<M.length){let e=M[N];if(e&&!e.isInstalled){let t=new Set(P);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),ce(t)}}},"plugin:install":()=>{P.size>0&&we()}},{context:`Plugin`,isActive:h===`plugin-list`&&!E});let Te=Fn.useMemo(()=>{if(!y)return[];let e=y.entry.homepage;return xn(e,bn(y))},[y]);if(c({"select:previous":()=>{I>0&&pe(I-1)},"select:next":()=>{I<Te.length-1&&pe(I+1)},"select:accept":()=>{if(!y)return;let e=Te[I]?.action,t=y.entry.homepage,n=bn(y);e===`install-user`?z(y,`user`):e===`install-project`?z(y,`project`):e===`install-local`?z(y,`local`):e===`homepage`&&t?De(t):e===`github`&&n?De(`https://github.com/${n}`):e===`back`&&(_(`plugin-list`),x(null))}},{context:`Select`,isActive:h===`plugin-details`&&!!y}),typeof h==`object`&&h.type===`plugin-options`){let{plugin:e,pluginId:t}=h;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(pn,{plugin:e,pluginId:t,onDone:(t,r)=>{switch(t){case`configured`:n(`✓ Installed and configured ${e.name}. Run /reload-plugins to apply.`);break;case`skipped`:n(`✓ Installed ${e.name}. Run /reload-plugins to apply.`);break;case`error`:n(`Installed but failed to save config: ${r}`);break}}})}if(ee)return(0,q.jsx)(d,{children:`Loading…`});if(e)return(0,q.jsx)(d,{color:`error`,children:e});if(h===`plugin-details`&&y){let e=y.entry.homepage,t=xn(e,bn(y));return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(d,{bold:!0,children:y.entry.name}),(0,q.jsxs)(d,{dimColor:!0,children:[`from `,y.marketplaceName]}),y.entry.version&&(0,q.jsxs)(d,{dimColor:!0,children:[`Version: `,y.entry.version]}),y.entry.description&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{children:y.entry.description})}),y.entry.author&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`By:`,` `,typeof y.entry.author==`string`?y.entry.author:y.entry.author.name]})})]}),(0,q.jsx)(_n,{}),ge&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`error`,children:[`Error: `,ge]})}),(0,q.jsx)(u,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(u,{children:[I===t&&(0,q.jsx)(d,{children:`> `}),I!==t&&(0,q.jsx)(d,{children:` `}),(0,q.jsx)(d,{bold:I===t,children:me&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,children:(0,q.jsxs)(f,{children:[(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(S.length===0)return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(d,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Pn,{reason:Se}),(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let Ee=F.getVisibleItems(M);return(0,q.jsxs)(u,{flexDirection:`column`,children:[(0,q.jsxs)(u,{children:[(0,q.jsx)(d,{bold:!0,children:`Discover plugins`}),F.needsPagination&&(0,q.jsxs)(d,{dimColor:!0,children:[` `,`(`,F.scrollPosition.current,`/`,F.scrollPosition.total,`)`]})]}),(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsx)(v,{query:k,isFocused:E,isTerminalFocused:A,width:j-4,cursorOffset:ie})}),_e&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{color:`warning`,children:[a.warning,` `,_e]})}),M.length===0&&k&&(0,q.jsx)(u,{marginBottom:1,children:(0,q.jsxs)(d,{dimColor:!0,children:[`No plugins match "`,k,`"`]})}),F.scrollPosition.canScrollUp&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Ee.map((t,n)=>{let r=F.toActualIndex(n),i=N===r,o=P.has(t.pluginId),s=le.has(t.pluginId);return(0,q.jsxs)(u,{flexDirection:`column`,marginBottom:n===Ee.length-1&&!e?0:1,children:[(0,q.jsxs)(u,{children:[(0,q.jsxs)(d,{color:i&&!E?`suggestion`:void 0,children:[i&&!E?a.pointer:` `,` `]}),(0,q.jsxs)(d,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(d,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(d,{dimColor:!0,children:` [Community Managed]`}),T&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(d,{dimColor:!0,children:[` · `,Dt(T.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(u,{marginLeft:4,children:(0,q.jsx)(d,{dimColor:!0,children:ut(t.entry.description,60)})})]},`${F.startIndex}-${t.pluginId}`)}),F.scrollPosition.canScrollDown&&(0,q.jsx)(u,{children:(0,q.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(u,{marginTop:1,children:(0,q.jsxs)(d,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Nn,{hasSelection:P.size>0,canToggle:N<M.length&&!M[N]?.isInstalled})]})}function Nn({hasSelection:e,canToggle:t}){return(0,q.jsx)(u,{marginTop:1,children:(0,q.jsx)(d,{dimColor:!0,italic:!0,children:(0,q.jsxs)(f,{children:[e&&(0,q.jsx)(V,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(d,{children:`type to search`}),t&&(0,q.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Pn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Please install git and restart Work Mate.`})]});case`all-blocked-by-policy`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(d,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(d,{dimColor:!0,children:`Switch to the Marketplaces tab to view allowed sources.`})]});case`all-marketplaces-failed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(d,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(d,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(d,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var Fn,K,q,In=e((()=>{i(),Fn=t(h(),1),K=t(h(),1),je(),Ht(),S(),Wt(),ze(),Ve(),T(),Ye(),rt(),Qe(),me(),wt(),we(),ge(),We(),Xe(),N(),F(),ft(),dt(),gn(),yn(),wn(),On(),q=w()}));function Ln({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:l}){let[m,h]=(0,zn.useState)([]),[_,v]=(0,zn.useState)(!0),[y,b]=(0,zn.useState)(0),[x,S]=(0,zn.useState)(!1),[C,ee]=(0,zn.useState)(null),[w,T]=(0,zn.useState)(null),[ne,E]=(0,zn.useState)(null),[D,ie]=(0,zn.useState)(`list`),[A,j]=(0,zn.useState)(null),[M,N]=(0,zn.useState)(0),oe=(0,zn.useRef)(!1);(0,zn.useEffect)(()=>{async function e(){try{let e=await B(),{enabled:r,disabled:i}=await ue(),a=[...r,...i],{marketplaces:o,failures:c}=await ae(e),u=[];for(let{name:e,config:t,data:n}of o){let r=a.filter(t=>t.source.endsWith(`@${e}`));u.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:re(e,t)})}u.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),h(u);let d=ye(c,te(o,e=>e.data!==null));if(d)if(d.type===`warning`)ee(d.message);else throw Error(d.message);if(s&&!oe.current&&!t){oe.current=!0;let e=u.findIndex(e=>e.name===s);if(e>=0){let t=u[e];if(l){b(e+1);let t=[...u];l===`update`?t[e].pendingUpdate=!0:l===`remove`&&(t[e].pendingRemove=!0),h(t),setTimeout(ce,100,t)}else t&&(b(e+1),j(t),ie(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),ee(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{v(!1)}}e()},[s,l,t]);let se=()=>m.some(e=>e.pendingUpdate||e.pendingRemove),P=()=>({updateCount:te(m,e=>e.pendingUpdate),removeCount:te(m,e=>e.pendingRemove)}),ce=async t=>{let i=t||m,s=D===`details`;S(!0),ee(null),T(null),E(null);try{let t=O(`userSettings`),n=0,c=0,l=new Set;for(let e of i){if(e.pendingRemove){if(e.installedPlugins&&e.installedPlugins.length>0){let n={...t?.enabledPlugins};for(let t of e.installedPlugins){let r=ve(t.name,e.name);n[r]=!1}k(`userSettings`,{enabledPlugins:n})}await Ae(e.name),c++,e.name,e.installedPlugins?.length;continue}e.pendingUpdate&&(await Fe(e.name,e=>{E(e)}),n++,l.add(e.name.toLowerCase()),e.name)}let u=0;l.size>0&&(u=(await $t(l)).length),fe(),o&&await o();let d=await B(),{enabled:f,disabled:p}=await ue(),m=[...f,...p],{marketplaces:g}=await ae(d),_=[];for(let{name:e,config:t,data:n}of g){let r=m.filter(t=>t.source.endsWith(`@${e}`));_.push({name:e,source:le(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:re(e,t)})}if(_.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),h(_),s&&A){let e=_.find(e=>e.name===A.name);e&&j(e)}let v=[];if(n>0){let e=u>0?` (${u} ${H(u,`plugin`)} bumped)`:``;v.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&v.push(`Removed ${c} ${H(c,`marketplace`)}`),v.length>0){let t=`${a.tick} ${v.join(`, `)}`;s?T(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=$e(e);ee(t),n&&n(t)}finally{S(!1),E(null)}},F=async()=>{if(!A)return;let e=m.map(e=>e.name===A.name?{...e,pendingRemove:!0}:e);h(e),await ce(e)},I=e=>{if(!e)return[];let t=[{label:`Browse plugins (${e.pluginCount??0})`,value:`browse`},{label:`Update marketplace`,secondaryLabel:e.lastUpdated?`(last updated ${new Date(e.lastUpdated).toLocaleDateString()})`:void 0,value:`update`}];return ot()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},de=async e=>{let t=!e.autoUpdate;try{await Je(e.name,t),h(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),j(e=>e&&{...e,autoUpdate:t})}catch(e){ee(e instanceof Error?e.message:`Failed to update setting`)}};if(p(`confirm:no`,()=>{ie(`list`),N(0)},{context:`Confirmation`,isActive:!x&&(D===`details`||D===`confirm-remove`)}),p(`confirm:no`,()=>{h(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),b(0)},{context:`Confirmation`,isActive:!x&&D===`list`&&se()}),p(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!x&&D===`list`&&!se()}),c({"select:previous":()=>b(e=>Math.max(0,e-1)),"select:next":()=>{let e=m.length+1;b(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=y-1;if(y===0)e({type:`add-marketplace`});else if(se())ce();else{let e=m[t];e&&(j(e),ie(`details`),N(0))}}},{context:`Select`,isActive:!x&&D===`list`}),g(e=>{let t=y-1;if((e===`u`||e===`U`)&&t>=0)h(e=>e.map((e,n)=>n===t?{...e,pendingUpdate:!e.pendingUpdate,pendingRemove:e.pendingUpdate?e.pendingRemove:!1}:e));else if((e===`r`||e===`R`)&&t>=0){let e=m[t];e&&(j(e),ie(`confirm-remove`))}},{isActive:!x&&D===`list`}),c({"select:previous":()=>N(e=>Math.max(0,e-1)),"select:next":()=>{let e=I(A);N(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!A)return;let t=I(A)[M];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:A.name});else if(t?.value===`update`){let e=m.map(e=>e.name===A.name?{...e,pendingUpdate:!0}:e);h(e),ce(e)}else t?.value===`toggle-auto-update`?de(A):t?.value===`remove`&&ie(`confirm-remove`)}},{context:`Select`,isActive:!x&&D===`details`}),g(e=>{e===`y`||e===`Y`?F():(e===`n`||e===`N`)&&(ie(`list`),j(null))},{isActive:!x&&D===`confirm-remove`}),_)return(0,J.jsx)(d,{children:`Loading marketplaces…`});if(m.length===0)return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(d,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(D===`confirm-remove`&&A){let e=A.installedPlugins?.length||0;return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsxs)(d,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(d,{italic:!0,children:A.name}),`?`]}),(0,J.jsxs)(u,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),A.installedPlugins&&A.installedPlugins.length>0&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,marginLeft:2,children:A.installedPlugins.map(e=>(0,J.jsxs)(d,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[`Press `,(0,J.jsx)(d,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(d,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(D===`details`&&A){let e=A.pendingUpdate||x,t=I(A);return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{bold:!0,children:A.name}),(0,J.jsx)(d,{dimColor:!0,children:A.source}),(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{children:[A.pluginCount||0,` available `,H(A.pluginCount||0,`plugin`)]})}),A.installedPlugins&&A.installedPlugins.length>0&&(0,J.jsxs)(u,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(d,{bold:!0,children:[`Installed plugins (`,A.installedPlugins.length,`):`]}),(0,J.jsx)(u,{flexDirection:`column`,marginLeft:1,children:A.installedPlugins.map(e=>(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(d,{children:a.bullet}),(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(d,{children:e.name}),(0,J.jsx)(d,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(d,{color:`claude`,children:`Updating marketplace…`}),ne&&(0,J.jsx)(d,{dimColor:!0,children:ne})]}),!e&&w&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:w})}),!e&&C&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:C})}),!e&&(0,J.jsx)(u,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===M;return(0,J.jsxs)(u,{children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(d,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!ot()&&A.autoUpdate&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(u,{marginLeft:3,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(f,{children:[(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:pe,removeCount:me}=P();return(0,J.jsxs)(u,{flexDirection:`column`,children:[(0,J.jsx)(u,{marginBottom:1,children:(0,J.jsx)(d,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:y===0?`suggestion`:void 0,children:[y===0?a.pointer:` `,` +`]}),(0,J.jsx)(d,{bold:!0,color:y===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(u,{flexDirection:`column`,children:m.map((e,t)=>{let n=t+1===y,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(u,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(d,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(u,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(u,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(d,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(d,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(d,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(d,{dimColor:!0,children:e.source}),(0,J.jsxs)(d,{dimColor:!0,children:[e.pluginCount!==void 0&&(0,J.jsxs)(J.Fragment,{children:[e.pluginCount,` available`]}),e.installedPlugins&&e.installedPlugins.length>0&&(0,J.jsxs)(J.Fragment,{children:[` • `,e.installedPlugins.length,` installed`]}),e.lastUpdated&&(0,J.jsxs)(J.Fragment,{children:[` • Updated `,new Date(e.lastUpdated).toLocaleDateString()]})]})]})]},e.name)})}),se()&&(0,J.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(d,{children:[(0,J.jsx)(d,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(d,{dimColor:!0,children:`Enter to apply`})]}),pe>0&&(0,J.jsxs)(d,{children:[`• Update `,pe,` `,H(pe,`marketplace`)]}),me>0&&(0,J.jsxs)(d,{color:`warning`,children:[`• Remove `,me,` `,H(me,`marketplace`)]})]}),x&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`claude`,children:`Processing changes…`})}),C&&(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{color:`error`,children:C})}),(0,J.jsx)(Rn,{exitState:i,hasPendingActions:se()})]})}function Rn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(u,{marginTop:1,children:(0,J.jsxs)(d,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(u,{marginTop:1,children:(0,J.jsx)(d,{dimColor:!0,italic:!0,children:(0,J.jsxs)(f,{children:[t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(o,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(o,{shortcut:`r`,action:`remove`}),(0,J.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var zn,J,Bn=e((()=>{i(),zn=t(h(),1),lt(),je(),S(),Ve(),T(),at(),Qe(),me(),ge(),We(),en(),L(),E(),D(),ft(),J=w()}));function Vn(e){switch(e.type){case`path-not-found`:return`${e.component} path not found: ${e.path}`;case`git-auth-failed`:return`Git ${e.authType.toUpperCase()} authentication failed for ${e.gitUrl}`;case`git-timeout`:return`Git ${e.operation} timed out for ${e.gitUrl}`;case`network-error`:return`Network error accessing ${e.url}${e.details?`: ${e.details}`:``}`;case`manifest-parse-error`:return`Failed to parse manifest at ${e.manifestPath}: ${e.parseError}`;case`manifest-validation-error`:return`Invalid manifest at ${e.manifestPath}: ${e.validationErrors.join(`, `)}`;case`plugin-not-found`:return`Plugin "${e.pluginId}" not found in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return`Marketplace "${e.marketplace}" not found`;case`marketplace-load-failed`:return`Failed to load marketplace "${e.marketplace}": ${e.reason}`;case`mcp-config-invalid`:return`Invalid MCP server config for "${e.serverName}": ${e.validationError}`;case`mcp-server-suppressed-duplicate`:{let t=e.duplicateOf.startsWith(`plugin:`)?`server provided by plugin "${e.duplicateOf.split(`:`)[1]??`?`}"`:`already-configured "${e.duplicateOf}"`;return`MCP server "${e.serverName}" skipped — same command/URL as ${t}`}case`hook-load-failed`:return`Failed to load hooks from ${e.hookPath}: ${e.reason}`;case`component-load-failed`:return`Failed to load ${e.component} from ${e.path}: ${e.reason}`;case`mcpb-download-failed`:return`Failed to download MCPB from ${e.url}: ${e.reason}`;case`mcpb-extract-failed`:return`Failed to extract MCPB ${e.mcpbPath}: ${e.reason}`;case`mcpb-invalid-manifest`:return`MCPB manifest invalid at ${e.mcpbPath}: ${e.validationError}`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`Marketplace "${e.marketplace}" is blocked by enterprise policy`:`Marketplace "${e.marketplace}" is not in the allowed marketplace list`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Dependency "${e.dependency}" is disabled`:`Dependency "${e.dependency}" is not installed`;case`lsp-config-invalid`:return`Invalid LSP server config for "${e.serverName}": ${e.validationError}`;case`lsp-server-start-failed`:return`LSP server "${e.serverName}" failed to start: ${e.reason}`;case`lsp-server-crashed`:return e.signal?`LSP server "${e.serverName}" crashed with signal ${e.signal}`:`LSP server "${e.serverName}" crashed with exit code ${e.exitCode??`unknown`}`;case`lsp-request-timeout`:return`LSP server "${e.serverName}" timed out on ${e.method} after ${e.timeoutMs}ms`;case`lsp-request-failed`:return`LSP server "${e.serverName}" ${e.method} failed: ${e.error}`;case`plugin-cache-miss`:return`Plugin "${e.plugin}" not cached at ${e.installPath}`;case`generic-error`:return e.error}return pe(e)}function Hn(e){switch(e.type){case`path-not-found`:return`Check that the path in your manifest or marketplace config is correct`;case`git-auth-failed`:return e.authType===`ssh`?`Configure SSH keys or use HTTPS URL instead`:`Configure credentials or use SSH URL instead`;case`git-timeout`:case`network-error`:return`Check your internet connection and try again`;case`manifest-parse-error`:return`Check manifest file syntax in the plugin directory`;case`manifest-validation-error`:return`Check manifest file follows the required schema`;case`plugin-not-found`:return`Plugin may not exist in marketplace "${e.marketplace}"`;case`marketplace-not-found`:return e.availableMarketplaces.length>0?`Available marketplaces: ${e.availableMarketplaces.join(`, `)}`:`Add the marketplace first using /plugin marketplace add`;case`mcp-config-invalid`:return`Check MCP server configuration in .mcp.json or manifest`;case`mcp-server-suppressed-duplicate`:return e.duplicateOf.startsWith(`plugin:`)?`Disable plugin "${e.duplicateOf.split(`:`)[1]??`the other plugin`}" if you want this plugin's version instead`:`Remove "${e.duplicateOf}" from your MCP config if you want the plugin's version instead`;case`hook-load-failed`:return`Check hooks.json file syntax and structure`;case`component-load-failed`:return`Check ${e.component} directory structure and file permissions`;case`mcpb-download-failed`:return`Check your internet connection and URL accessibility`;case`mcpb-extract-failed`:return`Verify the MCPB file is valid and not corrupted`;case`mcpb-invalid-manifest`:return`Contact the plugin author about the invalid manifest`;case`marketplace-blocked-by-policy`:return e.blockedByBlocklist?`This marketplace source is explicitly blocked by your administrator`:e.allowedSources.length>0?`Allowed sources: ${e.allowedSources.join(`, `)}`:`Contact your administrator to configure allowed marketplace sources`;case`dependency-unsatisfied`:return e.reason===`not-enabled`?`Enable "${e.dependency}" or uninstall "${e.plugin}"`:`Install "${e.dependency}" or uninstall "${e.plugin}"`;case`lsp-config-invalid`:return`Check LSP server configuration in the plugin manifest`;case`lsp-server-start-failed`:case`lsp-server-crashed`:case`lsp-request-timeout`:case`lsp-request-failed`:return`Check LSP server logs with --debug for details`;case`plugin-cache-miss`:return`Run /plugins to refresh the plugin cache`;case`marketplace-load-failed`:case`generic-error`:return null}return null}var Un=e((()=>{he()}));function Wn({item:e,isSelected:t}){let[n]=l();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=_(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=_(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=_(`success`,n)(a.tick),i=`enabled`):(r=_(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=_(`warning`,n)(a.warning);return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=_(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(d,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=_(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=_(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=_(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=_(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=_(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{dimColor:!t,children:`└ `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]}):(0,Y.jsxs)(u,{children:[(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(d,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(d,{dimColor:!t,children:[` `,(0,Y.jsx)(d,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(d,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(d,{dimColor:!t,children:i})]})}var Y,Gn=e((()=>{i(),S(),ft(),Y=w()}));async function Kn(e){try{return(await nn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>tn.basename(e.name,`.md`))}catch(t){return nt(`Failed to read plugin components from ${e}: ${$e(t)}`,{level:`error`}),ct(tt(t)),[]}}async function qn(e){try{let t=await nn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=tn.join(e,r.name,`SKILL.md`);try{(await nn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return nt(`Failed to read skill directories from ${e}: ${$e(t)}`,{level:`error`}),ct(tt(t)),[]}}function Jn({plugin:e,marketplace:t}){let[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(null);return(0,X.useEffect)(()=>{async function n(){try{if(t===`builtin`){let t=Ne(e.name);if(t){let e=t.skills?.map(e=>e.name)??[],n=t.hooks?Object.keys(t.hooks):[],i=t.mcpServers?Object.keys(t.mcpServers):[];r({commands:null,agents:null,skills:e.length>0?e:null,hooks:n.length>0?n:null,mcpServers:i.length>0?i:null})}else s(`Built-in plugin ${e.name} not found`);a(!1);return}let n=(await Be(t)).plugins.find(t=>t.name===e.name);if(n){let t=[];e.commandsPath&&t.push(e.commandsPath),e.commandsPaths&&t.push(...e.commandsPaths);let i=[];for(let e of t)if(typeof e==`string`){let t=await Kn(e);i.push(...t)}let a=[];e.agentsPath&&a.push(e.agentsPath),e.agentsPaths&&a.push(...e.agentsPaths);let o=[];for(let e of a)if(typeof e==`string`){let t=await Kn(e);o.push(...t)}let s=[];e.skillsPath&&s.push(e.skillsPath),e.skillsPaths&&s.push(...e.skillsPaths);let c=[];for(let e of s)if(typeof e==`string`){let t=await qn(e);c.push(...t)}let l=[];e.hooksConfig&&l.push(Object.keys(e.hooksConfig)),n.hooks&&l.push(n.hooks);let u=[];e.mcpServers&&u.push(Object.keys(e.mcpServers)),n.mcpServers&&u.push(n.mcpServers),r({commands:i.length>0?i:null,agents:o.length>0?o:null,skills:c.length>0?c:null,hooks:l.length>0?l:null,mcpServers:u.length>0?u:null})}else s(`Plugin ${e.name} not found in marketplace`)}catch(e){s(e instanceof Error?e.message:`Failed to load components`)}finally{a(!1)}}n()},[e.name,e.commandsPath,e.commandsPaths,e.agentsPath,e.agentsPaths,e.skillsPath,e.skillsPaths,e.hooksConfig,e.mcpServers,t]),i?null:o?(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Components:`}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(d,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Commands:`,` `,typeof n.commands==`string`?n.commands:Array.isArray(n.commands)?n.commands.join(`, `):Object.keys(n.commands).join(`, `)]}):null,n.agents?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Agents:`,` `,typeof n.agents==`string`?n.agents:Array.isArray(n.agents)?n.agents.join(`, `):Object.keys(n.agents).join(`, `)]}):null,n.skills?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Skills:`,` `,typeof n.skills==`string`?n.skills:Array.isArray(n.skills)?n.skills.join(`, `):Object.keys(n.skills).join(`, `)]}):null,n.hooks?(0,Z.jsxs)(d,{dimColor:!0,children:[`• Hooks:`,` `,typeof n.hooks==`string`?n.hooks:Array.isArray(n.hooks)?n.hooks.map(String).join(`, `):typeof n.hooks==`object`&&n.hooks!==null?Object.keys(n.hooks).join(`, `):String(n.hooks)]}):null,n.mcpServers?(0,Z.jsxs)(d,{dimColor:!0,children:[`• MCP Servers:`,` `,typeof n.mcpServers==`string`?n.mcpServers:Array.isArray(n.mcpServers)?n.mcpServers.map(String).join(`, `):typeof n.mcpServers==`object`&&n.mcpServers!==null?Object.keys(n.mcpServers).join(`, `):String(n.mcpServers)]}):null]})}async function Yn(e,t){let n=(await Be(t))?.plugins.find(t=>t.name===e);return n&&typeof n.source==`string`?`Local plugins cannot be updated remotely. To update, modify the source at: ${n.source}`:null}function Xn(e){return e.filter(e=>{let t=e.source.split(`@`)[1]||`local`;return!de(`${e.name}@${t}`)})}function Zn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=oe(e=>e.mcp.clients),h=oe(e=>e.mcp.tools),_=oe(e=>e.plugins.errors),y=jt(),[x,S]=(0,X.useState)(!1),C=(0,X.useCallback)(e=>{S(e),r?.(e)},[r]),ee=m(),{columns:w}=b(),[T,E]=(0,X.useState)(`plugin-list`),{query:D,setQuery:re,cursorOffset:ie}=Ut({isActive:T===`plugin-list`&&x,onExit:()=>{C(!1)}}),[A,j]=(0,X.useState)(null),[ae,M]=(0,X.useState)([]),[N,se]=(0,X.useState)([]),[P,ce]=(0,X.useState)(!0),[le,F]=(0,X.useState)(new Map),I=(0,X.useRef)(!1),de=(0,X.useRef)(void 0),pe=Pt();p(`confirm:no`,Qn.useCallback(()=>{if(T===`plugin-details`)E(`plugin-list`),j(null),B(null);else if(typeof T==`object`&&T.type===`failed-plugin-details`)E(`plugin-list`),B(null);else if(T===`configuring`)E(`plugin-details`),Ae(null);else if(typeof T==`object`&&(T.type===`plugin-options`||T.type===`configuring-options`))E(`plugin-list`),j(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof T==`object`&&T.type===`flagged-detail`)E(`plugin-list`),B(null);else if(typeof T==`object`&&T.type===`mcp-detail`)E(`plugin-list`),B(null);else if(typeof T==`object`&&T.type===`mcp-tools`)E({type:`mcp-detail`,client:T.client});else if(typeof T==`object`&&T.type===`mcp-tool-detail`)E({type:`mcp-tools`,client:T.client});else{if(le.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[T,e,le,t]),{context:`Confirmation`,isActive:(T!==`plugin-list`||!x)&&T!==`confirm-project-uninstall`&&!(typeof T==`object`&&T.type===`confirm-data-cleanup`)});let me=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,he=(0,X.useMemo)(()=>{let e=ne(),t=new Map;for(let e of l)if(e.name.startsWith(`plugin:`)){let n=e.name.split(`:`);if(n.length>=3){let r=n[1],i=n.slice(2).join(`:`),a=t.get(r)||[];a.push({displayName:i,client:e}),t.set(r,a)}}let n=[];for(let r of N){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=_.filter(e=>`plugin`in e&&e.plugin===r.plugin.name||e.source===i||e.source.startsWith(`${r.plugin.name}@`)),s=r.plugin.isBuiltin?`builtin`:r.scope||`user`;n.push({item:{type:`plugin`,id:i,name:r.plugin.name,description:r.plugin.manifest.description,marketplace:r.marketplace,scope:s,isEnabled:a,errorCount:o.length,errors:o,plugin:r.plugin,pendingEnable:r.pendingEnable,pendingUpdate:r.pendingUpdate,pendingToggle:le.get(i)},originalScope:s,childMcps:t.get(r.plugin.name)||[]})}let r=new Set(n.map(({item:e})=>e.id)),i=new Set(n.map(({item:e})=>e.name)),a=new Map;for(let e of _){if(r.has(e.source)||`plugin`in e&&typeof e.plugin==`string`&&i.has(e.plugin))continue;let t=a.get(e.source)||[];t.push(e),a.set(e.source,t)}let o=mt(),s=[];for(let[e,t]of a){if(e in y)continue;let n=be(e),r=n.name||e,i=n.marketplace||`unknown`,a=o.get(e),c=a===`flag`||a===void 0?`user`:a;s.push({type:`failed-plugin`,id:e,name:r,marketplace:i,scope:c,errorCount:t.length,errors:t})}let c=[];for(let e of l)e.name!==`ide`&&(e.name.startsWith(`plugin:`)||c.push({type:`mcp`,id:`mcp:${e.name}`,name:e.name,description:void 0,scope:e.config.scope,status:me(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},d=[],f=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;f.has(n)||f.set(n,[]),f.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;f.has(r)||f.set(r,[]),f.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:me(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let e of s){let t=e.scope;f.has(t)||f.set(t,[]),f.get(t).push(e)}for(let[e,t]of Object.entries(y)){let n=be(e),r=n.name||e,i=n.marketplace||`unknown`;f.has(`flagged`)||f.set(`flagged`,[]),f.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let p=[...f.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of p){let t=f.get(e),n=[],r=[],i=0;for(;i<t.length;){let e=t[i];if(e.type===`plugin`||e.type===`failed-plugin`||e.type===`flagged-plugin`){let r=[e];i++;let a=t[i];for(;a?.type===`mcp`&&a.indented;)r.push(a),i++,a=t[i];n.push(r)}else e.type===`mcp`&&!e.indented&&r.push(e),i++}n.sort((e,t)=>e[0].name.localeCompare(t[0].name)),r.sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)d.push(...e);d.push(...r)}return d},[N,l,_,le,y]),ge=(0,X.useMemo)(()=>he.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[he]);(0,X.useEffect)(()=>{ge.length>0&&At(ge)},[ge]);let L=(0,X.useMemo)(()=>{if(!D)return he;let e=D.toLowerCase();return he.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[he,D]),[R,ve]=(0,X.useState)(0),ye=Tn({totalItems:L.length,selectedIndex:R,maxVisible:8}),[xe,Ce]=(0,X.useState)(0),[we,z]=(0,X.useState)(!1),[Ee,B]=(0,X.useState)(null),[ke,Ae]=(0,X.useState)(null),[je,Me]=(0,X.useState)(!1),[Ne,Pe]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!A){Pe(!1);return}async function e(){let e=A.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&Oe(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Oe(e))),!t)try{let e=tn.join(A.plugin.path,`..`),n=tn.join(e,`.claude-plugin`,`marketplace.json`),r=et(await nn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===A.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&Oe(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Oe(e))}}catch(e){nt(`Failed to read raw marketplace.json: ${e}`)}Pe(t)}e()},[A]),(0,X.useEffect)(()=>{async function e(){ce(!0);try{let{enabled:e,disabled:t}=await ue(),n=ne(),r=Xn([...e,...t]),i={};for(let e of r){let t=e.source.split(`@`)[1]||`local`;i[t]||(i[t]=[]),i[t].push(e)}let a=[];for(let[e,t]of Object.entries(i)){let r=te(t,t=>{let r=`${t.name}@${e}`;return n?.enabledPlugins?.[r]!==!1}),i=t.length-r;a.push({name:e,installedPlugins:t,enabledCount:r,disabledCount:i})}a.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),M(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:bt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}se(o),ve(0)}finally{ce(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!I.current&&i&&ae.length>0&&!P){let{name:e,marketplace:n}=be(i),r=o??n,a=r?ae.filter(e=>e.name===r):ae;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=bt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};j(r),E(`plugin-details`),de.current=s,I.current=!0;return}}let c=he.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(E({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),I.current=!0),!I.current&&s&&(I.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,ae,P,he,s,t]);let Fe=async r=>{if(!A)return;let i=A.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){B(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!yt(i)&&r!==`update`){B(`This plugin is managed by your organization. Contact your admin to disable it.`);return}z(!0),B(null);try{let o=`${A.plugin.name}@${A.marketplace}`,s;switch(r){case`enable`:{let e=await ht(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await vt(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!yt(i))break;if(St(o)){z(!1),E(`confirm-project-uninstall`);return}let e=Ue().plugins[o],t=!e||e.length<=1?await Le(o):null;if(t){z(!1),E({type:`confirm-data-cleanup`,size:t});return}let n=await gt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await _t(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${A.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}fe();let c=`${A.plugin.name}@${A.marketplace}`;if(ne()?.enabledPlugins?.[c]!==!1){z(!1),E({type:`plugin-options`});return}let l=r===`enable`?`Enabled`:r===`disable`?`Disabled`:r===`update`?`Updated`:`Uninstalled`,u=s&&s.length>0?` · required by ${s.join(`, `)}`:``;t(`✓ ${l} ${A.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){z(!1);let t=e instanceof Error?e.message:String(e);B(`Failed to ${r}: ${t}`),ct(tt(e))}},Re=(0,X.useRef)(Fe);Re.current=Fe,(0,X.useEffect)(()=>{if(T===`plugin-details`&&A&&de.current){let e=de.current;de.current=void 0,Re.current(e)}},[T,A]);let ze=Qn.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=ne(),r=le.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||yt(a)){let e=new Map(le);r?(e.delete(t),(async()=>{try{r===`will-disable`?await ht(t):await vt(t),fe()}catch(e){ct(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await vt(t):await ht(t),fe()}catch(e){ct(e)}})()),F(e)}}else e?.type===`mcp`&&pe(e.client.name)},[R,L,le,N,pe]);c({"select:previous":()=>{R===0?C(!0):ye.handleSelectionChange(R-1,ve)},"select:next":()=>{R<L.length-1&&ye.handleSelectionChange(R+1,ve)},"select:accept":Qn.useCallback(()=>{if(R>=L.length)return;let e=L[R];if(e?.type===`plugin`){let t=N.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(j(t),E(`plugin-details`),Ce(0),B(null))}else e?.type===`flagged-plugin`?(E({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),B(null)):e?.type===`failed-plugin`?(E({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),Ce(0),B(null)):e?.type===`mcp`&&(E({type:`mcp-detail`,client:e.client}),B(null))},[R,L,N])},{context:`Select`,isActive:T===`plugin-list`&&!x}),c({"plugin:toggle":ze},{context:`Plugin`,isActive:T===`plugin-list`&&!x}),c({"select:accept":Qn.useCallback(()=>{typeof T!=`object`||T.type!==`flagged-detail`||(Mt(T.plugin.id),E(`plugin-list`))},[T])},{context:`Select`,isActive:typeof T==`object`&&T.type===`flagged-detail`});let Be=Qn.useMemo(()=>{if(T!==`plugin-details`||!A)return[];let e=ne(),t=`${A.plugin.name}@${A.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=A.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void Fe(n?`disable`:`enable`)}),r||(i.push({label:A.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Yn(A.plugin.name,A.marketplace);if(e){B(e);return}let t=[...N],n=t.findIndex(e=>e.plugin.name===A.plugin.name&&e.marketplace===A.marketplace);n!==-1&&(t[n].pendingUpdate=!A.pendingUpdate,se(t),j({...A,pendingUpdate:!A.pendingUpdate}))}catch(e){B(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Ne&&i.push({label:`Configure`,action:async()=>{Me(!0);try{let e=A.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&Oe(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&Oe(n)){t=n;break}}if(!t){B(`No MCPB file found in plugin`),Me(!1);return}let n=`${A.plugin.name}@${A.marketplace}`,r=await Ie(t,A.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ae(r),E(`configuring`)):B(`Failed to load MCPB for configuration`)}catch(e){let t=$e(e);B(`Failed to load configuration: ${t}`)}finally{Me(!1)}}}),A.plugin.manifest.userConfig&&Object.keys(A.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{E({type:`configuring-options`,schema:A.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void Fe(`update`)}),i.push({label:`Uninstall`,action:()=>void Fe(`uninstall`)})),A.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void De(A.plugin.manifest.homepage)}),A.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void De(A.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{E(`plugin-list`),j(null),B(null)}}),i},[T,A,Ne,N]);if(c({"select:previous":()=>{xe>0&&Ce(xe-1)},"select:next":()=>{xe<Be.length-1&&Ce(xe+1)},"select:accept":()=>{Be[xe]&&Be[xe].action()}},{context:`Select`,isActive:T===`plugin-details`&&!!A}),c({"select:accept":()=>{typeof T==`object`&&T.type===`failed-plugin-details`&&(async()=>{z(!0),B(null);let e=T.plugin.id,t=T.plugin.scope,r=yt(t)?await gt(e,t,!1):await gt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=O(t);n?.enabledPlugins?.[e]!==void 0&&(k(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}fe()}i?(n&&await n(),z(!1),E(`plugin-list`)):(z(!1),B(r.message))})()}},{context:`Select`,isActive:typeof T==`object`&&T.type===`failed-plugin-details`&&T.plugin.scope!==`managed`}),c({"confirm:yes":()=>{if(!A)return;z(!0),B(null);let r=`${A.plugin.name}@${A.marketplace}`,{error:i}=k(`localSettings`,{enabledPlugins:{...O(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){z(!1),B(`Failed to write settings: ${i.message}`);return}fe(),t(`✓ Disabled ${A.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{E(`plugin-details`),B(null)}},{context:`Confirmation`,isActive:T===`confirm-project-uninstall`&&!!A&&!we}),g((r,i)=>{if(!A)return;let o=`${A.plugin.name}@${A.marketplace}`,s=A.scope;if(!s||s===`builtin`||!yt(s))return;let c=async r=>{z(!0),B(null);try{let i=await gt(o,s,r);if(!i.success)throw Error(i.message);fe();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){z(!1),B(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(E(`plugin-details`),B(null))},{isActive:typeof T==`object`&&T.type===`confirm-data-cleanup`&&!!A&&!we}),Qn.useEffect(()=>{ve(0)},[D]),g((e,t)=>{let n=!t.ctrl&&!t.meta;x||(e===`/`&&n?(C(!0),re(``),ve(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(C(!0),re(e),ve(0)))},{isActive:T===`plugin-list`}),P)return(0,Z.jsx)(d,{children:`Loading installed plugins…`});if(he.length===0)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(d,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Esc to go back`})})]});if(typeof T==`object`&&T.type===`plugin-options`&&A){let r=`${A.plugin.name}@${A.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(pn,{plugin:A.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${A.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${A.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof T==`object`&&T.type===`configuring-options`&&A){let e=`${A.plugin.name}@${A.marketplace}`;return(0,Z.jsx)(cn,{title:`Configure ${A.plugin.name}`,subtitle:`Plugin options`,configSchema:T.schema,initialValues:Te(e),onSave:n=>{try{_e(e,n,T.schema),fe(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){B(`Failed to save configuration: ${$e(e)}`)}E(`plugin-details`)},onCancel:()=>E(`plugin-details`)})}if(T===`configuring`&&ke&&A){let e=`${A.plugin.name}@${A.marketplace}`;async function n(n){if(!(!ke||!A))try{let r=A.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&Oe(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&Oe(e)){i=e;break}}if(!i){B(`No MCPB file found`),E(`plugin-details`);return}await Ie(i,A.plugin.path,e,void 0,n),B(null),Ae(null),E(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=$e(e);B(`Failed to save configuration: ${t}`),E(`plugin-details`)}}function r(){Ae(null),E(`plugin-details`)}return(0,Z.jsx)(cn,{title:`Configure ${ke.manifest.name}`,subtitle:`Plugin: ${A.plugin.name}`,configSchema:ke.configSchema,initialValues:ke.existingConfig,onSave:n,onCancel:r})}if(typeof T==`object`&&T.type===`flagged-detail`){let e=T.plugin;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(u,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(d,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(d,{children:e.text}),(0,Z.jsxs)(d,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(u,{children:[(0,Z.jsxs)(d,{children:[a.pointer,` `]}),(0,Z.jsx)(d,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(T===`confirm-project-uninstall`&&A)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,color:`warning`,children:[A.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(d,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:we?(0,Z.jsx)(d,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof T==`object`&&T.type===`confirm-data-cleanup`&&A)return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{bold:!0,children:[A.plugin.name,` has `,T.size.human,` of persistent data`]}),(0,Z.jsxs)(u,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(d,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(d,{dimColor:!0,children:Ge(`${A.plugin.name}@${A.marketplace}`)})]}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:we?(0,Z.jsx)(d,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(d,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(d,{bold:!0,children:`esc`}),` to cancel`]})})]});if(T===`plugin-details`&&A){let e=ne(),t=`${A.plugin.name}@${A.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=_.filter(e=>`plugin`in e&&e.plugin===A.plugin.name||e.source===t||e.source.startsWith(`${A.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(u,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(d,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Hn(e);return(0,Z.jsxs)(u,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(d,{color:`error`,children:Vn(e)}),n&&(0,Z.jsxs)(d,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{bold:!0,children:[A.plugin.name,` @ `,A.marketplace]})}),(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(d,{children:A.scope||`user`})]}),A.plugin.manifest.version&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(d,{children:A.plugin.manifest.version})]}),A.plugin.manifest.description&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(d,{children:A.plugin.manifest.description})}),A.plugin.manifest.author&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(d,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(d,{children:A.plugin.manifest.author.name})]}),(0,Z.jsxs)(u,{marginBottom:1,children:[(0,Z.jsx)(d,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(d,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),A.pendingUpdate&&(0,Z.jsx)(d,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Jn,{plugin:A.plugin,marketplace:A.marketplace}),i,(0,Z.jsx)(u,{marginTop:1,flexDirection:`column`,children:Be.map((e,t)=>{let n=t===xe;return(0,Z.jsxs)(u,{children:[n&&(0,Z.jsxs)(d,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(d,{children:` `}),(0,Z.jsx)(d,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),we&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{children:`Processing…`})}),Ee&&(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{color:`error`,children:Ee})}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(V,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof T==`object`&&T.type===`failed-plugin-details`){let e=T.plugin,t=e.errors[0],n=t?Vn(t):`Failed to load`;return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsxs)(d,{children:[(0,Z.jsx)(d,{bold:!0,children:e.name}),(0,Z.jsxs)(d,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(d,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(d,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(u,{marginTop:1,children:[(0,Z.jsxs)(d,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(d,{bold:!0,children:`Remove`})]}),we&&(0,Z.jsx)(d,{children:`Processing…`}),Ee&&(0,Z.jsx)(d,{color:`error`,children:Ee}),(0,Z.jsx)(u,{marginTop:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[e.scope!==`managed`&&(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof T==`object`&&T.type===`mcp-detail`){let e=T.client,n=Se(h,e.name).length,r=()=>{E({type:`mcp-tools`,client:e})},i=()=>{E(`plugin-list`)},a=e=>{e&&t(e),E(`plugin-list`)},o=e.config.scope,s=e.config.type;return s===`stdio`?(0,Z.jsx)(Gt,{server:{name:e.name,client:e,scope:o,transport:`stdio`,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`sse`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`sse`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`http`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`http`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):s===`claudeai-proxy`?(0,Z.jsx)(Zt,{server:{name:e.name,client:e,scope:o,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},serverToolsCount:n,onViewTools:r,onCancel:i,onComplete:a,borderless:!0}):(E(`plugin-list`),null)}if(typeof T==`object`&&T.type===`mcp-tools`){let e=T.client,t=e.config.scope,n=e.config.type,r;return r=n===`stdio`?{name:e.name,client:e,scope:t,transport:`stdio`,config:e.config}:n===`sse`?{name:e.name,client:e,scope:t,transport:`sse`,isAuthenticated:void 0,config:e.config}:n===`http`?{name:e.name,client:e,scope:t,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:t,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Qt,{server:r,onSelectTool:t=>{E({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>E({type:`mcp-detail`,client:e})})}if(typeof T==`object`&&T.type===`mcp-tool-detail`){let{client:e,tool:t}=T,n=e.config.scope,r=e.config.type,i;return i=r===`stdio`?{name:e.name,client:e,scope:n,transport:`stdio`,config:e.config}:r===`sse`?{name:e.name,client:e,scope:n,transport:`sse`,isAuthenticated:void 0,config:e.config}:r===`http`?{name:e.name,client:e,scope:n,transport:`http`,isAuthenticated:void 0,config:e.config}:{name:e.name,client:e,scope:n,transport:`claudeai-proxy`,isAuthenticated:void 0,config:e.config},(0,Z.jsx)(Xt,{tool:t,server:i,onBack:()=>E({type:`mcp-tools`,client:e})})}let Ve=ye.getVisibleItems(L);return(0,Z.jsxs)(u,{flexDirection:`column`,children:[(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsx)(v,{query:D,isFocused:x,isTerminalFocused:ee,width:w-4,cursorOffset:ie})}),L.length===0&&D&&(0,Z.jsx)(u,{marginBottom:1,children:(0,Z.jsxs)(d,{dimColor:!0,children:[`No items match "`,D,`"`]})}),ye.scrollPosition.canScrollUp&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Ve.map((e,t)=>{let n=ye.toActualIndex(t)===R&&!x,r=t>0?Ve[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)(Qn.Fragment,{children:[i&&(0,Z.jsx)(u,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(d,{dimColor:e.scope!==`flagged`,color:e.scope===`flagged`?`warning`:void 0,bold:e.scope===`flagged`,children:(e=>{switch(e){case`flagged`:return`Flagged`;case`project`:return`Project`;case`local`:return`Local`;case`user`:return`User`;case`enterprise`:return`Enterprise`;case`managed`:return`Managed`;case`builtin`:return`Built-in`;case`dynamic`:return`Built-in`;default:return e}})(e.scope)})}),(0,Z.jsx)(Wn,{item:e,isSelected:n})]},e.id)}),ye.scrollPosition.canScrollDown&&(0,Z.jsx)(u,{children:(0,Z.jsxs)(d,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(u,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(f,{children:[(0,Z.jsx)(d,{children:`type to search`}),(0,Z.jsx)(V,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(V,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(V,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),le.size>0&&(0,Z.jsx)(u,{marginLeft:1,children:(0,Z.jsx)(d,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var Qn,X,Z,$n=e((()=>{i(),Qn=t(h(),1),X=t(h(),1),je(),S(),Kt(),Yt(),qt(),Jt(),Ht(),Wt(),ze(),Ve(),M(),Ft(),A(),xt(),Ze(),T(),Ye(),rt(),Qe(),st(),me(),we(),We(),j(),Pe(),Nt(),P(),L(),Ce(),F(),pt(),D(),it(),ft(),Un(),dn(),gn(),Gn(),On(),Z=w()}));function er(e){if(!e)return{type:`menu`};let t=e.trim().split(/\s+/);switch(t[0]?.toLowerCase()){case`help`:case`--help`:case`-h`:return{type:`help`};case`install`:case`i`:{let e=t[1];if(!e)return{type:`install`};if(e.includes(`@`)){let[t,n]=e.split(`@`);return{type:`install`,plugin:t,marketplace:n}}return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`file://`)||e.includes(`/`)||e.includes(`\\`)?{type:`install`,marketplace:e}:{type:`install`,plugin:e}}case`manage`:return{type:`manage`};case`uninstall`:return{type:`uninstall`,plugin:t[1]};case`enable`:return{type:`enable`,plugin:t[1]};case`disable`:return{type:`disable`,plugin:t[1]};case`validate`:return{type:`validate`,path:t.slice(1).join(` `).trim()||void 0};case`marketplace`:case`market`:{let e=t[1]?.toLowerCase(),n=t.slice(2).join(` `);switch(e){case`add`:return{type:`marketplace`,action:`add`,target:n};case`remove`:case`rm`:return{type:`marketplace`,action:`remove`,target:n};case`update`:return{type:`marketplace`,action:`update`,target:n};case`list`:return{type:`marketplace`,action:`list`};default:return{type:`marketplace`}}}default:return{type:`menu`}}}var tr=e((()=>{}));function nr({onComplete:e,path:t}){return(0,rr.useEffect)(()=>{async function n(){if(!t){e(`Usage: /plugin validate <path>
2
2
 
3
3
  Validate a plugin or marketplace manifest file or directory.
4
4
 
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{gt as t,yt as n}from"./settings-D4M13toi.js";import{Cx as r,Tx as i,Ya as a,Za as o,do as s,eo as c,mo as l,oo as u,uo as d}from"./loadAgentsDir-uuZYOgKn.js";import{I as f,M as p,c as m,i as h}from"./debug-2pVES-2G.js";import{d as g,g as _}from"./config-BDn2YIjC.js";import{o as v,s as y}from"./log-L1kqxa_P.js";import{f as b,s as x}from"./pluginOperations-Ca_T-HYn.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await s(),t=u(),r=new Set;for(let[i,a]of Object.entries(e)){let e=t[i]?.autoUpdate;(e===void 0?n(i,a):e)&&r.add(i.toLowerCase())}return r}async function w(e,t){let n=!1;for(let{scope:r}of t)try{let t=await b(e,r);t.success&&!t.alreadyUpToDate?(n=!0,m(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||m(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){m(`Plugin autoupdate: error updating ${e}: ${p(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=c(),n=Object.keys(t.plugins);return n.length===0?[]:(await Promise.allSettled(n.map(async n=>{let{marketplace:r}=i(n);if(!r||!e.has(r.toLowerCase()))return null;let a=t.plugins[n];if(!a||a.length===0)return null;let s=a.filter(o);return s.length===0?null:w(n,s)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(_()){m(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let t=(await Promise.allSettled(Array.from(e).map(async e=>{try{await l(e,void 0,{disableCredentialHelper:!0})}catch(t){m(`Plugin autoupdate: failed to refresh marketplace ${e}: ${p(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);t.length>0&&m(`Plugin autoupdate: ${t.length} marketplace refresh(es) failed`,{level:`warn`}),m(`Plugin autoupdate: checking installed plugins`);let n=await E(e);n.length>0&&(O?O(n):k=n)}catch(e){y(e)}})()}var O,k,A=e((()=>{x(),g(),h(),f(),v(),a(),d(),r(),t(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{gt as t,yt as n}from"./settings-D4M13toi.js";import{Cx as r,Tx as i,Ya as a,Za as o,do as s,eo as c,mo as l,oo as u,uo as d}from"./loadAgentsDir-bmpKLPdG.js";import{I as f,M as p,c as m,i as h}from"./debug-2pVES-2G.js";import{d as g,g as _}from"./config-Bio2EjUK.js";import{o as v,s as y}from"./log-L1kqxa_P.js";import{f as b,s as x}from"./pluginOperations-BCvJvfOC.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await s(),t=u(),r=new Set;for(let[i,a]of Object.entries(e)){let e=t[i]?.autoUpdate;(e===void 0?n(i,a):e)&&r.add(i.toLowerCase())}return r}async function w(e,t){let n=!1;for(let{scope:r}of t)try{let t=await b(e,r);t.success&&!t.alreadyUpToDate?(n=!0,m(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||m(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){m(`Plugin autoupdate: error updating ${e}: ${p(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=c(),n=Object.keys(t.plugins);return n.length===0?[]:(await Promise.allSettled(n.map(async n=>{let{marketplace:r}=i(n);if(!r||!e.has(r.toLowerCase()))return null;let a=t.plugins[n];if(!a||a.length===0)return null;let s=a.filter(o);return s.length===0?null:w(n,s)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(_()){m(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let t=(await Promise.allSettled(Array.from(e).map(async e=>{try{await l(e,void 0,{disableCredentialHelper:!0})}catch(t){m(`Plugin autoupdate: failed to refresh marketplace ${e}: ${p(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);t.length>0&&m(`Plugin autoupdate: ${t.length} marketplace refresh(es) failed`,{level:`warn`}),m(`Plugin autoupdate: checking installed plugins`);let n=await E(e);n.length>0&&(O?O(n):k=n)}catch(e){y(e)}})()}var O,k,A=e((()=>{x(),g(),h(),f(),v(),a(),d(),r(),t(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
@@ -1 +1 @@
1
- import{Ya as e,fo as t,so as n,to as r,uo as i}from"./loadAgentsDir-uuZYOgKn.js";import{I as a,M as o,c as s,i as c}from"./debug-2pVES-2G.js";import{d as l,s as u}from"./pluginOperations-Ca_T-HYn.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-CUvkKGOB.js";u(),c(),a(),e(),i(),p();function h(e,t,n){let r=new Set(t.plugins.map(e=>e.name)),i=`@${n}`,a=[];for(let t of Object.keys(e.plugins)){if(!t.endsWith(i))continue;let e=t.slice(0,-i.length);r.has(e)||a.push(t)}return a}async function g(){await d();let e=r(),i=f(),a=await t(),c=[];for(let t of Object.keys(a))try{let r=await n(t);if(!r.forceRemoveDeletedPlugins)continue;let a=h(e,r,t);for(let t of a){if(t in i)continue;let n=e.plugins[t]??[];if(n.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let e of n){let{scope:n}=e;if(!(n!==`user`&&n!==`project`&&n!==`local`))try{await l(t,n)}catch(e){s(`Failed to auto-uninstall delisted plugin ${t} from ${n}: ${o(e)}`,{level:`error`})}}await m(t),c.push(t)}}}catch(e){s(`Failed to check for delisted plugins in "${t}": ${o(e)}`,{level:`warn`})}return c}export{g as t};
1
+ import{Ya as e,fo as t,so as n,to as r,uo as i}from"./loadAgentsDir-bmpKLPdG.js";import{I as a,M as o,c as s,i as c}from"./debug-2pVES-2G.js";import{d as l,s as u}from"./pluginOperations-BCvJvfOC.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-B2ZX5_oB.js";u(),c(),a(),e(),i(),p();function h(e,t,n){let r=new Set(t.plugins.map(e=>e.name)),i=`@${n}`,a=[];for(let t of Object.keys(e.plugins)){if(!t.endsWith(i))continue;let e=t.slice(0,-i.length);r.has(e)||a.push(t)}return a}async function g(){await d();let e=r(),i=f(),a=await t(),c=[];for(let t of Object.keys(a))try{let r=await n(t);if(!r.forceRemoveDeletedPlugins)continue;let a=h(e,r,t);for(let t of a){if(t in i)continue;let n=e.plugins[t]??[];if(n.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let e of n){let{scope:n}=e;if(!(n!==`user`&&n!==`project`&&n!==`local`))try{await l(t,n)}catch(e){s(`Failed to auto-uninstall delisted plugin ${t} from ${n}: ${o(e)}`,{level:`error`})}}await m(t),c.push(t)}}}catch(e){s(`Failed to check for delisted plugins in "${t}": ${o(e)}`,{level:`warn`})}return c}export{g as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./figures-5ThXQEtq.js";import{Cx as n,Ja as r,Tx as i,au as a,gi as o,iu as s,mi as c,qa as l,ru as u}from"./loadAgentsDir-uuZYOgKn.js";import{I as d,M as f}from"./debug-2pVES-2G.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-L1kqxa_P.js";import{n as _}from"./analytics-COpjZpvd.js";import{a as v,c as y,d as b,f as x,i as S,r as C,s as w}from"./pluginOperations-Ca_T-HYn.js";e(),d(),o(),h(),r(),n(),p(),a(),_(),w();function T(e,n,r){g(e);let a=r?`${n} plugin "${r}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${a}: ${f(e)}`);let o=r?(()=>{let{name:e,marketplace:t}=i(r);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...u(e,t,l())}})():{};s(e),{...o},process.exit(1)}async function E(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let r=await y(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`install`,e)}}async function D(e,n=`user`,r=!1){try{let a=await b(e,n,!r);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);({...s&&{_PROTO_marketplace_name:s}}),a.scope,{...u(o,s,l())},process.exit(0)}catch(t){T(t,`uninstall`,e)}}async function O(e,n){try{let r=await v(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`enable`,e)}}async function k(e,n){try{let r=await S(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`disable`,e)}}async function A(){try{let e=await C();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),process.exit(0)}catch(e){T(e,`disable-all`)}}async function j(e,n){try{m(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let r=await x(e,n);if(!r.success)throw Error(r.message);if(m(`${t.tick} ${r.message}\n`),!r.alreadyUpToDate){let{name:t,marketplace:n}=i(r.pluginId||e);({...n&&{_PROTO_marketplace_name:n}}),r.oldVersion,r.newVersion,{...u(t,n,l())}}await c(0)}catch(t){T(t,`update`,e)}}export{D as a,E as i,k as n,j as o,O as r,A as t};
1
+ import{n as e,t}from"./figures-5ThXQEtq.js";import{Cx as n,Ja as r,Tx as i,au as a,gi as o,iu as s,mi as c,qa as l,ru as u}from"./loadAgentsDir-bmpKLPdG.js";import{I as d,M as f}from"./debug-2pVES-2G.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-L1kqxa_P.js";import{n as _}from"./analytics-COpjZpvd.js";import{a as v,c as y,d as b,f as x,i as S,r as C,s as w}from"./pluginOperations-BCvJvfOC.js";e(),d(),o(),h(),r(),n(),p(),a(),_(),w();function T(e,n,r){g(e);let a=r?`${n} plugin "${r}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${a}: ${f(e)}`);let o=r?(()=>{let{name:e,marketplace:t}=i(r);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...u(e,t,l())}})():{};s(e),{...o},process.exit(1)}async function E(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let r=await y(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`install`,e)}}async function D(e,n=`user`,r=!1){try{let a=await b(e,n,!r);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);({...s&&{_PROTO_marketplace_name:s}}),a.scope,{...u(o,s,l())},process.exit(0)}catch(t){T(t,`uninstall`,e)}}async function O(e,n){try{let r=await v(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`enable`,e)}}async function k(e,n){try{let r=await S(e,n);if(!r.success)throw Error(r.message);console.log(`${t.tick} ${r.message}`);let{name:a,marketplace:o}=i(r.pluginId||e);({...o&&{_PROTO_marketplace_name:o}}),r.scope,{...u(a,o,l())},process.exit(0)}catch(t){T(t,`disable`,e)}}async function A(){try{let e=await C();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),process.exit(0)}catch(e){T(e,`disable-all`)}}async function j(e,n){try{m(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let r=await x(e,n);if(!r.success)throw Error(r.message);if(m(`${t.tick} ${r.message}\n`),!r.alreadyUpToDate){let{name:t,marketplace:n}=i(r.pluginId||e);({...n&&{_PROTO_marketplace_name:n}}),r.oldVersion,r.newVersion,{...u(t,n,l())}}await c(0)}catch(t){T(t,`update`,e)}}export{D as a,E as i,k as n,j as o,O as r,A as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{cx as t,lx as n}from"./loadAgentsDir-uuZYOgKn.js";import{C as r,S as i,c as a,f as o,i as s,u as c,x as l}from"./debug-2pVES-2G.js";import{o as u,s as d}from"./log-L1kqxa_P.js";import{join as f}from"path";import{randomBytes as p}from"crypto";import{readFile as m,rename as h,unlink as g,writeFile as _}from"fs/promises";function v(){return f(t(),D)}function y(e){let t=i(e);if(typeof t!=`object`||!t||!(`plugins`in t)||typeof t.plugins!=`object`||t.plugins===null)return{};let n=t.plugins,r={};for(let[e,t]of Object.entries(n))if(t&&typeof t==`object`&&`flaggedAt`in t&&typeof t.flaggedAt==`string`){let n={flaggedAt:t.flaggedAt};`seenAt`in t&&typeof t.seenAt==`string`&&(n.seenAt=t.seenAt),r[e]=n}return r}async function b(){try{return y(await m(v(),{encoding:`utf-8`}))}catch{return{}}}async function x(e){let n=v(),i=`${n}.${p(8).toString(`hex`)}.tmp`;try{await c().mkdir(t()),await _(i,r({plugins:e},null,2),{encoding:`utf-8`,mode:384}),await h(i,n),k=e}catch(e){d(e);try{await g(i)}catch{}}}async function S(){let e=await b(),t=Date.now(),n=!1;for(let[r,i]of Object.entries(e))i.seenAt&&t-new Date(i.seenAt).getTime()>=O&&(delete e[r],n=!0);k=e,n&&await x(e)}function C(){return k??{}}async function w(e){k===null&&(k=await b()),await x({...k,[e]:{flaggedAt:new Date().toISOString()}}),a(`Flagged plugin: ${e}`)}async function T(e){k===null&&(k=await b());let t=new Date().toISOString(),n=!1,r={...k};for(let i of e){let e=r[i];e&&!e.seenAt&&(r[i]={...e,seenAt:t},n=!0)}n&&await x(r)}async function E(e){if(k===null&&(k=await b()),!(e in k))return;let{[e]:t,...n}=k;k=n,await x(n)}var D,O,k,A=e((()=>{s(),o(),u(),l(),n(),D=`flagged-plugins.json`,O=2880*60*1e3,k=null}));export{T as a,S as i,C as n,E as o,A as r,w as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{cx as t,lx as n}from"./loadAgentsDir-bmpKLPdG.js";import{C as r,S as i,c as a,f as o,i as s,u as c,x as l}from"./debug-2pVES-2G.js";import{o as u,s as d}from"./log-L1kqxa_P.js";import{join as f}from"path";import{randomBytes as p}from"crypto";import{readFile as m,rename as h,unlink as g,writeFile as _}from"fs/promises";function v(){return f(t(),D)}function y(e){let t=i(e);if(typeof t!=`object`||!t||!(`plugins`in t)||typeof t.plugins!=`object`||t.plugins===null)return{};let n=t.plugins,r={};for(let[e,t]of Object.entries(n))if(t&&typeof t==`object`&&`flaggedAt`in t&&typeof t.flaggedAt==`string`){let n={flaggedAt:t.flaggedAt};`seenAt`in t&&typeof t.seenAt==`string`&&(n.seenAt=t.seenAt),r[e]=n}return r}async function b(){try{return y(await m(v(),{encoding:`utf-8`}))}catch{return{}}}async function x(e){let n=v(),i=`${n}.${p(8).toString(`hex`)}.tmp`;try{await c().mkdir(t()),await _(i,r({plugins:e},null,2),{encoding:`utf-8`,mode:384}),await h(i,n),k=e}catch(e){d(e);try{await g(i)}catch{}}}async function S(){let e=await b(),t=Date.now(),n=!1;for(let[r,i]of Object.entries(e))i.seenAt&&t-new Date(i.seenAt).getTime()>=O&&(delete e[r],n=!0);k=e,n&&await x(e)}function C(){return k??{}}async function w(e){k===null&&(k=await b()),await x({...k,[e]:{flaggedAt:new Date().toISOString()}}),a(`Flagged plugin: ${e}`)}async function T(e){k===null&&(k=await b());let t=new Date().toISOString(),n=!1,r={...k};for(let i of e){let e=r[i];e&&!e.seenAt&&(r[i]={...e,seenAt:t},n=!0)}n&&await x(r)}async function E(e){if(k===null&&(k=await b()),!(e in k))return;let{[e]:t,...n}=k;k=n,await x(n)}var D,O,k,A=e((()=>{s(),o(),u(),l(),n(),D=`flagged-plugins.json`,O=2880*60*1e3,k=null}));export{T as a,S as i,C as n,E as o,A as r,w as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{m as t,s as n,y as r}from"./settings-D4M13toi.js";import{Pt as i,q as a}from"./state-CXY-q5gr.js";import{Ax as o,Ba as s,Cx as c,Ex as l,Fa as u,Ga as d,Ha as f,Jm as p,Ka as m,La as h,Ma as g,Mo as _,Na as v,No as y,Pa as b,Po as x,Sx as S,Tx as C,Ua as w,Wa as T,Xm as E,Ya as ee,ax as te,bx as D,do as ne,eo as O,ja as k,jx as A,ka as j,lo as M,lx as re,no as ie,ro as ae,so as oe,to as N,uo as se,xx as P,za as ce}from"./loadAgentsDir-uuZYOgKn.js";import{I as F,R as I,V as L,f as R,u as z}from"./debug-2pVES-2G.js";import{o as B,s as V}from"./log-L1kqxa_P.js";import{l as H,o as U}from"./stringUtils-Cs6E5f-B.js";import{n as W,t as G}from"./pluginStartupCheck-DftTiXct.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?a():void 0}function de(e){return n(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let r of[`local`,`project`,`user`]){let i=n(l(r))?.enabledPlugins;if(i){for(let n of Object.keys(i))if(t?n===e:n.startsWith(`${e}@`))return{pluginId:n,scope:r}}}return null}function pe(e,t){let{name:n,marketplace:r}=C(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=C(e),n=N();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=C(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=N().plugins[e];if(!t||t.length===0)return{scope:`user`};let n=a(),r=t.find(e=>e.scope===`local`&&e.projectPath===n);if(r)return{scope:r.scope,projectPath:r.projectPath};let i=t.find(e=>e.scope===`project`&&e.projectPath===n);if(i)return{scope:i.scope,projectPath:i.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=C(e),i,a,o;if(r){let t=await M(e);t&&(i=t.entry,a=r,o=t.marketplaceInstallLocation)}else{let e=await ne();for(let[t,r]of Object.entries(e))try{let e=(await oe(t)).plugins.find(e=>e.name===n);if(e){i=e,a=t,o=r.installLocation;break}}catch(e){V(L(e))}}if(!i||!a)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let s=i,c=`${s.name}@${a}`,l=await f({pluginId:c,entry:s,scope:t,marketplaceInstallLocation:o});if(!l.ok){let e=l;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:ce(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${c} (scope: ${t})${l.depNote}`,pluginId:c,pluginName:s.name,scope:t}}async function ge(e,t=`user`,i=!0){q(t);let{enabled:a,disabled:o}=await u(),s=[...a,...o],c=pe(e,s),d=l(t),f=n(d),m,h;if(c)m=Object.keys(f?.enabledPlugins??{}).find(t=>t===e||t===c.name||t.startsWith(`${c.name}@`))??(e.includes(`@`)?e:c.name),h=c.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};m=t.pluginId,h=t.pluginName}let g=J(t),v=N().plugins[m],y=v?.find(e=>e.scope===t&&e.projectPath===g);if(!y){let{scope:n}=Y(m);return n!==t&&v&&v.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.workmate/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let b=y.installPath,S={...f?.enabledPlugins};S[m]=void 0,r(d,{enabledPlugins:S}),_(),ie(m,t,g);let C=N().plugins[m],w=!C||C.length===0;w&&b&&await x(b),w&&(p(m),i&&await te(m));let T=D(m,s),E=P(T);return{success:!0,message:`Successfully uninstalled plugin: ${h} (scope: ${t})${E}`,pluginId:m,pluginName:h,scope:t,reverseDependents:T.length>0?T:void 0}}async function X(e,t,i){let a=t?`enable`:`disable`;if(A(e)){let{error:i}=r(`userSettings`,{enabledPlugins:{...n(`userSettings`)?.enabledPlugins,[e]:t}});if(i)return{success:!1,message:`Failed to ${a} built-in plugin: ${i.message}`};_();let{name:o}=C(e);return{success:!0,message:`Successfully ${a}d built-in plugin: ${o}`,pluginId:e,pluginName:o,scope:`user`}}i&&q(i);let o,s,c=fe(e);if(i)if(s=i,c)o=c.pluginId;else if(e.includes(`@`))o=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(c)o=c.pluginId,s=c.scope;else if(e.includes(`@`))o=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&m(o))return{success:!1,message:`Plugin "${o}" is blocked by your organization's policy and cannot be enabled`};let d=l(s),f=n(d)?.enabledPlugins?.[o],p={user:0,project:1,local:2},h=i&&c&&p[i]>p[c.scope];if(i&&f===void 0&&c&&c.scope!==i&&!h)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${i}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(t===(i&&!h?f===!0:G().has(o)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${i?` at ${i} scope`:``}`};let g;if(!t){let{enabled:e,disabled:t}=await u(),n=D(o,[...e,...t]);n.length>0&&(g=n)}let{error:v}=r(d,{enabledPlugins:{...n(d)?.enabledPlugins,[o]:t}});if(v)return{success:!1,message:`Failed to ${a} plugin: ${v.message}`};_();let{name:y}=C(o),b=P(g);return{success:!0,message:`Successfully ${a}d plugin: ${y} (scope: ${s})${b}`,pluginId:o,pluginName:y,scope:s,reverseDependents:g}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${H(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{m as t,s as n,y as r}from"./settings-D4M13toi.js";import{Pt as i,q as a}from"./state-CXY-q5gr.js";import{Ax as o,Ba as s,Cx as c,Ex as l,Fa as u,Ga as d,Ha as f,Jm as p,Ka as m,La as h,Ma as g,Mo as _,Na as v,No as y,Pa as b,Po as x,Sx as S,Tx as C,Ua as w,Wa as T,Xm as E,Ya as ee,ax as te,bx as D,do as ne,eo as O,ja as k,jx as A,ka as j,lo as M,lx as re,no as ie,ro as ae,so as oe,to as N,uo as se,xx as P,za as ce}from"./loadAgentsDir-bmpKLPdG.js";import{I as F,R as I,V as L,f as R,u as z}from"./debug-2pVES-2G.js";import{o as B,s as V}from"./log-L1kqxa_P.js";import{l as H,o as U}from"./stringUtils-Cs6E5f-B.js";import{n as W,t as G}from"./pluginStartupCheck-QG0d95dE.js";import{dirname as le,join as K}from"path";function q(e){if(!Q.includes(e))throw Error(`Invalid scope "${e}". Must be one of: ${Q.join(`, `)}`)}function ue(e){return Q.includes(e)}function J(e){return e===`project`||e===`local`?a():void 0}function de(e){return n(`projectSettings`)?.enabledPlugins?.[e]===!0}function fe(e){let t=e.includes(`@`);for(let r of[`local`,`project`,`user`]){let i=n(l(r))?.enabledPlugins;if(i){for(let n of Object.keys(i))if(t?n===e:n.startsWith(`${e}@`))return{pluginId:n,scope:r}}}return null}function pe(e,t){let{name:n,marketplace:r}=C(e);return t.find(t=>t.name===e||t.name===n?!0:r&&t.source?t.name===n&&t.source.includes(`@${r}`):!1)}function me(e){let{name:t}=C(e),n=N();if(n.plugins[e]?.length)return{pluginId:e,pluginName:t};let r=Object.keys(n.plugins).find(e=>{let{name:r}=C(e);return r===t&&(n.plugins[e]?.length??0)>0});return r?{pluginId:r,pluginName:t}:null}function Y(e){let t=N().plugins[e];if(!t||t.length===0)return{scope:`user`};let n=a(),r=t.find(e=>e.scope===`local`&&e.projectPath===n);if(r)return{scope:r.scope,projectPath:r.projectPath};let i=t.find(e=>e.scope===`project`&&e.projectPath===n);if(i)return{scope:i.scope,projectPath:i.projectPath};let o=t.find(e=>e.scope===`user`);return o?{scope:o.scope}:{scope:t[0].scope,projectPath:t[0].projectPath}}async function he(e,t=`user`){q(t);let{name:n,marketplace:r}=C(e),i,a,o;if(r){let t=await M(e);t&&(i=t.entry,a=r,o=t.marketplaceInstallLocation)}else{let e=await ne();for(let[t,r]of Object.entries(e))try{let e=(await oe(t)).plugins.find(e=>e.name===n);if(e){i=e,a=t,o=r.installLocation;break}}catch(e){V(L(e))}}if(!i||!a)return{success:!1,message:`Plugin "${n}" not found in ${r?`marketplace "${r}"`:`any configured marketplace`}`};let s=i,c=`${s.name}@${a}`,l=await f({pluginId:c,entry:s,scope:t,marketplaceInstallLocation:o});if(!l.ok){let e=l;switch(e.reason){case`local-source-no-location`:return{success:!1,message:`Cannot install local plugin "${e.pluginName}" without marketplace install location`};case`settings-write-failed`:return{success:!1,message:`Failed to update settings: ${e.message}`};case`resolution-failed`:return{success:!1,message:ce(e.resolution)};case`blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" is blocked by your organization's policy and cannot be installed`};case`dependency-blocked-by-policy`:return{success:!1,message:`Plugin "${e.pluginName}" depends on "${e.blockedDependency}", which is blocked by your organization's policy`}}}return{success:!0,message:`Successfully installed plugin: ${c} (scope: ${t})${l.depNote}`,pluginId:c,pluginName:s.name,scope:t}}async function ge(e,t=`user`,i=!0){q(t);let{enabled:a,disabled:o}=await u(),s=[...a,...o],c=pe(e,s),d=l(t),f=n(d),m,h;if(c)m=Object.keys(f?.enabledPlugins??{}).find(t=>t===e||t===c.name||t.startsWith(`${c.name}@`))??(e.includes(`@`)?e:c.name),h=c.name;else{let t=me(e);if(!t)return{success:!1,message:`Plugin "${e}" not found in installed plugins`};m=t.pluginId,h=t.pluginName}let g=J(t),v=N().plugins[m],y=v?.find(e=>e.scope===t&&e.projectPath===g);if(!y){let{scope:n}=Y(m);return n!==t&&v&&v.length>0?n===`project`?{success:!1,message:`Plugin "${e}" is enabled at project scope (.workmate/settings.json, shared with your team). To disable just for you: claude plugin disable ${e} --scope local`}:{success:!1,message:`Plugin "${e}" is installed in ${n} scope, not ${t}. Use --scope ${n} to uninstall.`}:{success:!1,message:`Plugin "${e}" is not installed in ${t} scope. Use --scope to specify the correct scope.`}}let b=y.installPath,S={...f?.enabledPlugins};S[m]=void 0,r(d,{enabledPlugins:S}),_(),ie(m,t,g);let C=N().plugins[m],w=!C||C.length===0;w&&b&&await x(b),w&&(p(m),i&&await te(m));let T=D(m,s),E=P(T);return{success:!0,message:`Successfully uninstalled plugin: ${h} (scope: ${t})${E}`,pluginId:m,pluginName:h,scope:t,reverseDependents:T.length>0?T:void 0}}async function X(e,t,i){let a=t?`enable`:`disable`;if(A(e)){let{error:i}=r(`userSettings`,{enabledPlugins:{...n(`userSettings`)?.enabledPlugins,[e]:t}});if(i)return{success:!1,message:`Failed to ${a} built-in plugin: ${i.message}`};_();let{name:o}=C(e);return{success:!0,message:`Successfully ${a}d built-in plugin: ${o}`,pluginId:e,pluginName:o,scope:`user`}}i&&q(i);let o,s,c=fe(e);if(i)if(s=i,c)o=c.pluginId;else if(e.includes(`@`))o=e;else return{success:!1,message:`Plugin "${e}" not found in settings. Use plugin@marketplace format.`};else if(c)o=c.pluginId,s=c.scope;else if(e.includes(`@`))o=e,s=`user`;else return{success:!1,message:`Plugin "${e}" not found in any editable settings scope. Use plugin@marketplace format.`};if(t&&m(o))return{success:!1,message:`Plugin "${o}" is blocked by your organization's policy and cannot be enabled`};let d=l(s),f=n(d)?.enabledPlugins?.[o],p={user:0,project:1,local:2},h=i&&c&&p[i]>p[c.scope];if(i&&f===void 0&&c&&c.scope!==i&&!h)return{success:!1,message:`Plugin "${e}" is installed at ${c.scope} scope, not ${i}. Use --scope ${c.scope} or omit --scope to auto-detect.`};if(t===(i&&!h?f===!0:G().has(o)))return{success:!1,message:`Plugin "${e}" is already ${t?`enabled`:`disabled`}${i?` at ${i} scope`:``}`};let g;if(!t){let{enabled:e,disabled:t}=await u(),n=D(o,[...e,...t]);n.length>0&&(g=n)}let{error:v}=r(d,{enabledPlugins:{...n(d)?.enabledPlugins,[o]:t}});if(v)return{success:!1,message:`Failed to ${a} plugin: ${v.message}`};_();let{name:y}=C(o),b=P(g);return{success:!0,message:`Successfully ${a}d plugin: ${y} (scope: ${s})${b}`,pluginId:o,pluginName:y,scope:s,reverseDependents:g}}async function _e(e,t){return X(e,!0,t)}async function ve(e,t){return X(e,!1,t)}async function Z(){let e=G();if(e.size===0)return{success:!0,message:`No enabled plugins to disable`};let t=[],n=[];for(let[r]of e){let e=await X(r,!1);e.success?t.push(r):n.push(`${r}: ${e.message}`)}return n.length>0?{success:!1,message:`Disabled ${t.length} ${H(t.length,`plugin`)}, ${n.length} failed:\n${n.join(`
2
2
  `)}`}:{success:!0,message:`Disabled ${t.length} ${H(t.length,`plugin`)}`}}async function ye(e,t){let{name:n,marketplace:r}=C(e),i=r?`${n}@${r}`:e,a=await M(e);if(!a)return{success:!1,message:`Plugin "${n}" not found`,pluginId:i,scope:t};let{entry:o,marketplaceInstallLocation:s}=a,c=O().plugins[i];if(!c||c.length===0)return{success:!1,message:`Plugin "${n}" is not installed`,pluginId:i,scope:t};let l=J(t),u=c.find(e=>e.scope===t&&e.projectPath===l);return u?be({pluginId:i,pluginName:n,entry:o,marketplaceInstallLocation:s,installation:u,scope:t,projectPath:l}):{success:!1,message:`Plugin "${n}" is not installed at scope ${l?`${t} (${l})`:t}`,pluginId:i,scope:t}}async function be({pluginId:e,pluginName:t,entry:n,marketplaceInstallLocation:r,installation:i,scope:a,projectPath:o}){let s=z(),c=i.version,l,u,d=!1,f;if(typeof n.source!=`string`){let t=await j(n.source,{manifest:{name:n.name}});l=t.path,d=!0,f=t.gitCommitSha,u=await w(e,n.source,t.manifest,t.path,n.version,t.gitCommitSha)}else{let t;try{t=await s.stat(r)}catch(t){if(I(t))return{success:!1,message:`Marketplace directory not found at ${r}`,pluginId:e,scope:a};throw t}l=K(t.isDirectory()?r:le(r),n.source);try{await s.stat(l)}catch(t){if(I(t))return{success:!1,message:`Plugin source not found at ${l}`,pluginId:e,scope:a};throw t}let i,o=K(l,`.claude-plugin`,`plugin.json`);try{i=await h(o,n.name,n.source)}catch{}u=await w(e,n.source,i,l,n.version)}try{let r=g(e,u),s=v(e,u);if(i.version===u||i.installPath===r||i.installPath===s)return{success:!0,message:`${t} is already at the latest version (${u}).`,pluginId:e,newVersion:u,oldVersion:c,alreadyUpToDate:!0,scope:a};r=await k(l,e,u,n);let d=i.installPath;if(ae(e,a,o,r,u,f),d&&d!==r){let e=O();Object.values(e.plugins).some(e=>e.some(e=>e.installPath===d))||await x(d)}let p=o?`${a} (${o})`:a;return{success:!0,message:`Plugin "${t}" updated from ${c||`unknown`} to ${u} for scope ${p}. Restart to apply changes.`,pluginId:e,newVersion:u,oldVersion:c,scope:a}}finally{d&&l!==g(e,u)&&await s.rm(l,{recursive:!0,force:!0})}}var Q,$,xe=e((()=>{i(),o(),F(),R(),B(),y(),S(),ee(),se(),re(),c(),s(),b(),E(),d(),W(),T(),t(),U(),Q=[`user`,`project`,`local`],$=[`user`,`project`,`local`,`managed`]}));export{_e as a,he as c,ge as d,ye as f,ve as i,ue as l,$ as n,Y as o,Z as r,xe as s,Q as t,de as u};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{gt as t,m as n,s as r}from"./settings-D4M13toi.js";import{Ba as i,Cx as a,Dx as o,Ox as s,Ya as c,uo as l}from"./loadAgentsDir-uuZYOgKn.js";import{n as u}from"./cwd-DrEEb4f5.js";import{c as d,i as f}from"./debug-2pVES-2G.js";import{o as p}from"./log-L1kqxa_P.js";import"path";function m(){let e=new Map,t=o();for(let[n,r]of Object.entries(t))n.includes(`@`)&&(r===!0?e.set(n,`flag`):r===!1&&e.delete(n));for(let{scope:n,source:i}of[{scope:`managed`,source:`policySettings`},{scope:`user`,source:`userSettings`},{scope:`project`,source:`projectSettings`},{scope:`local`,source:`localSettings`},{scope:`flag`,source:`flagSettings`}]){let a=r(i);if(a?.enabledPlugins)for(let[r,o]of Object.entries(a.enabledPlugins))r.includes(`@`)&&(r in t&&t[r]!==o&&d(`Plugin ${r} from --add-dir (${t[r]}) overridden by ${i} (${o})`),o===!0?e.set(r,n):o===!1&&e.delete(r))}return d(`Found ${e.size} enabled plugins with scopes: ${Array.from(e.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)}`),e}var h=e((()=>{u(),f(),p(),n(),s(),c(),l(),a(),i(),t()}));export{h as n,m as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{gt as t,m as n,s as r}from"./settings-D4M13toi.js";import{Ba as i,Cx as a,Dx as o,Ox as s,Ya as c,uo as l}from"./loadAgentsDir-bmpKLPdG.js";import{n as u}from"./cwd-DrEEb4f5.js";import{c as d,i as f}from"./debug-2pVES-2G.js";import{o as p}from"./log-L1kqxa_P.js";import"path";function m(){let e=new Map,t=o();for(let[n,r]of Object.entries(t))n.includes(`@`)&&(r===!0?e.set(n,`flag`):r===!1&&e.delete(n));for(let{scope:n,source:i}of[{scope:`managed`,source:`policySettings`},{scope:`user`,source:`userSettings`},{scope:`project`,source:`projectSettings`},{scope:`local`,source:`localSettings`},{scope:`flag`,source:`flagSettings`}]){let a=r(i);if(a?.enabledPlugins)for(let[r,o]of Object.entries(a.enabledPlugins))r.includes(`@`)&&(r in t&&t[r]!==o&&d(`Plugin ${r} from --add-dir (${t[r]}) overridden by ${i} (${o})`),o===!0?e.set(r,n):o===!1&&e.delete(r))}return d(`Found ${e.size} enabled plugins with scopes: ${Array.from(e.entries()).map(([e,t])=>`${e}(${t})`).join(`, `)}`),e}var h=e((()=>{u(),f(),p(),n(),s(),c(),l(),a(),i(),t()}));export{h as n,m as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./pluginStartupCheck-QG0d95dE.js";e();export{t as getPluginEditableScopes};
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./figures-5ThXQEtq.js";import{Bn as n,Pt as r}from"./state-CXY-q5gr.js";import{$a as i,Ao as a,Cx as o,Ex as s,Fa as c,Mo as l,Mx as u,No as d,Nx as f,Oo as p,Pa as m,So as h,Tx as g,Ya as _,_f as v,do as y,go as ee,io as te,mo as b,po as x,to as S,uo as C,vf as w,vo as T}from"./loadAgentsDir-uuZYOgKn.js";import{C as E,I as ne,M as D,x as re}from"./debug-2pVES-2G.js";import{o as O,s as k}from"./log-L1kqxa_P.js";import{n as A}from"./analytics-COpjZpvd.js";import{l as j,o as M}from"./stringUtils-Cs6E5f-B.js";import{n as N,t as P}from"./exit-s9XGerrH.js";import{n as F,s as I,t as L}from"./pluginOperations-Ca_T-HYn.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./pluginCliCommands-CACeyIwz.js";import{a as ie,c as W,i as G,n as K,r as q,s as J,t as Y}from"./validatePlugin-fx1Y8vam.js";import{basename as ae,dirname as X}from"path";e(),r(),A(),I(),f(),ne(),O(),d(),W(),_(),p(),C(),v(),G(),o(),m(),Y(),re(),M();function Z(e,n){k(e),P(`${t.cross} Failed to ${n}: ${D(e)}`)}function Q(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${j(e.errors.length,`error`)}:\n`),e.errors.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``)),e.warnings.length>0&&(console.log(`${t.warning} Found ${e.warnings.length} ${j(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function oe(e,r){r.cowork&&n(!0);try{let n=await K(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),Q(n);let r=[];if(n.fileType===`plugin`){let e=X(n.filePath);if(ae(e)===`.claude-plugin`){r=await q(X(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),Q(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?N(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){k(e),console.error(`${t.cross} Unexpected error during validation: ${D(e)}`),process.exit(2)}}async function se(e){e.cowork&&n(!0);let r=S(),{getPluginEditableScopes:o}=await import(`./pluginStartupCheck-Du9yx2P8.js`),s=o(),l=Object.keys(r.plugins),{enabled:d,disabled:f,errors:p}=await c(),m=[...d,...f],_=m.filter(e=>e.source.endsWith(`@inline`)),v=p.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(m.map(e=>[e.source,e])),n=[];for(let e of l.sort()){let i=r.plugins[e];if(!i||i.length===0)continue;let a=g(e).name,o=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(u);for(let r of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await w(i);e&&Object.keys(e).length>0&&(a=e)}n.push({id:e,version:r.version||`unknown`,scope:r.scope,enabled:s.has(e),installPath:r.installPath,installedAt:r.installedAt,lastUpdated:r.lastUpdated,projectPath:r.projectPath,mcpServers:a,errors:o.length>0?o:void 0})}}for(let e of _){let t=e.mcpServers||await w(e),r=v.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(u);n.push({id:e.source,version:e.manifest.version??`unknown`,scope:`session`,enabled:e.enabled!==!1,installPath:e.path,mcpServers:t&&Object.keys(t).length>0?t:void 0,errors:r.length>0?r:void 0})}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))n.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[u(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([y(),J()]),{marketplaces:r}=await a(t);for(let{name:t,data:a}of r)if(a)for(let r of a.plugins){let a=h(r.name,t);i(a)||e.push({pluginId:a,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(a)})}}catch{}N(E({installed:n,available:e},null,2))}else N(E(n,null,2))}l.length===0&&_.length===0&&v.length===0&&N("No plugins installed. Use `wm plugin install` to install a plugin."),l.length>0&&console.log(`Installed plugins:
1
+ import{n as e,t}from"./figures-5ThXQEtq.js";import{Bn as n,Pt as r}from"./state-CXY-q5gr.js";import{$a as i,Ao as a,Cx as o,Ex as s,Fa as c,Mo as l,Mx as u,No as d,Nx as f,Oo as p,Pa as m,So as h,Tx as g,Ya as _,_f as v,do as y,go as ee,io as te,mo as b,po as x,to as S,uo as C,vf as w,vo as T}from"./loadAgentsDir-bmpKLPdG.js";import{C as E,I as ne,M as D,x as re}from"./debug-2pVES-2G.js";import{o as O,s as k}from"./log-L1kqxa_P.js";import{n as A}from"./analytics-COpjZpvd.js";import{l as j,o as M}from"./stringUtils-Cs6E5f-B.js";import{n as N,t as P}from"./exit-s9XGerrH.js";import{n as F,s as I,t as L}from"./pluginOperations-BCvJvfOC.js";import{a as R,i as z,n as B,o as V,r as H,t as U}from"./pluginCliCommands-Dyk4HYHs.js";import{a as ie,c as W,i as G,n as K,r as q,s as J,t as Y}from"./validatePlugin-CTVnWx9H.js";import{basename as ae,dirname as X}from"path";e(),r(),A(),I(),f(),ne(),O(),d(),W(),_(),p(),C(),v(),G(),o(),m(),Y(),re(),M();function Z(e,n){k(e),P(`${t.cross} Failed to ${n}: ${D(e)}`)}function Q(e){e.errors.length>0&&(console.log(`${t.cross} Found ${e.errors.length} ${j(e.errors.length,`error`)}:\n`),e.errors.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``)),e.warnings.length>0&&(console.log(`${t.warning} Found ${e.warnings.length} ${j(e.warnings.length,`warning`)}:\n`),e.warnings.forEach(e=>{console.log(` ${t.pointer} ${e.path}: ${e.message}`)}),console.log(``))}async function oe(e,r){r.cowork&&n(!0);try{let n=await K(e);console.log(`Validating ${n.fileType} manifest: ${n.filePath}\n`),Q(n);let r=[];if(n.fileType===`plugin`){let e=X(n.filePath);if(ae(e)===`.claude-plugin`){r=await q(X(e));for(let e of r)console.log(`Validating ${e.fileType}: ${e.filePath}\n`),Q(e)}}let i=n.success&&r.every(e=>e.success),a=n.warnings.length>0||r.some(e=>e.warnings.length>0);i?N(a?`${t.tick} Validation passed with warnings`:`${t.tick} Validation passed`):(console.log(`${t.cross} Validation failed`),process.exit(1))}catch(e){k(e),console.error(`${t.cross} Unexpected error during validation: ${D(e)}`),process.exit(2)}}async function se(e){e.cowork&&n(!0);let r=S(),{getPluginEditableScopes:o}=await import(`./pluginStartupCheck-o_TC7wIt.js`),s=o(),l=Object.keys(r.plugins),{enabled:d,disabled:f,errors:p}=await c(),m=[...d,...f],_=m.filter(e=>e.source.endsWith(`@inline`)),v=p.filter(e=>e.source.endsWith(`@inline`)||e.source.startsWith(`inline[`));if(e.json){let t=new Map(m.map(e=>[e.source,e])),n=[];for(let e of l.sort()){let i=r.plugins[e];if(!i||i.length===0)continue;let a=g(e).name,o=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===a).map(u);for(let r of i){let i=t.get(e),a;if(i){let e=i.mcpServers||await w(i);e&&Object.keys(e).length>0&&(a=e)}n.push({id:e,version:r.version||`unknown`,scope:r.scope,enabled:s.has(e),installPath:r.installPath,installedAt:r.installedAt,lastUpdated:r.lastUpdated,projectPath:r.projectPath,mcpServers:a,errors:o.length>0?o:void 0})}}for(let e of _){let t=e.mcpServers||await w(e),r=v.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name).map(u);n.push({id:e.source,version:e.manifest.version??`unknown`,scope:`session`,enabled:e.enabled!==!1,installPath:e.path,mcpServers:t&&Object.keys(t).length>0?t:void 0,errors:r.length>0?r:void 0})}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))n.push({id:e.source,version:`unknown`,scope:`session`,enabled:!1,installPath:`path`in e?e.path:``,errors:[u(e)]});if(e.available){let e=[];try{let[t,n]=await Promise.all([y(),J()]),{marketplaces:r}=await a(t);for(let{name:t,data:a}of r)if(a)for(let r of a.plugins){let a=h(r.name,t);i(a)||e.push({pluginId:a,name:r.name,description:r.description,marketplaceName:t,version:r.version,source:r.source,installCount:n?.get(a)})}}catch{}N(E({installed:n,available:e},null,2))}else N(E(n,null,2))}l.length===0&&_.length===0&&v.length===0&&N("No plugins installed. Use `wm plugin install` to install a plugin."),l.length>0&&console.log(`Installed plugins:
2
2
  `);for(let e of l.sort()){let n=r.plugins[e];if(!n||n.length===0)continue;let i=g(e).name,a=p.filter(t=>t.source===e||`plugin`in t&&t.plugin===i);for(let r of n){let n=s.has(e),i=a.length>0?`${t.cross} failed to load`:n?`${t.tick} enabled`:`${t.cross} disabled`,o=r.version||`unknown`,c=r.scope;console.log(` ${t.pointer} ${e}`),console.log(` Version: ${o}`),console.log(` Scope: ${c}`),console.log(` Status: ${i}`);for(let e of a)console.log(` Error: ${u(e)}`);console.log(``)}}if(_.length>0||v.length>0){console.log(`Session-only plugins (--plugin-dir):
3
3
  `);for(let e of _){let n=v.filter(t=>t.source===e.source||`plugin`in t&&t.plugin===e.name),r=n.length>0?`${t.cross} loaded with errors`:`${t.tick} loaded`;console.log(` ${t.pointer} ${e.source}`),console.log(` Version: ${e.manifest.version??`unknown`}`),console.log(` Path: ${e.path}`),console.log(` Status: ${r}`);for(let e of n)console.log(` Error: ${u(e)}`);console.log(``)}for(let e of v.filter(e=>e.source.startsWith(`inline[`)))console.log(` ${t.pointer} ${e.source}: ${t.cross} ${u(e)}\n`)}N()}async function ce(e,r){r.cowork&&n(!0);try{let n=await ie(e);n||P(`${t.cross} Invalid marketplace source format. Try: owner/repo, https://..., or ./path`),`error`in n&&P(`${t.cross} ${n.error}`);let i=r.scope??`user`;i!==`user`&&i!==`project`&&i!==`local`&&P(`${t.cross} Invalid scope '${i}'. Use: user, project, or local`);let a=s(i),o=n;r.sparse&&r.sparse.length>0&&(o.source===`github`||o.source===`git`?o={...o,sparsePaths:r.sparse}:P(`${t.cross} --sparse is only supported for github and git marketplace sources (got: ${o.source})`)),console.log(`Adding marketplace...`);let{name:c,alreadyMaterialized:u,resolvedSource:d}=await te(o,e=>{console.log(e)});T(c,{source:d},a),l(),o.source,o.source===`github`&&o.repo,N(u?`${t.tick} Marketplace '${c}' already on disk — declared in ${i} settings`:`${t.tick} Successfully added marketplace: ${c} (declared in ${i} settings)`)}catch(e){Z(e,`add marketplace`)}}async function le(e){e.cowork&&n(!0);try{let n=await y(),r=Object.keys(n);e.json&&N(E(r.sort().map(e=>{let t=n[e],r=t?.source;return{name:e,source:r?.source,...r?.source===`github`&&{repo:r.repo},...r?.source===`git`&&{url:r.url},...r?.source===`url`&&{url:r.url},...r?.source===`directory`&&{path:r.path},...r?.source===`file`&&{path:r.path},installLocation:t?.installLocation}}),null,2)),r.length===0&&N(`No marketplaces configured`),console.log(`Configured marketplaces:
4
4
  `),r.forEach(e=>{let r=n[e];if(console.log(` ${t.pointer} ${e}`),r?.source){let e=r.source;e.source===`github`?console.log(` Source: GitHub (${e.repo})`):e.source===`git`?console.log(` Source: Git (${e.url})`):e.source===`url`?console.log(` Source: URL (${e.url})`):e.source===`directory`?console.log(` Source: Directory (${e.path})`):e.source===`file`&&console.log(` Source: File (${e.path})`)}console.log(``)}),N()}catch(e){Z(e,`list marketplaces`)}}async function $(e,r){r.cowork&&n(!0);try{await ee(e),l(),N(`${t.tick} Successfully removed marketplace: ${e}`)}catch(e){Z(e,`remove marketplace`)}}async function ue(e,r){r.cowork&&n(!0);try{if(e)console.log(`Updating marketplace: ${e}...`),await b(e,e=>{console.log(e)}),l(),N(`${t.tick} Successfully updated marketplace: ${e}`);else{let e=await y(),n=Object.keys(e);n.length===0&&N(`No marketplaces configured`),console.log(`Updating ${n.length} marketplace(s)...`),await x(),l(),n.length,N(`${t.tick} Successfully updated ${n.length} marketplace(s)`)}}catch(e){Z(e,`update marketplace(s)`)}}async function de(e,t){t.cowork&&n(!0);let r=t.scope||`user`;t.cowork&&r!==`user`&&P(`--cowork can only be used with user scope`),L.includes(r)||P(`Invalid scope: ${r}. Must be one of: ${L.join(`, `)}.`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await z(e,r)}async function fe(e,t){t.cowork&&n(!0);let r=t.scope||`user`;t.cowork&&r!==`user`&&P(`--cowork can only be used with user scope`),L.includes(r)||P(`Invalid scope: ${r}. Must be one of: ${L.join(`, `)}.`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await R(e,r,t.keepData)}async function pe(e,t){t.cowork&&n(!0);let r;t.scope&&(L.includes(t.scope)||P(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),r=t.scope),t.cowork&&r!==void 0&&r!==`user`&&P(`--cowork can only be used with user scope`),t.cowork&&r===void 0&&(r=`user`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await H(e,r)}async function me(e,t){if(t.all&&e&&P(`Cannot use --all with a specific plugin`),!t.all&&!e&&P(`Please specify a plugin name or use --all to disable all plugins`),t.cowork&&n(!0),t.all){t.scope&&P(`Cannot use --scope with --all`),await U();return}let r;t.scope&&(L.includes(t.scope)||P(`Invalid scope "${t.scope}". Valid scopes: ${L.join(`, `)}`),r=t.scope),t.cowork&&r!==void 0&&r!==`user`&&P(`--cowork can only be used with user scope`),t.cowork&&r===void 0&&(r=`user`);let{name:i,marketplace:a}=g(e);({...a&&{_PROTO_marketplace_name:a}}),await B(e,r)}async function he(e,t){t.cowork&&n(!0);let{name:r,marketplace:i}=g(e);({...i&&{_PROTO_marketplace_name:i}});let a=`user`;t.scope&&(F.includes(t.scope)||P(`Invalid scope "${t.scope}". Valid scopes: ${F.join(`, `)}`),a=t.scope),t.cowork&&a!==`user`&&P(`--cowork can only be used with user scope`),await V(e,a)}export{ce as marketplaceAddHandler,le as marketplaceListHandler,$ as marketplaceRemoveHandler,ue as marketplaceUpdateHandler,me as pluginDisableHandler,pe as pluginEnableHandler,de as pluginInstallHandler,se as pluginListHandler,fe as pluginUninstallHandler,he as pluginUpdateHandler,oe as pluginValidateHandler};