@readmagic/workmate 0.0.15 → 0.0.17

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 (274) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-DcVnvL_u.js → AddWorkspaceDirectory-YAhnVwyN.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog--D4BeNAN.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-D6DopTxc.js → AgentsMdExternalIncludesDialog-Ba4GYFl3.js} +1 -1
  4. package/dist/chunks/{App-BoI5EJry.js → App-mri25OrC.js} +1 -1
  5. package/dist/chunks/{ApproveApiKey-BjlQDcMx.js → ApproveApiKey-DCw6d7dm.js} +1 -1
  6. package/dist/chunks/ApproveApiKey-lv4Sg0RR.js +1 -0
  7. package/dist/chunks/{BackgroundTasksDialog-ClSMkcGp.js → BackgroundTasksDialog-CZND8e_Z.js} +1 -1
  8. package/dist/chunks/{BypassPermissionsModeDialog-KCZv-PXl.js → BypassPermissionsModeDialog-B5QBJTB4.js} +1 -1
  9. package/dist/chunks/{DiffDialog-BGBkuVIn.js → DiffDialog-Bd-DcTsK.js} +1 -1
  10. package/dist/chunks/{Doctor-CI04juFO.js → Doctor-C9t7udHN.js} +2 -2
  11. package/dist/chunks/Doctor-V-JLC4e3.js +1 -0
  12. package/dist/chunks/ExitFlow-CShdrKmr.js +2 -0
  13. package/dist/chunks/{Grove-B-M3DWD3.js → Grove-CClEZT2e.js} +1 -1
  14. package/dist/chunks/{HybridTransport-n5jji6SI.js → HybridTransport-DyEuslQB.js} +1 -1
  15. package/dist/chunks/{InvalidConfigDialog-By-j6fHE.js → InvalidConfigDialog-Wyrk_cXR.js} +1 -1
  16. package/dist/chunks/{InvalidSettingsDialog-C_reeMzL.js → InvalidSettingsDialog-Cr9fmSyh.js} +1 -1
  17. package/dist/chunks/MCPConnectionManager-BnUw0nYN.js +1 -0
  18. package/dist/chunks/{MCPToolListView-jw0tITfc.js → MCPToolListView-CY2EezWF.js} +1 -1
  19. package/dist/chunks/{McpParsingWarnings-BeZ3Bn8N.js → McpParsingWarnings-BF4np2Y3.js} +1 -1
  20. package/dist/chunks/{MessageSelector-Ci6N-gCw.js → MessageSelector-Dtt2Sf65.js} +1 -1
  21. package/dist/chunks/Messages-D5Uuapmf.js +10 -0
  22. package/dist/chunks/{Onboarding-DDkVEq-G.js → Onboarding-BAJXV7Ay.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-BlhZuQ5F.js → PromptInputFooterSuggestions-Cm4WN3qd.js} +1 -1
  24. package/dist/chunks/PromptInputHelpMenu-ESj8sOpK.js +1 -0
  25. package/dist/chunks/QueryEngine-B79JLwG4.js +1 -0
  26. package/dist/chunks/REPL-B7evbhvN.js +1 -0
  27. package/dist/chunks/REPL-cAXdORs2.js +128 -0
  28. package/dist/chunks/{RemoteSessionManager-mWVrdNfS.js → RemoteSessionManager-C5pAD0Lh.js} +2 -2
  29. package/dist/chunks/{ResumeConversation-BzTn_1jS.js → ResumeConversation-NSVT3gn7.js} +1 -1
  30. package/dist/chunks/{SSETransport-D86IVNn1.js → SSETransport-CDGMGrxN.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-CddjJcAH.js +1 -0
  32. package/dist/chunks/Settings-_b5Yxt_9.js +2 -0
  33. package/dist/chunks/{TeleportProgress-CW8mLRy2.js → TeleportProgress-8cS6aHVO.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-DZD32R-l.js → TeleportRepoMismatchDialog-B0epkMgp.js} +1 -1
  35. package/dist/chunks/{TeleportResumeWrapper-BhuUE1aq.js → TeleportResumeWrapper-Bb14JeEk.js} +1 -1
  36. package/dist/chunks/{ThemePicker-ByQZgIbH.js → ThemePicker-CnX8faYA.js} +1 -1
  37. package/dist/chunks/{TrustDialog-BzwibD_8.js → TrustDialog-6wJF3W6K.js} +1 -1
  38. package/dist/chunks/{add-dir-BQ-ljgk6.js → add-dir-LLAv-rGS.js} +1 -1
  39. package/dist/chunks/{agentDisplay-tRprY4gB.js → agentDisplay-QqGqcHGz.js} +1 -1
  40. package/dist/chunks/{agents-DMyQUXwl.js → agents-C8wRUTNV.js} +6 -6
  41. package/dist/chunks/{agents-Dq4BCf0H.js → agents-DFPEienW.js} +1 -1
  42. package/dist/chunks/{allErrors-CQWZ6BPw.js → allErrors-DUYYPpdH.js} +1 -1
  43. package/dist/chunks/{api-ClAyS7cQ.js → api-B3Wnozaf.js} +1 -1
  44. package/dist/chunks/api-BAT--5sp.js +1 -0
  45. package/dist/chunks/auth-CQGJitIV.js +10 -0
  46. package/dist/chunks/auth-DaJXqwN5.js +1 -0
  47. package/dist/chunks/auth-DkhPycBL.js +1 -0
  48. package/dist/chunks/{backgroundHousekeeping-rzQFJiND.js → backgroundHousekeeping-Bjb_Jc7L.js} +2 -2
  49. package/dist/chunks/backgroundHousekeeping-V-dg2j2E.js +1 -0
  50. package/dist/chunks/{branch-BWbCrXBJ.js → branch-BWq5ynjm.js} +1 -1
  51. package/dist/chunks/{bridgeConfig-CPHAyzdg.js → bridgeConfig-B3mR0kJ0.js} +1 -1
  52. package/dist/chunks/bridgeConfig-D31i4BRi.js +1 -0
  53. package/dist/chunks/{bridgeMessaging-vR7uQXB9.js → bridgeMessaging-wZ5EKxW_.js} +1 -1
  54. package/dist/chunks/{bridgeStatusUtil-CHTx7XwJ.js → bridgeStatusUtil-mvVQSVN-.js} +1 -1
  55. package/dist/chunks/{btw-IGcgP-Qq.js → btw-XNgXHnNr.js} +1 -1
  56. package/dist/chunks/{caches-FP8mGB4k.js → caches-ByLjTvdy.js} +1 -1
  57. package/dist/chunks/caches-ckqJ4Qso.js +1 -0
  58. package/dist/chunks/{ccrClient--8aPutWE.js → ccrClient-EisctZbc.js} +1 -1
  59. package/dist/chunks/{clear-CF-FZwpe.js → clear-BjtPf2Jb.js} +1 -1
  60. package/dist/chunks/client-Bb2eZnuq.js +1 -0
  61. package/dist/chunks/client-Bl43xcRk.js +1 -0
  62. package/dist/chunks/client-DNEVh6Wu.js +1 -0
  63. package/dist/chunks/client-Pap_HyZZ.js +1 -0
  64. package/dist/chunks/client-zhozU2ws.js +1 -0
  65. package/dist/chunks/commands-BDhn7EPO.js +1 -0
  66. package/dist/chunks/{compact-BrJGpEFZ.js → compact-w8AhLkr6.js} +1 -1
  67. package/dist/chunks/config-CbAvTdZ7.js +1 -0
  68. package/dist/chunks/{context-DADnwl4t.js → context-Btn2JU2y.js} +1 -1
  69. package/dist/chunks/{context-noninteractive-kACWzgS1.js → context-noninteractive-044464Vs.js} +1 -1
  70. package/dist/chunks/context-noninteractive-ulRLlYg5.js +1 -0
  71. package/dist/chunks/conversation-D08lU377.js +1 -0
  72. package/dist/chunks/{conversation-C8w1DtXk.js → conversation-a82khZ_n.js} +1 -1
  73. package/dist/chunks/{createSSHSession-B71Plec6.js → createSSHSession-C0KSI0fJ.js} +1 -1
  74. package/dist/chunks/{createSession-BJeDECzt.js → createSession-8ScCWTKb.js} +1 -1
  75. package/dist/chunks/createSession-CnlPXXkA.js +1 -0
  76. package/dist/chunks/{crossProjectResume-B1I6YzXr.js → crossProjectResume-BCN462Wa.js} +1 -1
  77. package/dist/chunks/{datadog-C9uqPA6N.js → datadog-BqINRWAW.js} +1 -1
  78. package/dist/chunks/{diff-CzChvQyK.js → diff-CcrSQNvQ.js} +1 -1
  79. package/dist/chunks/doctor-DRFDBrH1.js +1 -0
  80. package/dist/chunks/{entry-BoL8sy1Y.js → entry-oVZ7Z59B.js} +2 -2
  81. package/dist/chunks/{esm-DtcV71xh.js → esm-BZciQG9N.js} +1 -1
  82. package/dist/chunks/exit-jikLI2Zh.js +1 -0
  83. package/dist/chunks/extraUsage-BT3in1Aj.js +1 -0
  84. package/dist/chunks/extractMemories-BsQU2bVO.js +1 -0
  85. package/dist/chunks/fast-B9vVL3sY.js +1 -0
  86. package/dist/chunks/fast-CKhtBOx7.js +1 -0
  87. package/dist/chunks/fetchModelList-BeL40TyR.js +1 -0
  88. package/dist/chunks/fetchModelList-DmaMgpa2.js +1 -0
  89. package/dist/chunks/{fileSuggestions-DU7gmksK.js → fileSuggestions-BfG3sbET.js} +1 -1
  90. package/dist/chunks/firstPartyEventLogger-6GwZ6VLr.js +1 -0
  91. package/dist/chunks/{firstPartyEventLogger-7pAyUdbp.js → firstPartyEventLogger-Q3fMF0BR.js} +2 -2
  92. package/dist/chunks/{flushGate-4DfYr-Ru.js → flushGate-COa_KO98.js} +1 -1
  93. package/dist/chunks/{gemini-Cll4fVQn.js → gemini-L8Gj2B4H.js} +1 -1
  94. package/dist/chunks/{generateSessionName-BgGMwpps.js → generateSessionName-cAL5T7pG.js} +1 -1
  95. package/dist/chunks/{goal-D4E2WQVn.js → goal-D-x2WXm7.js} +1 -1
  96. package/dist/chunks/grok-DtypRM4d.js +1 -0
  97. package/dist/chunks/{grove-Bck1zFaD.js → grove-CSivzrhe.js} +1 -1
  98. package/dist/chunks/{help-DJp61Job.js → help-DKZhC0lL.js} +1 -1
  99. package/dist/chunks/{hooks-CJ17byYD.js → hooks-D_afUDcs.js} +1 -1
  100. package/dist/chunks/hooks-DvVuNKRx.js +1 -0
  101. package/dist/chunks/initReplBridge-sTaq4a0K.js +1 -0
  102. package/dist/chunks/{install-Dd5fw0cA.js → install-BWe3Jz4M.js} +1 -1
  103. package/dist/chunks/{instrumentation-jsPu6qqs.js → instrumentation-IljwxX0V.js} +4 -4
  104. package/dist/chunks/{job-BHhkQbvu.js → job-N25KhSUu.js} +1 -1
  105. package/dist/chunks/keybindings-DLEorhlY.js +1 -0
  106. package/dist/chunks/{launchLocalMemory-DsaijVcO.js → launchLocalMemory-DJsuNLIf.js} +1 -1
  107. package/dist/chunks/{launchOnboarding-DHOylaqn.js → launchOnboarding-CVvuxeH-.js} +1 -1
  108. package/dist/chunks/{loadAgentsDir-CwEfQDOw.js → loadAgentsDir-CbtNPJV3.js} +569 -569
  109. package/dist/chunks/loadAgentsDir-D0gl_H2S.js +1 -0
  110. package/dist/chunks/{loadPluginHooks-C-Yk5KlI.js → loadPluginHooks-BxkDBFd6.js} +1 -1
  111. package/dist/chunks/{localSearch-BEnlgSB7.js → localSearch-B5mTHBwK.js} +1 -1
  112. package/dist/chunks/localSearch-D3UrYUre.js +1 -0
  113. package/dist/chunks/{logoV2Utils-DG9GwFjl.js → logoV2Utils-D5nRpirL.js} +1 -1
  114. package/dist/chunks/{magicDocs-qGHR3Cqh.js → magicDocs-C9aIo4Oe.js} +2 -2
  115. package/dist/chunks/{main-CBVQ8bRm.js → main-DeUt_aE2.js} +26 -26
  116. package/dist/chunks/managedEnv-ADMKY7-G.js +1 -0
  117. package/dist/chunks/{managedEnv-3MbOWrVs.js → managedEnv-CDxyrUw1.js} +1 -1
  118. package/dist/chunks/{mappers-CdY45PDA.js → mappers-Del1KoA7.js} +1 -1
  119. package/dist/chunks/{mcp-DvY_FibT.js → mcp-Bh3MNBIj.js} +3 -3
  120. package/dist/chunks/{mcp-DI8pGrqi.js → mcp-D7vMhEOV.js} +1 -1
  121. package/dist/chunks/{mcp-BA8XQ6h1.js → mcp-nnBVM5Lt.js} +1 -1
  122. package/dist/chunks/{memory-C2U7CCmM.js → memory-DtqQhHu8.js} +1 -1
  123. package/dist/chunks/{mode-ByV6NqmB.js → mode-DPbrxU32.js} +1 -1
  124. package/dist/chunks/model-B50j-O5v.js +1 -0
  125. package/dist/chunks/model-DLG1nrnf.js +1 -0
  126. package/dist/chunks/{model-CeG-iOKF.js → model-DlLO7TSx.js} +1 -1
  127. package/dist/chunks/modelOptions-SMq3one0.js +1 -0
  128. package/dist/chunks/{nativeInstaller-CXFD8LDV.js → nativeInstaller-DTJ4clp-.js} +1 -1
  129. package/dist/chunks/{omit-B65XeX8r.js → omit-CMldTqqy.js} +1 -1
  130. package/dist/chunks/{onChangeAppState-EtUxsgYz.js → onChangeAppState-EAnsmOuo.js} +1 -1
  131. package/dist/chunks/openai-CR3CcjCE.js +17 -0
  132. package/dist/chunks/{openai-Dx5mvMjY.js → openai-D9KvLMrj.js} +2 -2
  133. package/dist/chunks/{partition-8vZDG3rY.js → partition-B8Y4jvjW.js} +1 -1
  134. package/dist/chunks/{permissions-CJUBfBTr.js → permissions-cDtIZRM1.js} +2 -2
  135. package/dist/chunks/{pidLock-tjm2n1Nd.js → pidLock-Br3_YNi_.js} +2 -2
  136. package/dist/chunks/{plan-eFur8bdH.js → plan-dG2H4eQl.js} +1 -1
  137. package/dist/chunks/{plugin-fYLRLdOY.js → plugin-CzQHuIlP.js} +1 -1
  138. package/dist/chunks/{pluginAutoupdate-B4w7SSYc.js → pluginAutoupdate-B9W_vxOG.js} +1 -1
  139. package/dist/chunks/{pluginBlocklist-CMwb7gmY.js → pluginBlocklist-BvdBsnJG.js} +1 -1
  140. package/dist/chunks/{pluginCliCommands-3YCj7Y3Q.js → pluginCliCommands-NKIgFTUF.js} +1 -1
  141. package/dist/chunks/{pluginFlagging-srvq9H7p.js → pluginFlagging-C0PtAJEg.js} +1 -1
  142. package/dist/chunks/{pluginOperations-C7BCR7pw.js → pluginOperations-wUUdFpu9.js} +1 -1
  143. package/dist/chunks/pluginStartupCheck-hDT6pEAd.js +1 -0
  144. package/dist/chunks/{pluginStartupCheck-BLc0U7W7.js → pluginStartupCheck-p0njap1l.js} +1 -1
  145. package/dist/chunks/{plugins-CPtmmDDi.js → plugins-B9WBqOAW.js} +1 -1
  146. package/dist/chunks/print-G3DgPTxy.js +14 -0
  147. package/dist/chunks/{processBashCommand-C9-FonuX.js → processBashCommand-zLWgCRws.js} +1 -1
  148. package/dist/chunks/{processSlashCommand-Bi8_1MRC.js → processSlashCommand-BHBnHBjj.js} +2 -2
  149. package/dist/chunks/{prompt-Bm2EEG4F.js → prompt-BRGC5U9Y.js} +1 -1
  150. package/dist/chunks/prompt-Ct3Ryb3C.js +1 -0
  151. package/dist/chunks/prompt-TZJKyomz.js +1 -0
  152. package/dist/chunks/{promptEditor-DQ9fpdQD.js → promptEditor-CRIw6vJS.js} +1 -1
  153. package/dist/chunks/{reconciler-DgQ4y1Vn.js → reconciler-DiU1RvGD.js} +1 -1
  154. package/dist/chunks/{refresh-CayVRWUY.js → refresh-DEXe3Lmx.js} +1 -1
  155. package/dist/chunks/{reload-plugins-6xcH3dLg.js → reload-plugins-Cl6wvT6V.js} +1 -1
  156. package/dist/chunks/{remoteBridgeCore-BnZYGaMH.js → remoteBridgeCore-DnFZoXaw.js} +1 -1
  157. package/dist/chunks/{remoteManagedSettings-CfFmrRze.js → remoteManagedSettings-BboLJ46D.js} +1 -1
  158. package/dist/chunks/{rename-mDtCTbnD.js → rename-CdzxOzN5.js} +1 -1
  159. package/dist/chunks/{resume-DRvz4QFs.js → resume-DgFXYWTN.js} +1 -1
  160. package/dist/chunks/{runtimeObserver-Ba6SM-sI.js → runtimeObserver-CwtRE2cj.js} +1 -1
  161. package/dist/chunks/{runtimeObserver-Dt5sGJVb.js → runtimeObserver-Dov-m2dl.js} +2 -2
  162. package/dist/chunks/sandbox-adapter-CtEngx-6.js +1 -0
  163. package/dist/chunks/{sandbox-toggle-DKcw3SbO.js → sandbox-toggle-DWCrG9zV.js} +1 -1
  164. package/dist/chunks/searchExtraTools-zFMN5MqY.js +1 -0
  165. package/dist/chunks/{session-COVyD8UU.js → session-L5191BSn.js} +1 -1
  166. package/dist/chunks/sessionFileAccessHooks-C2VjT-PU.js +1 -0
  167. package/dist/chunks/sessionObserver-BuhXr3FP.js +1 -0
  168. package/dist/chunks/{sessionObserver-iAgSetlC.js → sessionObserver-DpY0DOjI.js} +1 -1
  169. package/dist/chunks/{sessionState-zhvcDpb2.js → sessionState-BlbRQ3Y6.js} +2 -2
  170. package/dist/chunks/sessionStorage-CiYSwyY3.js +1 -0
  171. package/dist/chunks/sessionTitle-k4wpUS5l.js +2 -0
  172. package/dist/chunks/{sessionTracing-C4uqAdud.js → sessionTracing-DqVx8aFD.js} +1 -1
  173. package/dist/chunks/{settingsSync-BGo6dHJo.js → settingsSync-BhlegQAU.js} +1 -1
  174. package/dist/chunks/setup-DvnKMqDy.js +3 -0
  175. package/dist/chunks/{shadowedRuleDetection-CzRAzcC1.js → shadowedRuleDetection-Gerk3t93.js} +1 -1
  176. package/dist/chunks/{sideQuestion-oIYrx5ar.js → sideQuestion-RndkXExy.js} +1 -1
  177. package/dist/chunks/sinks-Cf4vx9UX.js +1 -0
  178. package/dist/chunks/{sinks-Bje3hCkR.js → sinks-CfzgqLH5.js} +1 -1
  179. package/dist/chunks/skillChangeDetector-BQx4xe_b.js +1 -0
  180. package/dist/chunks/{skillGapStore-CJjt3IW7.js → skillGapStore-CLxhWLyq.js} +2 -2
  181. package/dist/chunks/{skillLifecycle-BsgH84vl.js → skillLifecycle-CSNX2qOH.js} +2 -2
  182. package/dist/chunks/{skillSearchPanel-CneXymsb.js → skillSearchPanel-CsQDjy_E.js} +4 -4
  183. package/dist/chunks/{skills-DZRBy7vT.js → skills-DM9ACPW-.js} +1 -1
  184. package/dist/chunks/status-C3z0CSBw.js +1 -0
  185. package/dist/chunks/{status-BP_R8051.js → status-C5v7KsX4.js} +2 -2
  186. package/dist/chunks/{statusNoticeHelpers-ODrnrLAZ.js → statusNoticeHelpers-BY_8pK19.js} +1 -1
  187. package/dist/chunks/switcher-C9VsM-ip.js +1 -0
  188. package/dist/chunks/{switcher-BkGOeIzI.js → switcher-CnBKuiNp.js} +1 -1
  189. package/dist/chunks/syncCache-Dff4hbz4.js +1 -0
  190. package/dist/chunks/{tasks-CIUuwrX4.js → tasks-qVyXOLBf.js} +1 -1
  191. package/dist/chunks/{teleport-IzyDplC7.js → teleport-Deq_ecN9.js} +1 -1
  192. package/dist/chunks/{templateJobs-De57J461.js → templateJobs-CntPyct-.js} +1 -1
  193. package/dist/chunks/{theme-Nwii7354.js → theme-DVWYzSct.js} +1 -1
  194. package/dist/chunks/{toolEventObserver-Cq-uBb0-.js → toolEventObserver-BZn8ZJB5.js} +1 -1
  195. package/dist/chunks/toolPool-Dzp1ob3I.js +1 -0
  196. package/dist/chunks/trustedDevice-1Q4FTNyX.js +1 -0
  197. package/dist/chunks/{trustedDevice-DWZxDUxS.js → trustedDevice-CdLAZK6m.js} +1 -1
  198. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-D48aDPG9.js → useExitOnCtrlCDWithKeybindings-YSWYVWk6.js} +1 -1
  199. package/dist/chunks/useMainLoopModel-C1JRp4zE.js +1 -0
  200. package/dist/chunks/{useManagePlugins-EqoQELMT.js → useManagePlugins-DfuI4Nhd.js} +1 -1
  201. package/dist/chunks/{useMergedTools-BJ4L9QSK.js → useMergedTools-B4qRVJ8b.js} +1 -1
  202. package/dist/chunks/{useSearchInput-DkVER3cm.js → useSearchInput-DfUNYhqC.js} +1 -1
  203. package/dist/chunks/{useSettingsErrors-D3MlQ1GF.js → useSettingsErrors-Bls74ocI.js} +1 -1
  204. package/dist/chunks/{userAgent-aoe_xVAb.js → userAgent-CNPTS7ix.js} +1 -1
  205. package/dist/chunks/{util-g-5UX5gH.js → util-6aJHnBQ_.js} +1 -1
  206. package/dist/chunks/{validatePlugin-CSE8zjZn.js → validatePlugin-BajM6yNf.js} +1 -1
  207. package/dist/chunks/{workerRegistry-DGwy0YHB.js → workerRegistry-BwJ54Lzk.js} +2 -2
  208. package/dist/chunks/worktree-BFP10vim.js +1 -0
  209. package/dist/cli.js +1 -1
  210. package/package.json +1 -1
  211. package/dist/chunks/AgentsMdExternalIncludesDialog-0Qdg3Rh7.js +0 -1
  212. package/dist/chunks/ApproveApiKey-PWFcscjY.js +0 -1
  213. package/dist/chunks/Doctor-DCrqcW68.js +0 -1
  214. package/dist/chunks/ExitFlow-qrCDVA9i.js +0 -2
  215. package/dist/chunks/MCPConnectionManager-BNG7iSlw.js +0 -1
  216. package/dist/chunks/Messages-D6CRTH2m.js +0 -10
  217. package/dist/chunks/PromptInputHelpMenu-kKyPIMau.js +0 -1
  218. package/dist/chunks/QueryEngine-DXpS0Ytq.js +0 -1
  219. package/dist/chunks/REPL-D1BCm7cR.js +0 -128
  220. package/dist/chunks/REPL-JQgCrSEv.js +0 -1
  221. package/dist/chunks/SearchExtraToolsTool-BXIja1MR.js +0 -1
  222. package/dist/chunks/Settings-D_i8HzEW.js +0 -2
  223. package/dist/chunks/api-CpD5jeKe.js +0 -1
  224. package/dist/chunks/auth-CWAvPfX7.js +0 -10
  225. package/dist/chunks/auth-DG5bkWDc.js +0 -1
  226. package/dist/chunks/auth-DuHfQBuH.js +0 -1
  227. package/dist/chunks/backgroundHousekeeping-kf_v7Vfr.js +0 -1
  228. package/dist/chunks/bridgeConfig-CABsoOum.js +0 -1
  229. package/dist/chunks/caches-Dj1YhqrG.js +0 -1
  230. package/dist/chunks/client-B7WkO81L.js +0 -17
  231. package/dist/chunks/client-BCzhAEd0.js +0 -1
  232. package/dist/chunks/client-BU7upHOb.js +0 -1
  233. package/dist/chunks/commands-Cr1p7OPH.js +0 -1
  234. package/dist/chunks/config-BohF3_IV.js +0 -1
  235. package/dist/chunks/context-noninteractive-BAbzwNxu.js +0 -1
  236. package/dist/chunks/conversation-Ds7zRD0x.js +0 -1
  237. package/dist/chunks/createSession-Bozo4Bu8.js +0 -1
  238. package/dist/chunks/doctor-DdvdGkNX.js +0 -1
  239. package/dist/chunks/exit-Af27f74w.js +0 -1
  240. package/dist/chunks/extraUsage-DsFwXMAj.js +0 -1
  241. package/dist/chunks/extractMemories-B1KbTMY0.js +0 -1
  242. package/dist/chunks/fast-BGU8p2uY.js +0 -1
  243. package/dist/chunks/fast-CuUjONVV.js +0 -1
  244. package/dist/chunks/firstPartyEventLogger-sMeCTEUW.js +0 -1
  245. package/dist/chunks/grok-HF1PHxXb.js +0 -1
  246. package/dist/chunks/hooks-CjR3Eq0Z.js +0 -1
  247. package/dist/chunks/initReplBridge-D09JEKHt.js +0 -1
  248. package/dist/chunks/keybindings-Ch5lzNB8.js +0 -1
  249. package/dist/chunks/loadAgentsDir-8FioUEwX.js +0 -1
  250. package/dist/chunks/localSearch-LcgRjjl3.js +0 -1
  251. package/dist/chunks/managedEnv-B4YV3A_y.js +0 -1
  252. package/dist/chunks/model-C73ETGu9.js +0 -1
  253. package/dist/chunks/model-CVG_RRTy.js +0 -1
  254. package/dist/chunks/modelOptions-A5jrCUBp.js +0 -1
  255. package/dist/chunks/pluginStartupCheck-nzVDPI1k.js +0 -1
  256. package/dist/chunks/print-BCud0ukQ.js +0 -14
  257. package/dist/chunks/prompt-CX_v9F3s.js +0 -1
  258. package/dist/chunks/prompt-V0WQJrkO2.js +0 -1
  259. package/dist/chunks/sandbox-adapter-Cmrd6tBj.js +0 -1
  260. package/dist/chunks/searchExtraTools-DIgC0CFB.js +0 -1
  261. package/dist/chunks/sessionFileAccessHooks-yAPDTrbm.js +0 -1
  262. package/dist/chunks/sessionObserver-BizdPx8P.js +0 -1
  263. package/dist/chunks/sessionStorage-LMY409Ji.js +0 -1
  264. package/dist/chunks/sessionTitle-QPRly1tZ.js +0 -14
  265. package/dist/chunks/setup-Bjw5VS6x.js +0 -3
  266. package/dist/chunks/sinks-FaljTZ-c.js +0 -1
  267. package/dist/chunks/skillChangeDetector-v6mAYzXX.js +0 -1
  268. package/dist/chunks/status-CZYD3NGb.js +0 -1
  269. package/dist/chunks/switcher-DwKN9daN.js +0 -1
  270. package/dist/chunks/syncCache-CpmpvjfC.js +0 -1
  271. package/dist/chunks/toolPool-BBU4ll_p.js +0 -1
  272. package/dist/chunks/trustedDevice-BKzkA7fq.js +0 -1
  273. package/dist/chunks/useMainLoopModel-89eUU13X.js +0 -1
  274. package/dist/chunks/worktree-jjuORs7p.js +0 -1
@@ -1,3 +1,3 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,i,l as a,o}from"./envUtils-DcaKZlRU.js";import{$d as s,aT as c,cT as ee}from"./loadAgentsDir-CwEfQDOw.js";import{n as te}from"./cwd-Besi3Os3.js";import{B as ne,C as re,D as ie,R as l,S as u,T as ae,U as oe,V as se,c as d,f,i as p,u as m,x as h}from"./debug-BQj6h99Q.js";import{Kt as ce,M as g,P as le,Qt as ue,Xt as de,Yt as fe,g as pe,n as me}from"./settings-CvhsRFaT.js";import{a as _,c as v,h as y,i as he}from"./config-BSkuQZNf.js";import{c as ge,n as _e,o as ve,r as b,t as x}from"./execFileNoThrow-DYm1GeGn.js";import{o as S,s as C}from"./log-BlJ7CcKG.js";import{n as w,t as ye}from"./which-BR8YVCCW.js";import{i as T,o as E}from"./platform-DVeTi9mp.js";import{n as D,t as be}from"./bundledMode--fG1S62b.js";import{_t as xe,vt as Se}from"./sessionState-zhvcDpb2.js";import{a as Ce,i as we}from"./ripgrep-DsLUmulz.js";import{i as Te,r as Ee}from"./genericProcessUtils-Bbcbi11g.js";import{homedir as O}from"os";import{basename as De,delimiter as Oe,join as k,posix as A,win32 as j}from"path";import{constants as ke}from"fs";import{access as Ae,open as je,readFile as M,realpath as Me,stat as Ne}from"fs/promises";function Pe(){return k(i(),`local`)}function Fe(){return k(Pe(),`claude`)}function Ie(){return(process.argv[1]||``).includes(`/.workmate/local/node_modules/`)}async function N(){try{return await Ae(k(Pe(),`node_modules`,`.bin`,`claude`)),!0}catch{return!1}}function P(){let e=process.env.SHELL||``;return e.includes(`zsh`)?`zsh`:e.includes(`bash`)?`bash`:e.includes(`fish`)?`fish`:`unknown`}var F=e((()=>{y(),o(),l(),b(),f(),S(),h()}));function I(e){let t=e?.homedir??O();return{zsh:k((e?.env??process.env).ZDOTDIR||t,`.zshrc`),bash:k(t,`.bashrc`),fish:k(t,`.config/fish/config.fish`)}}function Le(e){let t=!1;return{filtered:e.filter(e=>{if(z.test(e)){let n=e.match(/alias\s+claude\s*=\s*["']([^"']+)["']/);if(n||(n=e.match(/alias\s+claude\s*=\s*([^#\n]+)/)),n?.[1]&&n[1].trim()===Fe())return t=!0,!1}return!0}),hadAlias:t}}async function L(e){try{return(await M(e,{encoding:`utf8`})).split(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,i,l as a,o}from"./envUtils-DcaKZlRU.js";import{$d as s,oT as c,rT as ee}from"./loadAgentsDir-CbtNPJV3.js";import{n as te}from"./cwd-Besi3Os3.js";import{B as ne,C as re,D as ie,R as l,S as u,T as ae,U as oe,V as se,c as d,f,i as p,u as m,x as h}from"./debug-BQj6h99Q.js";import{Kt as ce,M as g,P as le,Qt as ue,Xt as de,Yt as fe,g as pe,n as me}from"./settings-CvhsRFaT.js";import{a as _,c as v,h as y,i as he}from"./config-BSkuQZNf.js";import{c as ge,n as _e,o as ve,r as b,t as x}from"./execFileNoThrow-DYm1GeGn.js";import{o as S,s as C}from"./log-BlJ7CcKG.js";import{n as w,t as ye}from"./which-BR8YVCCW.js";import{i as T,o as E}from"./platform-DVeTi9mp.js";import{n as D,t as be}from"./bundledMode--fG1S62b.js";import{_t as xe,vt as Se}from"./sessionState-BlbRQ3Y6.js";import{a as Ce,i as we}from"./ripgrep-DsLUmulz.js";import{i as Te,r as Ee}from"./genericProcessUtils-Bbcbi11g.js";import{homedir as O}from"os";import{basename as De,delimiter as Oe,join as k,posix as A,win32 as j}from"path";import{constants as ke}from"fs";import{access as Ae,open as je,readFile as M,realpath as Me,stat as Ne}from"fs/promises";function Pe(){return k(i(),`local`)}function Fe(){return k(Pe(),`claude`)}function Ie(){return(process.argv[1]||``).includes(`/.workmate/local/node_modules/`)}async function N(){try{return await Ae(k(Pe(),`node_modules`,`.bin`,`claude`)),!0}catch{return!1}}function P(){let e=process.env.SHELL||``;return e.includes(`zsh`)?`zsh`:e.includes(`bash`)?`bash`:e.includes(`fish`)?`fish`:`unknown`}var F=e((()=>{y(),o(),l(),b(),f(),S(),h()}));function I(e){let t=e?.homedir??O();return{zsh:k((e?.env??process.env).ZDOTDIR||t,`.zshrc`),bash:k(t,`.bashrc`),fish:k(t,`.config/fish/config.fish`)}}function Le(e){let t=!1;return{filtered:e.filter(e=>{if(z.test(e)){let n=e.match(/alias\s+claude\s*=\s*["']([^"']+)["']/);if(n||(n=e.match(/alias\s+claude\s*=\s*([^#\n]+)/)),n?.[1]&&n[1].trim()===Fe())return t=!0,!1}return!0}),hadAlias:t}}async function L(e){try{return(await M(e,{encoding:`utf8`})).split(`
2
2
  `)}catch(e){if(se(e))return null;throw e}}async function Re(e,t){let n=await je(e,`w`);try{await n.writeFile(t.join(`
3
- `),{encoding:`utf8`}),await n.datasync()}finally{await n.close()}}async function R(e){let t=I(e);for(let e of Object.values(t)){let t=await L(e);if(t){for(let e of t)if(z.test(e)){let t=e.match(/alias\s+claude=["']?([^"'\s]+)/);if(t?.[1])return t[1]}}}return null}async function ze(e){let t=await R(e);if(!t)return null;let n=e?.homedir??O(),r=t.startsWith(`~`)?t.replace(`~`,n):t;try{let e=await Ne(r);if(e.isFile()||e.isSymbolicLink())return t}catch{}return null}var z,B=e((()=>{l(),F(),z=/^\s*alias\s+claude\s*=/}));async function Be(){}function Ve(e){let t=me()?.minimumVersion;if(!t)return!1;let n=!xe(e,t);return n&&d(`Skipping update to ${e} - below minimumVersion ${t}`),n}async function He(){let e=ce.isRunningWithBun(),t=null;return t=e?await _e(`bun`,[`pm`,`bin`,`-g`],{cwd:O()}):await _e(`npm`,[`-g`,`config`,`get`,`prefix`],{cwd:O()}),t.code===0?t.stdout.trim():(C(Error(`Failed to check ${e?`bun`:`npm`} permissions`)),null)}async function Ue(){try{let e=await He();if(!e)return{hasPermissions:!1,npmPrefix:null};try{return await Ae(e,ke.W_OK),{hasPermissions:!0,npmPrefix:e}}catch{return C(new We(`Insufficient permissions for global npm install.`)),{hasPermissions:!1,npmPrefix:e}}}catch(e){return C(e),{hasPermissions:!1,npmPrefix:null}}}var We,Ge=e((()=>{y(),p(),fe(),o(),l(),b(),f(),s(),S(),Se(),pe(),B(),We=class extends ie{}}));function V(e,t){return t.includes(e.id)||e.idLike.some(e=>t.includes(e))}function Ke(){let e=process.execPath||process.argv[0]||``;return/[/\\]mise[/\\]installs[/\\]/i.test(e)?(d(`Detected mise installation: ${e}`),!0):!1}function qe(){let e=process.execPath||process.argv[0]||``;return/[/\\]\.?asdf[/\\]installs[/\\]/i.test(e)?(d(`Detected asdf installation: ${e}`),!0):!1}function H(){let e=T();if(e!==`macos`&&e!==`linux`&&e!==`wsl`)return!1;let t=process.execPath||process.argv[0]||``;return t.includes(`/Caskroom/`)?(d(`Detected Homebrew cask installation: ${t}`),!0):!1}function Je(){if(T()!==`windows`)return!1;let e=process.execPath||process.argv[0]||``;for(let t of[/Microsoft[/\\]WinGet[/\\]Packages/i,/Microsoft[/\\]WinGet[/\\]Links/i])if(t.test(e))return d(`Detected winget installation: ${e}`),!0;return!1}var U,W,G,K,q,Ye,Xe=e((()=>{n(),p(),b(),E(),U=t(async()=>{try{let e=await M(`/etc/os-release`,`utf8`),t=e.match(/^ID=["']?(\S+?)["']?\s*$/m),n=e.match(/^ID_LIKE=["']?(.+?)["']?\s*$/m);return{id:t?.[1]??``,idLike:n?.[1]?.split(` `)??[]}}catch{return null}}),W=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`arch`]))return!1;let t=await x(`pacman`,[`-Qo`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected pacman installation: ${t.stdout.trim()}`),!0):!1}),G=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`debian`]))return!1;let t=await x(`dpkg`,[`-S`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected deb installation: ${t.stdout.trim()}`),!0):!1}),K=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`fedora`,`rhel`,`suse`]))return!1;let t=await x(`rpm`,[`-qf`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected rpm installation: ${t.stdout.trim()}`),!0):!1}),q=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`alpine`]))return!1;let t=await x(`apk`,[`info`,`--who-owns`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected apk installation: ${t.stdout.trim()}`),!0):!1}),Ye=t(async()=>H()?`homebrew`:Je()?`winget`:Ke()?`mise`:qe()?`asdf`:await W()?`pacman`:await q()?`apk`:await G()?`deb`:await K()?`rpm`:`unknown`)}));function Ze(){let e=process.argv[1]||``,t=process.execPath||process.argv[0]||``;return T()===`windows`&&(e=e.split(j.sep).join(A.sep),t=t.split(j.sep).join(A.sep)),[e,t]}async function Qe(){let[e]=Ze();if(D())return H()||Je()||Ke()||qe()||await W()||await G()||await K()||await q()?`package-manager`:`native`;if(Ie())return`npm-local`;if([`/usr/local/lib/node_modules`,`/usr/lib/node_modules`,`/opt/homebrew/lib/node_modules`,`/opt/homebrew/bin`,`/usr/local/bin`,`/.nvm/versions/node/`].some(t=>e.includes(t))||e.includes(`/npm/`)||e.includes(`/nvm/`))return`npm-global`;let t=await ve(`npm config get prefix`,{shell:!0,reject:!1}),n=t.exitCode===0?t.stdout.trim():null;return n&&e.startsWith(n)?`npm-global`:`unknown`}async function $e(){if(D()){try{return await Me(process.execPath)}catch{}try{let e=await w(`claude`);if(e)return e}catch{}try{return await m().stat(k(O(),`.local/bin/claude`)),k(O(),`.local/bin/claude`)}catch{}return`native`}try{return process.argv[0]||`unknown`}catch{return`unknown`}}function et(){try{return D()?process.execPath||`unknown`:process.argv[1]||`unknown`}catch{return`unknown`}}async function tt(){let e=m(),t=[],n=k(O(),`.workmate`,`local`);await N()&&t.push({type:`npm-local`,path:n});let r=[`@anthropic-ai/workmate`],i=await x(`npm`,[`-g`,`config`,`get`,`prefix`]);if(i.code===0&&i.stdout){let n=i.stdout.trim(),a=T()===`windows`,o=a?k(n,`claude`):k(n,`bin`,`claude`),s=!1;try{await e.stat(o),s=!0}catch{}if(s){let e=!1;try{(await Me(o)).includes(`/Caskroom/`)&&(e=H())}catch{}e||t.push({type:`npm-global`,path:o})}else for(let i of r){let r=a?k(n,`node_modules`,i):k(n,`lib`,`node_modules`,i);try{await e.stat(r),t.push({type:`npm-global-orphan`,path:r})}catch{}}}let a=k(O(),`.local`,`bin`,`claude`);try{await e.stat(a),t.push({type:`native`,path:a})}catch{}if(v().installMethod===`native`){let n=k(O(),`.local`,`share`,`claude`);try{await e.stat(n),t.some(e=>e.type===`native`)||t.push({type:`native`,path:n})}catch{}}return t}async function nt(e){let t=[];try{let e=u(await M(k(de(),`managed-settings.json`),`utf-8`)),n=e&&typeof e==`object`?e.strictPluginOnlyCustomization:void 0;if(n!==void 0&&typeof n!=`boolean`)if(!Array.isArray(n))t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has an invalid value (expected true or an array, got ${typeof n})`,fix:`The field is silently ignored (schema .catch rescues it). Set it to true, or an array of: ${g.join(`, `)}.`});else{let e=n.filter(e=>typeof e==`string`&&!g.includes(e));e.length>0&&t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has ${e.length} value(s) this client doesn't recognize: ${e.map(String).join(`, `)}`,fix:`These are silently ignored (forwards-compat). Known surfaces for this version: ${g.join(`, `)}. Either remove them, or this client is older than the managed-settings intended.`})}}catch{}let n=v();if(e===`development`)return t;if(e===`native`){let e=(process.env.PATH||``).split(Oe),n=k(O(),`.local`,`bin`),r=n;if(T()===`windows`&&(r=n.split(j.sep).join(A.sep)),!e.some(e=>{let t=e;T()===`windows`&&(t=e.split(j.sep).join(A.sep));let n=t.replace(/\/+$/,``),i=e.replace(/[/\\]+$/,``);return n===r||i===`~/.local/bin`||i===`$HOME/.local/bin`}))if(T()===`windows`){let e=n.split(A.sep).join(j.sep);t.push({issue:`Native installation exists but ${e} is not in your PATH`,fix:`Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`})}else{let e=P(),n=I()[e],r=n?n.replace(O(),`~`):`your shell config file`;t.push({issue:`Native installation exists but ~/.local/bin is not in your PATH`,fix:`Run: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ${r} then open a new terminal or run: source ${r}`})}}a(process.env.DISABLE_INSTALLATION_CHECKS)||(e===`npm-local`&&n.installMethod!==`local`&&t.push({issue:`Running from local installation but config install method is '${n.installMethod}'`,fix:`Consider using native installation: claude install`}),e===`native`&&n.installMethod!==`native`&&t.push({issue:`Running native installation but config install method is '${n.installMethod}'`,fix:`Run claude install to update configuration`})),e===`npm-global`&&await N()&&t.push({issue:`Local installation exists but not being used`,fix:`Consider using native installation: claude install`});let r=await R(),i=await ze();return e===`npm-local`&&!await w(`claude`)&&!i&&(r?t.push({issue:`Local installation not accessible`,fix:`Alias exists but points to invalid target: ${r}. Update alias: alias claude="~/.workmate/local/claude"`}):t.push({issue:`Local installation not accessible`,fix:`Create alias: alias claude="~/.workmate/local/claude"`})),t}function rt(){if(T()!==`linux`)return[];let e=[],t=c.getLinuxGlobPatternWarnings();if(t.length>0){let n=t.slice(0,3).join(`, `),r=t.length-3,i=r>0?`${n} (${r} more)`:n;e.push({issue:`Glob patterns in sandbox permission rules are not fully supported on Linux`,fix:`Found ${t.length} pattern(s): ${i}. On Linux, glob patterns in Edit/Read rules will be ignored.`})}return e}async function it(){let e=await Qe(),t=typeof MACRO<`u`?`0.0.15`:`unknown`,n=await $e(),r=et(),i=await tt(),a=await nt(e);if(a.push(...rt()),e===`native`){let e=i.filter(e=>e.type===`npm-global`||e.type===`npm-global-orphan`||e.type===`npm-local`),t=T()===`windows`;for(let n of e)n.type===`npm-global`?a.push({issue:`Leftover npm global installation at ${n.path}`,fix:`Run: npm -g uninstall @anthropic-ai/workmate`}):n.type===`npm-global-orphan`?a.push({issue:`Orphaned npm global package at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`}):n.type===`npm-local`&&a.push({issue:`Leftover npm local installation at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`})}let o=v().installMethod||`not set`,s=null;e===`npm-global`&&(s=(await Ue()).hasPermissions,!s&&!_()&&a.push({issue:`Insufficient permissions for auto-updates`,fix:"Do one of: (1) Re-install node without sudo, or (2) Use `claude install` for native installation"}));let c=we(),ee={working:c.working??!0,mode:c.mode,systemPath:c.mode===`system`?c.path:null,note:c.note??null},te=e===`package-manager`?await Ye():void 0;return{installationType:e,version:t,installationPath:n,invokedBinary:r,configInstallMethod:o,autoUpdates:(()=>{let e=_();return e?`disabled (${he(e)})`:`enabled`})(),hasUpdatePermissions:s,multipleInstallations:i,warnings:a,packageManager:te,ripgrepStatus:ee}}var at=e((()=>{ge(),Ge(),be(),y(),te(),o(),b(),f(),F(),Xe(),E(),Ce(),ee(),ue(),le(),B(),h(),ye()}));function J(e){return{env:e?.env??process.env,home:e?.homedir??process.env.HOME??O()}}function Y(e,...t){return e.includes(`/`)&&!e.includes(`\\`)&&!/^[A-Za-z]:/.test(e)?A.join(e,...t):k(e,...t)}function ot(e){let{env:t,home:n}=J(e);return t.XDG_STATE_HOME??Y(n,`.local`,`state`)}function st(e){let{env:t,home:n}=J(e);return t.XDG_CACHE_HOME??Y(n,`.cache`)}function ct(e){let{env:t,home:n}=J(e);return t.XDG_DATA_HOME??Y(n,`.local`,`share`)}function lt(e){let{home:t}=J(e);return Y(t,`.local`,`bin`)}var ut=e((()=>{}));function dt(){let e=process.env.ENABLE_PID_BASED_VERSION_LOCKING;return a(e)?!0:(r(e),!1)}function X(e){if(e<=1)return!1;try{return process.kill(e,0),!0}catch{return!1}}function ft(e,t){if(!X(e))return!1;if(e===process.pid)return!0;try{let n=Ee(e);if(!n)return!0;let r=n.toLowerCase(),i=t.toLowerCase();return r.includes(`claude`)||r.includes(i)}catch{return!0}}function Z(e){let t=m();try{let n=t.readFileSync(e,{encoding:`utf8`});if(!n||n.trim()===``)return null;let r=u(n);return typeof r.pid!=`number`||!r.version||!r.execPath?null:r}catch{return null}}function Q(e){let t=Z(e);if(!t)return!1;let{pid:n,execPath:r}=t;if(!X(n))return!1;if(!ft(n,r))return d(`Lock PID ${n} is running but does not appear to be Work Mate - treating as stale`),!1;let i=m();try{let t=i.statSync(e);if(Date.now()-t.mtimeMs>$&&!X(n))return!1}catch{}return!0}function pt(e,t){let n=m(),r=`${e}.tmp.${process.pid}.${Date.now()}`;try{ae(r,re(t,null,2),{encoding:`utf8`,flush:!0}),n.renameSync(r,e)}catch(e){try{n.unlinkSync(r)}catch{}throw e}}async function mt(e,t){let n=m(),r=De(e);if(Q(t))return d(`Cannot acquire lock for ${r} - held by PID ${Z(t)?.pid}`),null;let i={pid:process.pid,version:r,execPath:process.execPath,acquiredAt:Date.now()};try{return pt(t,i),Z(t)?.pid===process.pid?(d(`Acquired PID lock for ${r} (PID ${process.pid})`),()=>{try{Z(t)?.pid===process.pid&&(n.unlinkSync(t),d(`Released PID lock for ${r}`))}catch(e){d(`Failed to release lock for ${r}: ${e}`)}}):null}catch(e){return d(`Failed to acquire lock for ${r}: ${e}`),null}}async function ht(e,t){let n=await mt(e,t);if(!n)return!1;let r=()=>{try{n()}catch{}};return process.on(`exit`,r),process.on(`SIGINT`,r),process.on(`SIGTERM`,r),!0}async function gt(e,t,n){let r=await mt(e,t);if(!r)return!1;try{return await n(),!0}finally{r()}}function _t(e){let t=m(),n=[];try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let t of r){let r=k(e,t),i=Z(r);i&&n.push({version:i.version,pid:i.pid,isProcessRunning:X(i.pid),execPath:i.execPath,acquiredAt:new Date(i.acquiredAt),lockFilePath:r})}}catch(e){if(ne(e))return n;C(oe(e))}return n}function vt(e){let t=m(),n=0;try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let i of r){let r=k(e,i);try{t.lstatSync(r).isDirectory()?(t.rmSync(r,{recursive:!0,force:!0}),n++,d(`Cleaned up legacy directory lock: ${i}`)):Q(r)||(t.unlinkSync(r),n++,d(`Cleaned up stale lock: ${i}`))}catch{}}}catch(e){if(ne(e))return 0;C(oe(e))}return n}var $,yt=e((()=>{p(),o(),l(),f(),Te(),S(),h(),$=7200*1e3}));export{L as C,F as E,B as S,P as T,Be as _,Q as a,Le as b,gt as c,ct as d,ot as f,at as g,it as h,yt as i,lt as l,Qe as m,vt as n,dt as o,ut as p,_t as r,Z as s,ht as t,st as u,Ge as v,Re as w,I as x,Ve as y};
3
+ `),{encoding:`utf8`}),await n.datasync()}finally{await n.close()}}async function R(e){let t=I(e);for(let e of Object.values(t)){let t=await L(e);if(t){for(let e of t)if(z.test(e)){let t=e.match(/alias\s+claude=["']?([^"'\s]+)/);if(t?.[1])return t[1]}}}return null}async function ze(e){let t=await R(e);if(!t)return null;let n=e?.homedir??O(),r=t.startsWith(`~`)?t.replace(`~`,n):t;try{let e=await Ne(r);if(e.isFile()||e.isSymbolicLink())return t}catch{}return null}var z,B=e((()=>{l(),F(),z=/^\s*alias\s+claude\s*=/}));async function Be(){}function Ve(e){let t=me()?.minimumVersion;if(!t)return!1;let n=!xe(e,t);return n&&d(`Skipping update to ${e} - below minimumVersion ${t}`),n}async function He(){let e=ce.isRunningWithBun(),t=null;return t=e?await _e(`bun`,[`pm`,`bin`,`-g`],{cwd:O()}):await _e(`npm`,[`-g`,`config`,`get`,`prefix`],{cwd:O()}),t.code===0?t.stdout.trim():(C(Error(`Failed to check ${e?`bun`:`npm`} permissions`)),null)}async function Ue(){try{let e=await He();if(!e)return{hasPermissions:!1,npmPrefix:null};try{return await Ae(e,ke.W_OK),{hasPermissions:!0,npmPrefix:e}}catch{return C(new We(`Insufficient permissions for global npm install.`)),{hasPermissions:!1,npmPrefix:e}}}catch(e){return C(e),{hasPermissions:!1,npmPrefix:null}}}var We,Ge=e((()=>{y(),p(),fe(),o(),l(),b(),f(),s(),S(),Se(),pe(),B(),We=class extends ie{}}));function V(e,t){return t.includes(e.id)||e.idLike.some(e=>t.includes(e))}function Ke(){let e=process.execPath||process.argv[0]||``;return/[/\\]mise[/\\]installs[/\\]/i.test(e)?(d(`Detected mise installation: ${e}`),!0):!1}function qe(){let e=process.execPath||process.argv[0]||``;return/[/\\]\.?asdf[/\\]installs[/\\]/i.test(e)?(d(`Detected asdf installation: ${e}`),!0):!1}function H(){let e=T();if(e!==`macos`&&e!==`linux`&&e!==`wsl`)return!1;let t=process.execPath||process.argv[0]||``;return t.includes(`/Caskroom/`)?(d(`Detected Homebrew cask installation: ${t}`),!0):!1}function Je(){if(T()!==`windows`)return!1;let e=process.execPath||process.argv[0]||``;for(let t of[/Microsoft[/\\]WinGet[/\\]Packages/i,/Microsoft[/\\]WinGet[/\\]Links/i])if(t.test(e))return d(`Detected winget installation: ${e}`),!0;return!1}var U,W,G,K,q,Ye,Xe=e((()=>{n(),p(),b(),E(),U=t(async()=>{try{let e=await M(`/etc/os-release`,`utf8`),t=e.match(/^ID=["']?(\S+?)["']?\s*$/m),n=e.match(/^ID_LIKE=["']?(.+?)["']?\s*$/m);return{id:t?.[1]??``,idLike:n?.[1]?.split(` `)??[]}}catch{return null}}),W=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`arch`]))return!1;let t=await x(`pacman`,[`-Qo`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected pacman installation: ${t.stdout.trim()}`),!0):!1}),G=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`debian`]))return!1;let t=await x(`dpkg`,[`-S`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected deb installation: ${t.stdout.trim()}`),!0):!1}),K=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`fedora`,`rhel`,`suse`]))return!1;let t=await x(`rpm`,[`-qf`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected rpm installation: ${t.stdout.trim()}`),!0):!1}),q=t(async()=>{if(T()!==`linux`)return!1;let e=await U();if(e&&!V(e,[`alpine`]))return!1;let t=await x(`apk`,[`info`,`--who-owns`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected apk installation: ${t.stdout.trim()}`),!0):!1}),Ye=t(async()=>H()?`homebrew`:Je()?`winget`:Ke()?`mise`:qe()?`asdf`:await W()?`pacman`:await q()?`apk`:await G()?`deb`:await K()?`rpm`:`unknown`)}));function Ze(){let e=process.argv[1]||``,t=process.execPath||process.argv[0]||``;return T()===`windows`&&(e=e.split(j.sep).join(A.sep),t=t.split(j.sep).join(A.sep)),[e,t]}async function Qe(){let[e]=Ze();if(D())return H()||Je()||Ke()||qe()||await W()||await G()||await K()||await q()?`package-manager`:`native`;if(Ie())return`npm-local`;if([`/usr/local/lib/node_modules`,`/usr/lib/node_modules`,`/opt/homebrew/lib/node_modules`,`/opt/homebrew/bin`,`/usr/local/bin`,`/.nvm/versions/node/`].some(t=>e.includes(t))||e.includes(`/npm/`)||e.includes(`/nvm/`))return`npm-global`;let t=await ve(`npm config get prefix`,{shell:!0,reject:!1}),n=t.exitCode===0?t.stdout.trim():null;return n&&e.startsWith(n)?`npm-global`:`unknown`}async function $e(){if(D()){try{return await Me(process.execPath)}catch{}try{let e=await w(`claude`);if(e)return e}catch{}try{return await m().stat(k(O(),`.local/bin/claude`)),k(O(),`.local/bin/claude`)}catch{}return`native`}try{return process.argv[0]||`unknown`}catch{return`unknown`}}function et(){try{return D()?process.execPath||`unknown`:process.argv[1]||`unknown`}catch{return`unknown`}}async function tt(){let e=m(),t=[],n=k(O(),`.workmate`,`local`);await N()&&t.push({type:`npm-local`,path:n});let r=[`@anthropic-ai/workmate`],i=await x(`npm`,[`-g`,`config`,`get`,`prefix`]);if(i.code===0&&i.stdout){let n=i.stdout.trim(),a=T()===`windows`,o=a?k(n,`claude`):k(n,`bin`,`claude`),s=!1;try{await e.stat(o),s=!0}catch{}if(s){let e=!1;try{(await Me(o)).includes(`/Caskroom/`)&&(e=H())}catch{}e||t.push({type:`npm-global`,path:o})}else for(let i of r){let r=a?k(n,`node_modules`,i):k(n,`lib`,`node_modules`,i);try{await e.stat(r),t.push({type:`npm-global-orphan`,path:r})}catch{}}}let a=k(O(),`.local`,`bin`,`claude`);try{await e.stat(a),t.push({type:`native`,path:a})}catch{}if(v().installMethod===`native`){let n=k(O(),`.local`,`share`,`claude`);try{await e.stat(n),t.some(e=>e.type===`native`)||t.push({type:`native`,path:n})}catch{}}return t}async function nt(e){let t=[];try{let e=u(await M(k(de(),`managed-settings.json`),`utf-8`)),n=e&&typeof e==`object`?e.strictPluginOnlyCustomization:void 0;if(n!==void 0&&typeof n!=`boolean`)if(!Array.isArray(n))t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has an invalid value (expected true or an array, got ${typeof n})`,fix:`The field is silently ignored (schema .catch rescues it). Set it to true, or an array of: ${g.join(`, `)}.`});else{let e=n.filter(e=>typeof e==`string`&&!g.includes(e));e.length>0&&t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has ${e.length} value(s) this client doesn't recognize: ${e.map(String).join(`, `)}`,fix:`These are silently ignored (forwards-compat). Known surfaces for this version: ${g.join(`, `)}. Either remove them, or this client is older than the managed-settings intended.`})}}catch{}let n=v();if(e===`development`)return t;if(e===`native`){let e=(process.env.PATH||``).split(Oe),n=k(O(),`.local`,`bin`),r=n;if(T()===`windows`&&(r=n.split(j.sep).join(A.sep)),!e.some(e=>{let t=e;T()===`windows`&&(t=e.split(j.sep).join(A.sep));let n=t.replace(/\/+$/,``),i=e.replace(/[/\\]+$/,``);return n===r||i===`~/.local/bin`||i===`$HOME/.local/bin`}))if(T()===`windows`){let e=n.split(A.sep).join(j.sep);t.push({issue:`Native installation exists but ${e} is not in your PATH`,fix:`Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`})}else{let e=P(),n=I()[e],r=n?n.replace(O(),`~`):`your shell config file`;t.push({issue:`Native installation exists but ~/.local/bin is not in your PATH`,fix:`Run: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ${r} then open a new terminal or run: source ${r}`})}}a(process.env.DISABLE_INSTALLATION_CHECKS)||(e===`npm-local`&&n.installMethod!==`local`&&t.push({issue:`Running from local installation but config install method is '${n.installMethod}'`,fix:`Consider using native installation: claude install`}),e===`native`&&n.installMethod!==`native`&&t.push({issue:`Running native installation but config install method is '${n.installMethod}'`,fix:`Run claude install to update configuration`})),e===`npm-global`&&await N()&&t.push({issue:`Local installation exists but not being used`,fix:`Consider using native installation: claude install`});let r=await R(),i=await ze();return e===`npm-local`&&!await w(`claude`)&&!i&&(r?t.push({issue:`Local installation not accessible`,fix:`Alias exists but points to invalid target: ${r}. Update alias: alias claude="~/.workmate/local/claude"`}):t.push({issue:`Local installation not accessible`,fix:`Create alias: alias claude="~/.workmate/local/claude"`})),t}function rt(){if(T()!==`linux`)return[];let e=[],t=ee.getLinuxGlobPatternWarnings();if(t.length>0){let n=t.slice(0,3).join(`, `),r=t.length-3,i=r>0?`${n} (${r} more)`:n;e.push({issue:`Glob patterns in sandbox permission rules are not fully supported on Linux`,fix:`Found ${t.length} pattern(s): ${i}. On Linux, glob patterns in Edit/Read rules will be ignored.`})}return e}async function it(){let e=await Qe(),t=typeof MACRO<`u`?`0.0.17`:`unknown`,n=await $e(),r=et(),i=await tt(),a=await nt(e);if(a.push(...rt()),e===`native`){let e=i.filter(e=>e.type===`npm-global`||e.type===`npm-global-orphan`||e.type===`npm-local`),t=T()===`windows`;for(let n of e)n.type===`npm-global`?a.push({issue:`Leftover npm global installation at ${n.path}`,fix:`Run: npm -g uninstall @anthropic-ai/workmate`}):n.type===`npm-global-orphan`?a.push({issue:`Orphaned npm global package at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`}):n.type===`npm-local`&&a.push({issue:`Leftover npm local installation at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`})}let o=v().installMethod||`not set`,s=null;e===`npm-global`&&(s=(await Ue()).hasPermissions,!s&&!_()&&a.push({issue:`Insufficient permissions for auto-updates`,fix:"Do one of: (1) Re-install node without sudo, or (2) Use `claude install` for native installation"}));let c=we(),ee={working:c.working??!0,mode:c.mode,systemPath:c.mode===`system`?c.path:null,note:c.note??null},te=e===`package-manager`?await Ye():void 0;return{installationType:e,version:t,installationPath:n,invokedBinary:r,configInstallMethod:o,autoUpdates:(()=>{let e=_();return e?`disabled (${he(e)})`:`enabled`})(),hasUpdatePermissions:s,multipleInstallations:i,warnings:a,packageManager:te,ripgrepStatus:ee}}var at=e((()=>{ge(),Ge(),be(),y(),te(),o(),b(),f(),F(),Xe(),E(),Ce(),c(),ue(),le(),B(),h(),ye()}));function J(e){return{env:e?.env??process.env,home:e?.homedir??process.env.HOME??O()}}function Y(e,...t){return e.includes(`/`)&&!e.includes(`\\`)&&!/^[A-Za-z]:/.test(e)?A.join(e,...t):k(e,...t)}function ot(e){let{env:t,home:n}=J(e);return t.XDG_STATE_HOME??Y(n,`.local`,`state`)}function st(e){let{env:t,home:n}=J(e);return t.XDG_CACHE_HOME??Y(n,`.cache`)}function ct(e){let{env:t,home:n}=J(e);return t.XDG_DATA_HOME??Y(n,`.local`,`share`)}function lt(e){let{home:t}=J(e);return Y(t,`.local`,`bin`)}var ut=e((()=>{}));function dt(){let e=process.env.ENABLE_PID_BASED_VERSION_LOCKING;return a(e)?!0:(r(e),!1)}function X(e){if(e<=1)return!1;try{return process.kill(e,0),!0}catch{return!1}}function ft(e,t){if(!X(e))return!1;if(e===process.pid)return!0;try{let n=Ee(e);if(!n)return!0;let r=n.toLowerCase(),i=t.toLowerCase();return r.includes(`claude`)||r.includes(i)}catch{return!0}}function Z(e){let t=m();try{let n=t.readFileSync(e,{encoding:`utf8`});if(!n||n.trim()===``)return null;let r=u(n);return typeof r.pid!=`number`||!r.version||!r.execPath?null:r}catch{return null}}function Q(e){let t=Z(e);if(!t)return!1;let{pid:n,execPath:r}=t;if(!X(n))return!1;if(!ft(n,r))return d(`Lock PID ${n} is running but does not appear to be Work Mate - treating as stale`),!1;let i=m();try{let t=i.statSync(e);if(Date.now()-t.mtimeMs>$&&!X(n))return!1}catch{}return!0}function pt(e,t){let n=m(),r=`${e}.tmp.${process.pid}.${Date.now()}`;try{ae(r,re(t,null,2),{encoding:`utf8`,flush:!0}),n.renameSync(r,e)}catch(e){try{n.unlinkSync(r)}catch{}throw e}}async function mt(e,t){let n=m(),r=De(e);if(Q(t))return d(`Cannot acquire lock for ${r} - held by PID ${Z(t)?.pid}`),null;let i={pid:process.pid,version:r,execPath:process.execPath,acquiredAt:Date.now()};try{return pt(t,i),Z(t)?.pid===process.pid?(d(`Acquired PID lock for ${r} (PID ${process.pid})`),()=>{try{Z(t)?.pid===process.pid&&(n.unlinkSync(t),d(`Released PID lock for ${r}`))}catch(e){d(`Failed to release lock for ${r}: ${e}`)}}):null}catch(e){return d(`Failed to acquire lock for ${r}: ${e}`),null}}async function ht(e,t){let n=await mt(e,t);if(!n)return!1;let r=()=>{try{n()}catch{}};return process.on(`exit`,r),process.on(`SIGINT`,r),process.on(`SIGTERM`,r),!0}async function gt(e,t,n){let r=await mt(e,t);if(!r)return!1;try{return await n(),!0}finally{r()}}function _t(e){let t=m(),n=[];try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let t of r){let r=k(e,t),i=Z(r);i&&n.push({version:i.version,pid:i.pid,isProcessRunning:X(i.pid),execPath:i.execPath,acquiredAt:new Date(i.acquiredAt),lockFilePath:r})}}catch(e){if(ne(e))return n;C(oe(e))}return n}function vt(e){let t=m(),n=0;try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let i of r){let r=k(e,i);try{t.lstatSync(r).isDirectory()?(t.rmSync(r,{recursive:!0,force:!0}),n++,d(`Cleaned up legacy directory lock: ${i}`)):Q(r)||(t.unlinkSync(r),n++,d(`Cleaned up stale lock: ${i}`))}catch{}}}catch(e){if(ne(e))return 0;C(oe(e))}return n}var $,yt=e((()=>{p(),o(),l(),f(),Te(),S(),h(),$=7200*1e3}));export{L as C,F as E,B as S,P as T,Be as _,Q as a,Le as b,gt as c,ct as d,ot as f,at as g,it as h,yt as i,lt as l,Qe as m,vt as n,dt as o,ut as p,_t as r,Z as s,ht as t,st as u,Ge as v,Re as w,I as x,Ve as y};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$T as t,D as n,Gg as r,Hg as i,QT as a,_b as o,b as s,lb as c,nE as l}from"./loadAgentsDir-CwEfQDOw.js";import{I as u,P as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as m,zt as h}from"./state-BPFYBqm1.js";import{a as g,i as _,r as v,t as y}from"./promptEditor-DQ9fpdQD.js";import{r as b,t as x}from"./staticRender-D9AbnQFr.js";function S({planContent:e,planPath:t,editorName:n}){return(0,w.jsxs)(u,{flexDirection:`column`,children:[(0,w.jsx)(d,{bold:!0,children:`Current Plan`}),(0,w.jsx)(d,{dimColor:!0,children:t}),(0,w.jsx)(u,{marginTop:1,children:(0,w.jsx)(d,{children:e})}),n&&(0,w.jsxs)(u,{marginTop:1,children:[(0,w.jsx)(d,{dimColor:!0,children:`"/plan open"`}),(0,w.jsx)(d,{dimColor:!0,children:` to edit this plan in `}),(0,w.jsx)(d,{bold:!0,dimColor:!0,children:n})]})]})}async function C(e,r,s){let{getAppState:c,setAppState:l}=r,u=c().toolPermissionContext.mode;if(u!==`plan`){h(u,`plan`),l(e=>({...e,toolPermissionContext:i(n(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=s.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let d=a(),f=t();if(!d)return e(`Already in plan mode. No plan written yet.`),null;if(s.trim().split(/\s+/)[0]===`open`){let t=await y(f);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${f}`),null}let p=_();return e(await b((0,w.jsx)(S,{planContent:d,planPath:f,editorName:p?o(p):void 0}))),null}var w;e((()=>{m(),f(),g(),c(),r(),s(),l(),v(),x(),w=p()}))();export{C as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{D as t,Gg as n,Hg as r,XT as i,ZT as a,_b as o,b as s,eE as c,lb as l}from"./loadAgentsDir-CbtNPJV3.js";import{I as u,P as d,t as f}from"./src-DL3w8VPk2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as m,zt as h}from"./state-BPFYBqm1.js";import{a as g,i as _,r as v,t as y}from"./promptEditor-CRIw6vJS.js";import{r as b,t as x}from"./staticRender-D9AbnQFr.js";function S({planContent:e,planPath:t,editorName:n}){return(0,w.jsxs)(u,{flexDirection:`column`,children:[(0,w.jsx)(d,{bold:!0,children:`Current Plan`}),(0,w.jsx)(d,{dimColor:!0,children:t}),(0,w.jsx)(u,{marginTop:1,children:(0,w.jsx)(d,{children:e})}),n&&(0,w.jsxs)(u,{marginTop:1,children:[(0,w.jsx)(d,{dimColor:!0,children:`"/plan open"`}),(0,w.jsx)(d,{dimColor:!0,children:` to edit this plan in `}),(0,w.jsx)(d,{bold:!0,dimColor:!0,children:n})]})]})}async function C(e,n,s){let{getAppState:c,setAppState:l}=n,u=c().toolPermissionContext.mode;if(u!==`plan`){h(u,`plan`),l(e=>({...e,toolPermissionContext:r(t(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let n=s.trim();return n&&n!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let d=i(),f=a();if(!d)return e(`Already in plan mode. No plan written yet.`),null;if(s.trim().split(/\s+/)[0]===`open`){let t=await y(f);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${f}`),null}let p=_();return e(await b((0,w.jsx)(S,{planContent:d,planPath:f,editorName:p?o(p):void 0}))),null}var w;e((()=>{m(),f(),g(),l(),n(),s(),c(),v(),x(),w=p()}))();export{C 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-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$h as o,$o as s,$x as c,Ao as l,Bo as u,Bw as d,Cx as f,Do as p,Dp as m,Fw as h,Go as g,Ho as ee,Hw as _,Io as v,Jo as te,Kx as y,Lo as b,Mu as x,No as S,Nw as ne,Op as C,Pu as w,Qo as re,Qx as ie,To as T,Uw as E,Wo as D,Xh as O,Xo as ae,Xx as k,Yo as oe,Zh as A,Zo as se,Zx as ce,aS as j,as as M,bw as le,bx as ue,cd as N,co as de,dg as fe,eS as P,es as F,gw as pe,hC as me,ho as he,iS as ge,is as _e,kw as ve,ld as I,lo as ye,mo as be,nS as L,ns as xe,oS as Se,qx as Ce,rS as we,tS as Te,ug as Ee,wo as De,xC as Oe,xo as ke,yw as Ae,zw as je}from"./loadAgentsDir-CwEfQDOw.js";import{D as Me,Gr as Ne,Gt as R,H as Pe,I as z,P as B,T as V,Wt as Fe,Xn as Ie,ai as Le,hn as Re,j as ze,k as Be,n as Ve,ot as He,r as Ue,t as We,x as Ge,y as Ke}from"./src-DL3w8VPk2.js";import{t as qe}from"./jsx-runtime-Bb4Xn-E0.js";import{P as Je,R as Ye,S as Xe,U as Ze,c as Qe,i as $e,x as et}from"./debug-BQj6h99Q.js";import{Ln as tt,Rn as nt,c as rt,f as it,g as at,vt as ot,x as st,xt as ct}from"./settings-CvhsRFaT.js";import{b as lt,h as ut}from"./config-BSkuQZNf.js";import{o as dt,s as ft}from"./log-BlJ7CcKG.js";import{n as pt,r as mt}from"./analytics-DJobLaWP.js";import{C as ht,y as gt}from"./startupProfiler-2sjXZkIP.js";import{l as H,o as _t}from"./stringUtils-BjnclTLB.js";import{n as vt,t as yt}from"./pluginStartupCheck-BLc0U7W7.js";import{a as bt,d as xt,f as St,i as Ct,l as wt,o as Tt,s as Et,u as Dt}from"./pluginOperations-C7BCR7pw.js";import{a as Ot,c as kt,i as At,n as jt,o as Mt,s as Nt,t as Pt}from"./validatePlugin-CSE8zjZn.js";import{a as Ft,n as It,o as Lt,r as Rt}from"./pluginFlagging-srvq9H7p.js";import{i as zt,n as Bt}from"./MCPConnectionManager-BNG7iSlw.js";import{n as Vt,t as Ht}from"./useExitOnCtrlCDWithKeybindings-D48aDPG9.js";import{t as Ut}from"./SearchBox-CwwV0W-w.js";import{n as Wt,t as Gt}from"./useSearchInput-DkVER3cm.js";import{a as Kt,c as qt,i as Jt,n as Yt,o as Xt,r as Zt,s as Qt,t as $t}from"./MCPToolListView-jw0tITfc.js";import{i as en,n as tn}from"./pluginAutoupdate-B4w7SSYc.js";import*as nn from"path";import*as rn from"fs/promises";function an({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:o,setResult:s,setViewState:c,onAddComplete:u,cliMode:d=!1}){let f=(0,on.useRef)(!1),[p,h]=(0,on.useState)(!1),[g,ee]=(0,on.useState)(``),_=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ot(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{h(!0),ee(``);let{name:e,resolvedSource:t}=await l(n,e=>{ee(e)});D(e,{source:t}),_e();let r=n.source;n.source===`github`&&(r=n.repo),mt(`tengu_marketplace_added`,{source_type:r}),u&&await u(),ee(``),h(!1),d?s(`Successfully added marketplace: ${e}`):c({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=Ze(e);ft(t),a(t.message),ee(``),h(!1),s(d?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!f.current&&!i&&!o&&(f.current=!0,_())},[]),(0,U.jsxs)(z,{flexDirection:`column`,children:[(0,U.jsxs)(z,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(z,{marginBottom:1,children:(0,U.jsx)(B,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(z,{flexDirection:`column`,children:[(0,U.jsx)(B,{children:`Enter marketplace source:`}),(0,U.jsx)(B,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(B,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(B,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(B,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(B,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(N,{value:e,onChange:t,onSubmit:_,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),p&&(0,U.jsxs)(z,{marginTop:1,children:[(0,U.jsx)(x,{}),(0,U.jsx)(B,{children:g||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(B,{color:`error`,children:i})}),o&&(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(B,{children:o})})]}),(0,U.jsx)(z,{marginLeft:3,children:(0,U.jsx)(B,{dimColor:!0,italic:!0,children:(0,U.jsxs)(V,{children:[(0,U.jsx)(Me,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{on=t(Le(),1),pt(),C(),We(),w(),I(),Ye(),dt(),M(),v(),At(),U=qe()}));function cn(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 ln({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let s=Object.keys(n),c=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[l,u]=(0,un.useState)(0),[d,f]=(0,un.useState)({}),[p,m]=(0,un.useState)(()=>s[0]?c(s[0]):``),h=s[l],g=h?n[h]:null;if(Fe(`confirm:no`,o,{context:`Settings`}),R({"confirm:nextField":(0,un.useCallback)(()=>{if(l<s.length-1&&h){f(e=>({...e,[h]:p})),u(e=>e+1);let e=s[l+1];m(e?c(e):``)}},[l,s,h,p,c]),"confirm:yes":(0,un.useCallback)(()=>{if(!h)return;let e={...d,[h]:p};if(l===s.length-1)i(cn(s,e,n,r));else{f(e),u(e=>e+1);let t=s[l+1];m(t?c(t):``)}},[h,d,p,l,s,n,i,c,r])},{context:`Confirmation`}),Re((e,t)=>{if(t.backspace||t.delete){m(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&m(t=>t+e)}),!g||!h)return null;let ee=g.sensitive===!0,_=g.required===!0,v=ee?`*`.repeat(Ne(p)):p;return(0,dn.jsxs)(Ke,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(z,{flexDirection:`column`,children:[(0,dn.jsxs)(B,{bold:!0,children:[g.title||h,_&&(0,dn.jsx)(B,{color:`error`,children:` *`})]}),g.description&&(0,dn.jsx)(B,{dimColor:!0,children:g.description}),(0,dn.jsxs)(z,{marginTop:1,children:[(0,dn.jsxs)(B,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(B,{children:v}),(0,dn.jsx)(B,{children:`█`})]})]}),(0,dn.jsxs)(z,{flexDirection:`column`,children:[(0,dn.jsxs)(B,{dimColor:!0,children:[`Field `,l+1,` of `,s.length]}),l<s.length-1&&(0,dn.jsx)(B,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),l===s.length-1&&(0,dn.jsx)(B,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(Le(),1),We(),me(),r(),dn=qe()}));async function pn(e){let{enabled:t,disabled:n}=await ye();return[...t,...n].find(t=>t.repository===e||t.source===e)}function mn({plugin:e,pluginId:t,onDone:n}){let[r]=hn.useState(()=>{let n=[],r=k(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>ie(t),save:n=>c(t,n,e.manifest.userConfig)});let i=y(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>L(t,r.server)??void 0,save:e=>ge(t,r.server,e,r.configSchema)});return n}),[i,a]=hn.useState(0),o=hn.useRef(n);if(o.current=n,hn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function l(e){try{s.save(e)}catch(e){n(`error`,Je(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,gn.jsx)(ln,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:l,onCancel:()=>n(`skipped`)},s.key)}var hn,gn,_n=e((()=>{hn=t(Le(),1),Ye(),P(),Ce(),de(),ce(),fn(),gn=qe()}));function vn(){let e=s();return(0,yn.jsxs)(z,{marginBottom:1,children:[(0,yn.jsxs)(B,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(B,{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 yn,bn=e((()=>{i(),We(),F(),yn=qe()}));function xn(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 Sn(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 Cn({hasSelection:e}){return(0,wn.jsx)(z,{marginTop:1,children:(0,wn.jsx)(B,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(V,{children:[e&&(0,wn.jsx)(m,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(m,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{C(),We(),wn=qe()}));function En({totalItems:e,maxVisible:t=On,selectedIndex:n=0}){let r=e>t,i=(0,Dn.useRef)(0),a=(0,Dn.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,Dn.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,Dn.useCallback)(e=>o+e,[o]),u=(0,Dn.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,Dn.useCallback)(e=>{},[]),f=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)(()=>{},[]),m=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,Dn.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 Dn,On,kn=e((()=>{Dn=t(Le(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:c}){let[l,u]=(0,W.useState)(`marketplace-list`),[d,f]=(0,W.useState)(null),[p,h]=(0,W.useState)(null),[g,ee]=(0,W.useState)([]),[_,v]=(0,W.useState)([]),[y,x]=(0,W.useState)(!0),[ne,C]=(0,W.useState)(null),[w,ie]=(0,W.useState)(0),[E,D]=(0,W.useState)(new Set),[O,k]=(0,W.useState)(new Set),oe=En({totalItems:_.length,selectedIndex:w}),[A,ce]=(0,W.useState)(0),[j,M]=(0,W.useState)(!1),[le,ue]=(0,W.useState)(null),[N,de]=(0,W.useState)(null);Fe(`confirm:no`,jn.useCallback(()=>{l===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):g.length===1?i({type:`menu`}):(u(`marketplace-list`),f(null),D(new Set)):l===`plugin-details`?(u(`plugin-list`),h(null)):i({type:`menu`})},[l,s,i,g.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await b(),{marketplaces:n,failures:r}=await xe(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=tt(r.plugins,t=>T(te(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:re(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),ee(i);let a=se(r,tt(n,e=>e.data!==null));if(a)if(a.type===`warning`)de(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!c){let e=i[0];e&&(f(e.name),u(`plugin-list`))}if(c){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await S(t);if(e){let i=e.plugins.find(e=>e.name===c);if(i){let e=te(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:De(e)},r=t;break}}}if(n&&r){let e=n.pluginId;De(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(f(r),h(n),u(`plugin-details`))}else t(`Plugin "${c}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(f(s),u(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{x(!1)}}e()},[t,s,c]),(0,W.useEffect)(()=>{if(!d)return;let e=!1;async function n(n){x(!0);try{let t=await S(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=te(e.name,n);fe(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:De(t)})}try{let t=await Nt();if(e)return;C(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;Qe(`Failed to fetch install counts: ${Je(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}v(r),ie(0),D(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{x(!1)}}return n(d),()=>{e=!0}},[d,t]);let P=async()=>{if(E.size===0)return;let e=_.filter(e=>E.has(e.pluginId));k(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await he({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}k(new Set),D(new Set),_e(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ae(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ae(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},F=async(e,t=`user`)=>{M(!0),ue(null);let n=await he({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){M(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else M(!1),ue(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),R({"select:previous":()=>{w>0&&ie(w-1)},"select:next":()=>{w<g.length-1&&ie(w+1)},"select:accept":()=>{let e=g[w];e&&(f(e.name),u(`plugin-list`))}},{context:`Select`,isActive:l===`marketplace-list`}),R({"select:previous":()=>{w>0&&oe.handleSelectionChange(w-1,ie)},"select:next":()=>{w<_.length-1&&oe.handleSelectionChange(w+1,ie)},"select:accept":()=>{if(w===_.length&&E.size>0)P();else if(w<_.length){let e=_[w];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(h(e),u(`plugin-details`),ce(0),ue(null)))}}},{context:`Select`,isActive:l===`plugin-list`}),R({"plugin:toggle":()=>{if(w<_.length){let e=_[w];if(e&&!e.isInstalled){let t=new Set(E);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),D(t)}}},"plugin:install":()=>{E.size>0&&P()}},{context:`Plugin`,isActive:l===`plugin-list`});let pe=jn.useMemo(()=>{if(!p)return[];let e=p.entry.homepage;return Sn(e,xn(p))},[p]);if(R({"select:previous":()=>{A>0&&ce(A-1)},"select:next":()=>{A<pe.length-1&&ce(A+1)},"select:accept":()=>{if(!p)return;let e=pe[A]?.action,t=p.entry.homepage,n=xn(p);e===`install-user`?F(p,`user`):e===`install-project`?F(p,`project`):e===`install-local`?F(p,`local`):e===`homepage`&&t?Se(t):e===`github`&&n?Se(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),h(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!p}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(mn,{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(y)return(0,G.jsx)(B,{children:`Loading…`});if(e)return(0,G.jsx)(B,{color:`error`,children:e});if(l===`marketplace-list`)return g.length===0?(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(B,{children:`No marketplaces configured.`}),(0,G.jsxs)(B,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(z,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(B,{dimColor:!0,children:(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Select marketplace`})}),N&&(0,G.jsx)(z,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(B,{color:`warning`,children:[a.warning,` `,N]})}),g.map((e,t)=>(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:+(t<g.length-1),children:[(0,G.jsx)(z,{children:(0,G.jsxs)(B,{color:w===t?`suggestion`:void 0,children:[w===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(z,{marginLeft:2,children:(0,G.jsxs)(B,{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)(z,{marginTop:1,children:(0,G.jsx)(B,{dimColor:!0,italic:!0,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(l===`plugin-details`&&p){let e=p.entry.homepage,t=Sn(e,xn(p));return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(B,{bold:!0,children:p.entry.name}),p.entry.version&&(0,G.jsxs)(B,{dimColor:!0,children:[`Version: `,p.entry.version]}),p.entry.description&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsx)(B,{children:p.entry.description})}),p.entry.author&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsxs)(B,{dimColor:!0,children:[`By:`,` `,typeof p.entry.author==`string`?p.entry.author:p.entry.author.name]})})]}),(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(B,{bold:!0,children:`Will install:`}),p.entry.commands&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(p.entry.commands)?p.entry.commands.join(`, `):Object.keys(p.entry.commands).join(`, `)]}),p.entry.agents&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(p.entry.agents)?p.entry.agents.join(`, `):Object.keys(p.entry.agents).join(`, `)]}),p.entry.hooks&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Hooks: `,Object.keys(p.entry.hooks).join(`, `)]}),p.entry.mcpServers&&(0,G.jsxs)(B,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(p.entry.mcpServers)?p.entry.mcpServers.join(`, `):typeof p.entry.mcpServers==`object`?Object.keys(p.entry.mcpServers).join(`, `):`configured`]}),!p.entry.commands&&!p.entry.agents&&!p.entry.hooks&&!p.entry.mcpServers&&(typeof p.entry.source==`object`&&`source`in p.entry.source&&(p.entry.source.source===`github`||p.entry.source.source===`url`||p.entry.source.source===`npm`||p.entry.source.source===`pip`)?(0,G.jsx)(B,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(B,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(vn,{}),le&&(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsxs)(B,{color:`error`,children:[`Error: `,le]})}),(0,G.jsx)(z,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(z,{children:[A===t&&(0,G.jsx)(B,{children:`> `}),A!==t&&(0,G.jsx)(B,{children:` `}),(0,G.jsx)(B,{bold:A===t,children:j&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(z,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(B,{dimColor:!0,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(_.length===0)return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(B,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(B,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(z,{marginLeft:3,children:(0,G.jsx)(B,{dimColor:!0,italic:!0,children:(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let me=oe.getVisibleItems(_);return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Install Plugins`})}),oe.scrollPosition.canScrollUp&&(0,G.jsx)(z,{children:(0,G.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),me.map((t,n)=>{let r=oe.toActualIndex(n),i=w===r,o=E.has(t.pluginId),s=O.has(t.pluginId);return(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:n===me.length-1&&!e?0:1,children:[(0,G.jsxs)(z,{children:[(0,G.jsxs)(B,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(B,{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)(B,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(B,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(B,{dimColor:!0,children:` (installed)`}),ne&&d===`claude-plugins-official`&&(0,G.jsxs)(B,{dimColor:!0,children:[` · `,Mt(ne.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(z,{marginLeft:4,children:[(0,G.jsx)(B,{dimColor:!0,children:ht(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(B,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),oe.scrollPosition.canScrollDown&&(0,G.jsx)(z,{children:(0,G.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsxs)(B,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:E.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(Le(),1),W=t(Le(),1),C(),We(),me(),nt(),j(),$e(),Ye(),M(),kt(),ke(),F(),v(),ve(),be(),Ee(),_t(),gt(),_n(),bn(),Tn(),kn(),G=qe()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:c}){let[l,u]=(0,K.useState)(`plugin-list`),[d,f]=(0,K.useState)(null),[p,h]=(0,K.useState)([]),[g,ee]=(0,K.useState)(!0),[_,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(!1),S=(0,K.useCallback)(e=>{x(e),s?.(e)},[s]),{query:ne,setQuery:C,cursorOffset:w}=Wt({isActive:l===`plugin-list`&&y&&!g,onExit:()=>{S(!1)}}),re=Ie(),{columns:ie}=He(),T=(0,K.useMemo)(()=>{if(!ne)return p;let e=ne.toLowerCase();return p.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[p,ne]),[E,D]=(0,K.useState)(0),[O,k]=(0,K.useState)(new Set),[A,ce]=(0,K.useState)(new Set),j=En({totalItems:T.length,selectedIndex:E});(0,K.useEffect)(()=>{D(0)},[ne]);let[M,le]=(0,K.useState)(0),[ue,N]=(0,K.useState)(!1),[de,P]=(0,K.useState)(null),[F,pe]=(0,K.useState)(null),[me,ge]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await b(),{marketplaces:n,failures:r}=await xe(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=te(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:De(t)})}let a=i.filter(e=>!e.isInstalled&&!fe(e.pluginId));try{let e=await Nt();v(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){Qe(`Failed to fetch install counts: ${Je(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}h(a);let o=Object.keys(e).length;if(a.length===0){let e=await oe({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});ge(e)}let s=se(r,tt(n,e=>e.data!==null));if(s)if(s.type===`warning`)pe(`${s.message}. Showing available plugins.`);else throw Error(s.message);if(c){let e=i.find(e=>e.entry.name===c);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(f(e),u(`plugin-details`)):t(`Plugin "${c}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{ee(!1)}}e()},[t,c]);let ve=async()=>{if(O.size===0)return;let e=p.filter(e=>O.has(e.pluginId));ce(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await he({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ce(new Set),k(new Set),_e(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ae(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ae(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},I=async(e,t=`user`)=>{N(!0),P(null);let n=await he({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){N(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else N(!1),P(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),Fe(`confirm:no`,()=>{u(`plugin-list`),f(null)},{context:`Confirmation`,isActive:l===`plugin-details`}),Fe(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:l===`plugin-list`&&!y}),Re((e,t)=>{let n=!t.ctrl&&!t.meta;y||(e===`/`&&n?(S(!0),C(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(S(!0),C(e)))},{isActive:l===`plugin-list`&&!g}),R({"select:previous":()=>{E===0?S(!0):j.handleSelectionChange(E-1,D)},"select:next":()=>{E<T.length-1&&j.handleSelectionChange(E+1,D)},"select:accept":()=>{if(E===T.length&&O.size>0)ve();else if(E<T.length){let e=T[E];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(f(e),u(`plugin-details`),le(0),P(null)))}}},{context:`Select`,isActive:l===`plugin-list`&&!y}),R({"plugin:toggle":()=>{if(E<T.length){let e=T[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&&ve()}},{context:`Plugin`,isActive:l===`plugin-list`&&!y});let ye=In.useMemo(()=>{if(!d)return[];let e=d.entry.homepage;return Sn(e,xn(d))},[d]);if(R({"select:previous":()=>{M>0&&le(M-1)},"select:next":()=>{M<ye.length-1&&le(M+1)},"select:accept":()=>{if(!d)return;let e=ye[M]?.action,t=d.entry.homepage,n=xn(d);e===`install-user`?I(d,`user`):e===`install-project`?I(d,`project`):e===`install-local`?I(d,`local`):e===`homepage`&&t?Se(t):e===`github`&&n?Se(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),f(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!d}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(mn,{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(g)return(0,q.jsx)(B,{children:`Loading…`});if(e)return(0,q.jsx)(B,{color:`error`,children:e});if(l===`plugin-details`&&d){let e=d.entry.homepage,t=Sn(e,xn(d));return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(B,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(B,{bold:!0,children:d.entry.name}),(0,q.jsxs)(B,{dimColor:!0,children:[`from `,d.marketplaceName]}),d.entry.version&&(0,q.jsxs)(B,{dimColor:!0,children:[`Version: `,d.entry.version]}),d.entry.description&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{children:d.entry.description})}),d.entry.author&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsxs)(B,{dimColor:!0,children:[`By:`,` `,typeof d.entry.author==`string`?d.entry.author:d.entry.author.name]})})]}),(0,q.jsx)(vn,{}),de&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{color:`error`,children:[`Error: `,de]})}),(0,q.jsx)(z,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(z,{children:[M===t&&(0,q.jsx)(B,{children:`> `}),M!==t&&(0,q.jsx)(B,{children:` `}),(0,q.jsx)(B,{bold:M===t,children:ue&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,children:(0,q.jsxs)(V,{children:[(0,q.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(p.length===0)return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(B,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:me}),(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let be=j.getVisibleItems(T);return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsxs)(z,{children:[(0,q.jsx)(B,{bold:!0,children:`Discover plugins`}),j.needsPagination&&(0,q.jsxs)(B,{dimColor:!0,children:[` `,`(`,j.scrollPosition.current,`/`,j.scrollPosition.total,`)`]})]}),(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(Be,{query:ne,isFocused:y,isTerminalFocused:re,width:ie-4,cursorOffset:w})}),F&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{color:`warning`,children:[a.warning,` `,F]})}),T.length===0&&ne&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{dimColor:!0,children:[`No plugins match "`,ne,`"`]})}),j.scrollPosition.canScrollUp&&(0,q.jsx)(z,{children:(0,q.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),be.map((t,n)=>{let r=j.toActualIndex(n),i=E===r,o=O.has(t.pluginId),s=A.has(t.pluginId);return(0,q.jsxs)(z,{flexDirection:`column`,marginBottom:n===be.length-1&&!e?0:1,children:[(0,q.jsxs)(z,{children:[(0,q.jsxs)(B,{color:i&&!y?`suggestion`:void 0,children:[i&&!y?a.pointer:` `,` `]}),(0,q.jsxs)(B,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(B,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(B,{dimColor:!0,children:` [Community Managed]`}),_&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(B,{dimColor:!0,children:[` · `,Mt(_.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(z,{marginLeft:4,children:(0,q.jsx)(B,{dimColor:!0,children:ht(t.entry.description,60)})})]},`${j.startIndex}-${t.pluginId}`)}),j.scrollPosition.canScrollDown&&(0,q.jsx)(z,{children:(0,q.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsxs)(B,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:O.size>0,canToggle:E<T.length&&!T[E]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,italic:!0,children:(0,q.jsxs)(V,{children:[e&&(0,q.jsx)(m,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(B,{children:`type to search`}),t&&(0,q.jsx)(m,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Fn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(B,{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)(B,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(B,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(B,{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)(B,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(B,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(B,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(B,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(Le(),1),K=t(Le(),1),C(),Ut(),We(),Gt(),Oe(),me(),nt(),j(),$e(),Ye(),M(),kt(),ke(),F(),v(),ve(),be(),Ee(),_t(),gt(),_n(),bn(),Tn(),kn(),q=qe()}));function Rn({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:c}){let[l,d]=(0,Bn.useState)([]),[f,p]=(0,Bn.useState)(!0),[h,_]=(0,Bn.useState)(0),[v,y]=(0,Bn.useState)(!1),[x,S]=(0,Bn.useState)(null),[ne,C]=(0,Bn.useState)(null),[w,ie]=(0,Bn.useState)(null),[T,E]=(0,Bn.useState)(`list`),[D,O]=(0,Bn.useState)(null),[ae,k]=(0,Bn.useState)(0),oe=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await b(),{enabled:r,disabled:i}=await ye(),a=[...r,...i],{marketplaces:o,failures:l}=await xe(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:re(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}u.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(u);let f=se(l,tt(o,e=>e.data!==null));if(f)if(f.type===`warning`)S(f.message);else throw Error(f.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(c){_(e+1);let t=[...u];c===`update`?t[e].pendingUpdate=!0:c===`remove`&&(t[e].pendingRemove=!0),d(t),setTimeout(j,100,t)}else t&&(_(e+1),O(t),E(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),S(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{p(!1)}}e()},[s,c,t]);let A=()=>l.some(e=>e.pendingUpdate||e.pendingRemove),ce=()=>({updateCount:tt(l,e=>e.pendingUpdate),removeCount:tt(l,e=>e.pendingRemove)}),j=async t=>{let i=t||l,s=T===`details`;y(!0),S(null),C(null),ie(null);try{let t=rt(`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=te(t.name,e.name);n[r]=!1}st(`userSettings`,{enabledPlugins:n})}await ee(e.name),c++,mt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await u(e.name,e=>{ie(e)}),n++,l.add(e.name.toLowerCase()),mt(`tengu_marketplace_updated`,{marketplace_name:e.name}))}let f=0;l.size>0&&(f=(await en(l)).length),_e(),o&&await o();let p=await b(),{enabled:m,disabled:h}=await ye(),g=[...m,...h],{marketplaces:_}=await xe(p),v=[];for(let{name:e,config:t,data:n}of _){let r=g.filter(t=>t.source.endsWith(`@${e}`));v.push({name:e,source:re(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}if(v.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(v),s&&D){let e=v.find(e=>e.name===D.name);e&&O(e)}let y=[];if(n>0){let e=f>0?` (${f} ${H(f,`plugin`)} bumped)`:``;y.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&y.push(`Removed ${c} ${H(c,`marketplace`)}`),y.length>0){let t=`${a.tick} ${y.join(`, `)}`;s?C(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Je(e);S(t),n&&n(t)}finally{y(!1),ie(null)}},M=async()=>{if(!D)return;let e=l.map(e=>e.name===D.name?{...e,pendingRemove:!0}:e);d(e),await j(e)},le=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 lt()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},ue=async e=>{let t=!e.autoUpdate;try{await g(e.name,t),d(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),O(e=>e&&{...e,autoUpdate:t})}catch(e){S(e instanceof Error?e.message:`Failed to update setting`)}};if(Fe(`confirm:no`,()=>{E(`list`),k(0)},{context:`Confirmation`,isActive:!v&&(T===`details`||T===`confirm-remove`)}),Fe(`confirm:no`,()=>{d(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),_(0)},{context:`Confirmation`,isActive:!v&&T===`list`&&A()}),Fe(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!v&&T===`list`&&!A()}),R({"select:previous":()=>_(e=>Math.max(0,e-1)),"select:next":()=>{let e=l.length+1;_(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=h-1;if(h===0)e({type:`add-marketplace`});else if(A())j();else{let e=l[t];e&&(O(e),E(`details`),k(0))}}},{context:`Select`,isActive:!v&&T===`list`}),Re(e=>{let t=h-1;if((e===`u`||e===`U`)&&t>=0)d(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=l[t];e&&(O(e),E(`confirm-remove`))}},{isActive:!v&&T===`list`}),R({"select:previous":()=>k(e=>Math.max(0,e-1)),"select:next":()=>{let e=le(D);k(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!D)return;let t=le(D)[ae];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:D.name});else if(t?.value===`update`){let e=l.map(e=>e.name===D.name?{...e,pendingUpdate:!0}:e);d(e),j(e)}else t?.value===`toggle-auto-update`?ue(D):t?.value===`remove`&&E(`confirm-remove`)}},{context:`Select`,isActive:!v&&T===`details`}),Re(e=>{e===`y`||e===`Y`?M():(e===`n`||e===`N`)&&(E(`list`),O(null))},{isActive:!v&&T===`confirm-remove`}),f)return(0,J.jsx)(B,{children:`Loading marketplaces…`});if(l.length===0)return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(z,{marginBottom:1,children:(0,J.jsx)(B,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(B,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(B,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(z,{marginLeft:3,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(V,{children:[(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(T===`confirm-remove`&&D){let e=D.installedPlugins?.length||0;return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsxs)(B,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(B,{italic:!0,children:D.name}),`?`]}),(0,J.jsxs)(z,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),D.installedPlugins&&D.installedPlugins.length>0&&(0,J.jsx)(z,{flexDirection:`column`,marginTop:1,marginLeft:2,children:D.installedPlugins.map(e=>(0,J.jsxs)(B,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{children:[`Press `,(0,J.jsx)(B,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(B,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(T===`details`&&D){let e=D.pendingUpdate||v,t=le(D);return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(B,{bold:!0,children:D.name}),(0,J.jsx)(B,{dimColor:!0,children:D.source}),(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{children:[D.pluginCount||0,` available `,H(D.pluginCount||0,`plugin`)]})}),D.installedPlugins&&D.installedPlugins.length>0&&(0,J.jsxs)(z,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(B,{bold:!0,children:[`Installed plugins (`,D.installedPlugins.length,`):`]}),(0,J.jsx)(z,{flexDirection:`column`,marginLeft:1,children:D.installedPlugins.map(e=>(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(B,{children:a.bullet}),(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(B,{children:e.name}),(0,J.jsx)(B,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(B,{color:`claude`,children:`Updating marketplace…`}),w&&(0,J.jsx)(B,{dimColor:!0,children:w})]}),!e&&ne&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`claude`,children:ne})}),!e&&x&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`error`,children:x})}),!e&&(0,J.jsx)(z,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===ae;return(0,J.jsxs)(z,{children:[(0,J.jsxs)(B,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(B,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!lt()&&D.autoUpdate&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(z,{marginLeft:3,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(V,{children:[(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:N,removeCount:de}=ce();return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(z,{marginBottom:1,children:(0,J.jsx)(B,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(B,{color:h===0?`suggestion`:void 0,children:[h===0?a.pointer:` `,` +`]}),(0,J.jsx)(B,{bold:!0,color:h===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(z,{flexDirection:`column`,children:l.map((e,t)=>{let n=t+1===h,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(B,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(z,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(B,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(B,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(B,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(B,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(B,{dimColor:!0,children:e.source}),(0,J.jsxs)(B,{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)})}),A()&&(0,J.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(B,{children:[(0,J.jsx)(B,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(B,{dimColor:!0,children:`Enter to apply`})]}),N>0&&(0,J.jsxs)(B,{children:[`• Update `,N,` `,H(N,`marketplace`)]}),de>0&&(0,J.jsxs)(B,{color:`warning`,children:[`• Remove `,de,` `,H(de,`marketplace`)]})]}),v&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`claude`,children:`Processing changes…`})}),x&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`error`,children:x})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:A()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:(0,J.jsxs)(V,{children:[t&&(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(Me,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(Me,{shortcut:`r`,action:`remove`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),Bn=t(Le(),1),pt(),C(),We(),me(),nt(),ut(),Ye(),M(),F(),v(),tn(),de(),ot(),at(),_t(),J=qe()}));function Hn(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 _(e)}function Un(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 Wn=e((()=>{E()}));function Gn({item:e,isSelected:t}){let[n]=Pe();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=ze(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=ze(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=ze(`success`,n)(a.tick),i=`enabled`):(r=ze(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=ze(`warning`,n)(a.warning);return(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=ze(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=ze(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=ze(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=ze(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=ze(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=ze(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{dimColor:!t,children:`└ `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]}):(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),We(),_t(),Y=qe()}));async function qn(e){try{return(await rn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>nn.basename(e.name,`.md`))}catch(t){return Qe(`Failed to read plugin components from ${e}: ${Je(t)}`,{level:`error`}),ft(Ze(t)),[]}}async function Jn(e){try{let t=await rn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=nn.join(e,r.name,`SKILL.md`);try{(await rn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return Qe(`Failed to read skill directories from ${e}: ${Je(t)}`,{level:`error`}),ft(Ze(t)),[]}}function Yn({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=je(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 S(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 qn(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 qn(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 Jn(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)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(B,{bold:!0,children:`Components:`}),(0,Z.jsxs)(B,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(B,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(B,{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)(B,{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)(B,{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)(B,{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)(B,{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 Xn(e,t){let n=(await S(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 Zn(e){return e.filter(e=>{let t=e.source.split(`@`)[1]||`local`;return!fe(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=A(e=>e.mcp.clients),u=A(e=>e.mcp.tools),d=A(e=>e.plugins.errors),f=It(),[g,ee]=(0,X.useState)(!1),_=(0,X.useCallback)(e=>{ee(e),r?.(e)},[r]),v=Ie(),{columns:te}=He(),[y,b]=(0,X.useState)(`plugin-list`),{query:x,setQuery:S,cursorOffset:ne}=Wt({isActive:y===`plugin-list`&&g,onExit:()=>{_(!1)}}),[C,w]=(0,X.useState)(null),[re,T]=(0,X.useState)([]),[E,D]=(0,X.useState)([]),[O,ae]=(0,X.useState)(!0),[k,oe]=(0,X.useState)(new Map),se=(0,X.useRef)(!1),ce=(0,X.useRef)(void 0),j=zt();Fe(`confirm:no`,$n.useCallback(()=>{if(y===`plugin-details`)b(`plugin-list`),w(null),L(null);else if(typeof y==`object`&&y.type===`failed-plugin-details`)b(`plugin-list`),L(null);else if(y===`configuring`)b(`plugin-details`),Ce(null);else if(typeof y==`object`&&(y.type===`plugin-options`||y.type===`configuring-options`))b(`plugin-list`),w(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof y==`object`&&y.type===`flagged-detail`)b(`plugin-list`),L(null);else if(typeof y==`object`&&y.type===`mcp-detail`)b(`plugin-list`),L(null);else if(typeof y==`object`&&y.type===`mcp-tools`)b({type:`mcp-detail`,client:y.client});else if(typeof y==`object`&&y.type===`mcp-tool-detail`)b({type:`mcp-tools`,client:y.client});else{if(k.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[y,e,k,t]),{context:`Confirmation`,isActive:(y!==`plugin-list`||!g)&&y!==`confirm-project-uninstall`&&!(typeof y==`object`&&y.type===`confirm-data-cleanup`)});let M=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,N=(0,X.useMemo)(()=>{let e=it(),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 E){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=d.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:k.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 d){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=yt(),s=[];for(let[e,t]of a){if(e in f)continue;let n=h(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:M(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},p=[],m=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;m.has(n)||m.set(n,[]),m.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;m.has(r)||m.set(r,[]),m.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:M(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let e of s){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let[e,t]of Object.entries(f)){let n=h(e),r=n.name||e,i=n.marketplace||`unknown`;m.has(`flagged`)||m.set(`flagged`,[]),m.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let g=[...m.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of g){let t=m.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)p.push(...e);p.push(...r)}return p},[E,l,d,k,f]),de=(0,X.useMemo)(()=>N.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[N]);(0,X.useEffect)(()=>{de.length>0&&Ft(de)},[de]);let fe=(0,X.useMemo)(()=>{if(!x)return N;let e=x.toLowerCase();return N.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[N,x]),[P,F]=(0,X.useState)(0),me=En({totalItems:fe.length,selectedIndex:P,maxVisible:8}),[he,ge]=(0,X.useState)(0),[ve,I]=(0,X.useState)(!1),[be,L]=(0,X.useState)(null),[xe,Ce]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(!1),[Oe,ke]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!C){ke(!1);return}async function e(){let e=C.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&Te(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Te(e))),!t)try{let e=nn.join(C.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Xe(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===C.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&Te(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Te(e))}}catch(e){Qe(`Failed to read raw marketplace.json: ${e}`)}ke(t)}e()},[C]),(0,X.useEffect)(()=>{async function e(){ae(!0);try{let{enabled:e,disabled:t}=await ye(),n=it(),r=Zn([...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=tt(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)),T(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:Tt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}D(o),F(0)}finally{ae(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!se.current&&i&&re.length>0&&!O){let{name:e,marketplace:n}=h(i),r=o??n,a=r?re.filter(e=>e.name===r):re;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Tt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};w(r),b(`plugin-details`),ce.current=s,se.current=!0;return}}let c=N.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(b({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),se.current=!0),!se.current&&s&&(se.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,re,O,N,s,t]);let Ae=async r=>{if(!C)return;let i=C.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){L(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!wt(i)&&r!==`update`){L(`This plugin is managed by your organization. Contact your admin to disable it.`);return}I(!0),L(null);try{let o=`${C.plugin.name}@${C.marketplace}`,s;switch(r){case`enable`:{let e=await bt(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await Ct(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!wt(i))break;if(Dt(o)){I(!1),b(`confirm-project-uninstall`);return}let e=p().plugins[o],t=!e||e.length<=1?await pe(o):null;if(t){I(!1),b({type:`confirm-data-cleanup`,size:t});return}let n=await xt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await St(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${C.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}_e();let c=`${C.plugin.name}@${C.marketplace}`;if(it()?.enabledPlugins?.[c]!==!1){I(!1),b({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} ${C.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){I(!1);let t=e instanceof Error?e.message:String(e);L(`Failed to ${r}: ${t}`),ft(Ze(e))}},je=(0,X.useRef)(Ae);je.current=Ae,(0,X.useEffect)(()=>{if(y===`plugin-details`&&C&&ce.current){let e=ce.current;ce.current=void 0,je.current(e)}},[y,C]);let Me=$n.useCallback(()=>{if(P>=fe.length)return;let e=fe[P];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=it(),r=k.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||wt(a)){let e=new Map(k);r?(e.delete(t),(async()=>{try{r===`will-disable`?await bt(t):await Ct(t),_e()}catch(e){ft(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await Ct(t):await bt(t),_e()}catch(e){ft(e)}})()),oe(e)}}else e?.type===`mcp`&&j(e.client.name)},[P,fe,k,E,j]);R({"select:previous":()=>{P===0?_(!0):me.handleSelectionChange(P-1,F)},"select:next":()=>{P<fe.length-1&&me.handleSelectionChange(P+1,F)},"select:accept":$n.useCallback(()=>{if(P>=fe.length)return;let e=fe[P];if(e?.type===`plugin`){let t=E.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(w(t),b(`plugin-details`),ge(0),L(null))}else e?.type===`flagged-plugin`?(b({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),L(null)):e?.type===`failed-plugin`?(b({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),ge(0),L(null)):e?.type===`mcp`&&(b({type:`mcp-detail`,client:e.client}),L(null))},[P,fe,E])},{context:`Select`,isActive:y===`plugin-list`&&!g}),R({"plugin:toggle":Me},{context:`Plugin`,isActive:y===`plugin-list`&&!g}),R({"select:accept":$n.useCallback(()=>{typeof y!=`object`||y.type!==`flagged-detail`||(Lt(y.plugin.id),b(`plugin-list`))},[y])},{context:`Select`,isActive:typeof y==`object`&&y.type===`flagged-detail`});let Ne=$n.useMemo(()=>{if(y!==`plugin-details`||!C)return[];let e=it(),t=`${C.plugin.name}@${C.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=C.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void Ae(n?`disable`:`enable`)}),r||(i.push({label:C.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(C.plugin.name,C.marketplace);if(e){L(e);return}let t=[...E],n=t.findIndex(e=>e.plugin.name===C.plugin.name&&e.marketplace===C.marketplace);n!==-1&&(t[n].pendingUpdate=!C.pendingUpdate,D(t),w({...C,pendingUpdate:!C.pendingUpdate}))}catch(e){L(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Oe&&i.push({label:`Configure`,action:async()=>{De(!0);try{let e=C.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&Te(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&Te(n)){t=n;break}}if(!t){L(`No MCPB file found in plugin`),De(!1);return}let n=`${C.plugin.name}@${C.marketplace}`,r=await we(t,C.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ce(r),b(`configuring`)):L(`Failed to load MCPB for configuration`)}catch(e){let t=Je(e);L(`Failed to load configuration: ${t}`)}finally{De(!1)}}}),C.plugin.manifest.userConfig&&Object.keys(C.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{b({type:`configuring-options`,schema:C.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void Ae(`update`)}),i.push({label:`Uninstall`,action:()=>void Ae(`uninstall`)})),C.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void Se(C.plugin.manifest.homepage)}),C.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void Se(C.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{b(`plugin-list`),w(null),L(null)}}),i},[y,C,Oe,E]);if(R({"select:previous":()=>{he>0&&ge(he-1)},"select:next":()=>{he<Ne.length-1&&ge(he+1)},"select:accept":()=>{Ne[he]&&Ne[he].action()}},{context:`Select`,isActive:y===`plugin-details`&&!!C}),R({"select:accept":()=>{typeof y==`object`&&y.type===`failed-plugin-details`&&(async()=>{I(!0),L(null);let e=y.plugin.id,t=y.plugin.scope,r=wt(t)?await xt(e,t,!1):await xt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=rt(t);n?.enabledPlugins?.[e]!==void 0&&(st(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}_e()}i?(n&&await n(),I(!1),b(`plugin-list`)):(I(!1),L(r.message))})()}},{context:`Select`,isActive:typeof y==`object`&&y.type===`failed-plugin-details`&&y.plugin.scope!==`managed`}),R({"confirm:yes":()=>{if(!C)return;I(!0),L(null);let r=`${C.plugin.name}@${C.marketplace}`,{error:i}=st(`localSettings`,{enabledPlugins:{...rt(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){I(!1),L(`Failed to write settings: ${i.message}`);return}_e(),t(`✓ Disabled ${C.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{b(`plugin-details`),L(null)}},{context:`Confirmation`,isActive:y===`confirm-project-uninstall`&&!!C&&!ve}),Re((r,i)=>{if(!C)return;let o=`${C.plugin.name}@${C.marketplace}`,s=C.scope;if(!s||s===`builtin`||!wt(s))return;let c=async r=>{I(!0),L(null);try{let i=await xt(o,s,r);if(!i.success)throw Error(i.message);_e();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){I(!1),L(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(b(`plugin-details`),L(null))},{isActive:typeof y==`object`&&y.type===`confirm-data-cleanup`&&!!C&&!ve}),$n.useEffect(()=>{F(0)},[x]),Re((e,t)=>{let n=!t.ctrl&&!t.meta;g||(e===`/`&&n?(_(!0),S(``),F(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(_(!0),S(e),F(0)))},{isActive:y===`plugin-list`}),O)return(0,Z.jsx)(B,{children:`Loading installed plugins…`});if(N.length===0)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(B,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(B,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,children:`Esc to go back`})})]});if(typeof y==`object`&&y.type===`plugin-options`&&C){let r=`${C.plugin.name}@${C.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:C.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${C.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${C.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof y==`object`&&y.type===`configuring-options`&&C){let e=`${C.plugin.name}@${C.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${C.plugin.name}`,subtitle:`Plugin options`,configSchema:y.schema,initialValues:ie(e),onSave:n=>{try{c(e,n,y.schema),_e(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){L(`Failed to save configuration: ${Je(e)}`)}b(`plugin-details`)},onCancel:()=>b(`plugin-details`)})}if(y===`configuring`&&xe&&C){let e=`${C.plugin.name}@${C.marketplace}`;async function n(n){if(!(!xe||!C))try{let r=C.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&Te(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&Te(e)){i=e;break}}if(!i){L(`No MCPB file found`),b(`plugin-details`);return}await we(i,C.plugin.path,e,void 0,n),L(null),Ce(null),b(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Je(e);L(`Failed to save configuration: ${t}`),b(`plugin-details`)}}function r(){Ce(null),b(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${xe.manifest.name}`,subtitle:`Plugin: ${C.plugin.name}`,configSchema:xe.configSchema,initialValues:xe.existingConfig,onSave:n,onCancel:r})}if(typeof y==`object`&&y.type===`flagged-detail`){let e=y.plugin;return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(z,{marginBottom:1,children:[(0,Z.jsx)(B,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(B,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(z,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(B,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(B,{children:e.text}),(0,Z.jsxs)(B,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(z,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(z,{children:[(0,Z.jsxs)(B,{children:[a.pointer,` `]}),(0,Z.jsx)(B,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(y===`confirm-project-uninstall`&&C)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{bold:!0,color:`warning`,children:[C.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(B,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(B,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:ve?(0,Z.jsx)(B,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(V,{children:[(0,Z.jsx)(m,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof y==`object`&&y.type===`confirm-data-cleanup`&&C)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{bold:!0,children:[C.plugin.name,` has `,y.size.human,` of persistent data`]}),(0,Z.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(B,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(B,{dimColor:!0,children:le(`${C.plugin.name}@${C.marketplace}`)})]}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:ve?(0,Z.jsx)(B,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(B,{children:[(0,Z.jsx)(B,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(B,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(B,{bold:!0,children:`esc`}),` to cancel`]})})]});if(y===`plugin-details`&&C){let e=it(),t=`${C.plugin.name}@${C.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=d.filter(e=>`plugin`in e&&e.plugin===C.plugin.name||e.source===t||e.source.startsWith(`${C.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(B,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(z,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(B,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(B,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{bold:!0,children:[C.plugin.name,` @ `,C.marketplace]})}),(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(B,{children:C.scope||`user`})]}),C.plugin.manifest.version&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(B,{children:C.plugin.manifest.version})]}),C.plugin.manifest.description&&(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(B,{children:C.plugin.manifest.description})}),C.plugin.manifest.author&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(B,{children:C.plugin.manifest.author.name})]}),(0,Z.jsxs)(z,{marginBottom:1,children:[(0,Z.jsx)(B,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(B,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),C.pendingUpdate&&(0,Z.jsx)(B,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:C.plugin,marketplace:C.marketplace}),i,(0,Z.jsx)(z,{marginTop:1,flexDirection:`column`,children:Ne.map((e,t)=>{let n=t===he;return(0,Z.jsxs)(z,{children:[n&&(0,Z.jsxs)(B,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(B,{children:` `}),(0,Z.jsx)(B,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),ve&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{children:`Processing…`})}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[(0,Z.jsx)(m,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`failed-plugin-details`){let e=y.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(B,{bold:!0,children:e.name}),(0,Z.jsxs)(B,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(B,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(B,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(z,{marginTop:1,children:[(0,Z.jsxs)(B,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(B,{bold:!0,children:`Remove`})]}),ve&&(0,Z.jsx)(B,{children:`Processing…`}),be&&(0,Z.jsx)(B,{color:`error`,children:be}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[e.scope!==`managed`&&(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`mcp-detail`){let e=y.client,n=ue(u,e.name).length,r=()=>{b({type:`mcp-tools`,client:e})},i=()=>{b(`plugin-list`)},a=e=>{e&&t(e),b(`plugin-list`)},o=e.config.scope,s=e.config.type;return s===`stdio`?(0,Z.jsx)(Kt,{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)(Qt,{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)(Qt,{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)(Qt,{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}):(b(`plugin-list`),null)}if(typeof y==`object`&&y.type===`mcp-tools`){let e=y.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)($t,{server:r,onSelectTool:t=>{b({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>b({type:`mcp-detail`,client:e})})}if(typeof y==`object`&&y.type===`mcp-tool-detail`){let{client:e,tool:t}=y,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)(Zt,{tool:t,server:i,onBack:()=>b({type:`mcp-tools`,client:e})})}let Pe=me.getVisibleItems(fe);return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(Be,{query:x,isFocused:g,isTerminalFocused:v,width:te-4,cursorOffset:ne})}),fe.length===0&&x&&(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsxs)(B,{dimColor:!0,children:[`No items match "`,x,`"`]})}),me.scrollPosition.canScrollUp&&(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Pe.map((e,t)=>{let n=me.toActualIndex(t)===P&&!g,r=t>0?Pe[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(z,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(B,{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)(Gn,{item:e,isSelected:n})]},e.id)}),me.scrollPosition.canScrollDown&&(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(z,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[(0,Z.jsx)(B,{children:`type to search`}),(0,Z.jsx)(m,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),k.size>0&&(0,Z.jsx)(z,{marginLeft:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(Le(),1),X=t(Le(),1),C(),We(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),Oe(),me(),d(),Bt(),f(),Et(),O(),nt(),j(),$e(),Ye(),dt(),M(),ke(),v(),P(),Ae(),Rt(),ne(),de(),ce(),Ee(),vt(),at(),et(),_t(),Wn(),fn(),_n(),Kn(),kn(),Z=qe()}));function tr(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 nr=e((()=>{}));function rr({onComplete:e,path:t}){return(0,ir.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-DcaKZlRU.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{$h as o,$o as s,$x as c,Ao as l,Bo as u,Bw as d,Cx as f,Do as p,Dp as m,Fw as h,Go as g,Ho as ee,Hw as _,Io as v,Jo as te,Kx as y,Lo as b,Mu as x,No as S,Nw as ne,Op as C,Pu as w,Qo as re,Qx as ie,To as T,Uw as E,Wo as D,Xh as O,Xo as ae,Xx as k,Yo as oe,Zh as A,Zo as se,Zx as ce,aS as j,as as M,bw as le,bx as ue,cd as N,co as de,dg as fe,eS as P,es as F,gw as pe,hC as me,ho as he,iS as ge,is as _e,kw as ve,ld as I,lo as ye,mo as be,nS as L,ns as xe,oS as Se,qx as Ce,rS as we,tS as Te,ug as Ee,wo as De,xC as Oe,xo as ke,yw as Ae,zw as je}from"./loadAgentsDir-CbtNPJV3.js";import{D as Me,Gr as Ne,Gt as R,H as Pe,I as z,P as B,T as V,Wt as Fe,Xn as Ie,ai as Le,hn as Re,j as ze,k as Be,n as Ve,ot as He,r as Ue,t as We,x as Ge,y as Ke}from"./src-DL3w8VPk2.js";import{t as qe}from"./jsx-runtime-Bb4Xn-E0.js";import{P as Je,R as Ye,S as Xe,U as Ze,c as Qe,i as $e,x as et}from"./debug-BQj6h99Q.js";import{Ln as tt,Rn as nt,c as rt,f as it,g as at,vt as ot,x as st,xt as ct}from"./settings-CvhsRFaT.js";import{b as lt,h as ut}from"./config-BSkuQZNf.js";import{o as dt,s as ft}from"./log-BlJ7CcKG.js";import{n as pt,r as mt}from"./analytics-DJobLaWP.js";import{C as ht,y as gt}from"./startupProfiler-2sjXZkIP.js";import{l as H,o as _t}from"./stringUtils-BjnclTLB.js";import{n as vt,t as yt}from"./pluginStartupCheck-p0njap1l.js";import{a as bt,d as xt,f as St,i as Ct,l as wt,o as Tt,s as Et,u as Dt}from"./pluginOperations-wUUdFpu9.js";import{a as Ot,c as kt,i as At,n as jt,o as Mt,s as Nt,t as Pt}from"./validatePlugin-BajM6yNf.js";import{a as Ft,n as It,o as Lt,r as Rt}from"./pluginFlagging-C0PtAJEg.js";import{i as zt,n as Bt}from"./MCPConnectionManager-BnUw0nYN.js";import{n as Vt,t as Ht}from"./useExitOnCtrlCDWithKeybindings-YSWYVWk6.js";import{t as Ut}from"./SearchBox-CwwV0W-w.js";import{n as Wt,t as Gt}from"./useSearchInput-DfUNYhqC.js";import{a as Kt,c as qt,i as Jt,n as Yt,o as Xt,r as Zt,s as Qt,t as $t}from"./MCPToolListView-CY2EezWF.js";import{i as en,n as tn}from"./pluginAutoupdate-B9W_vxOG.js";import*as nn from"path";import*as rn from"fs/promises";function an({inputValue:e,setInputValue:t,cursorOffset:n,setCursorOffset:r,error:i,setError:a,result:o,setResult:s,setViewState:c,onAddComplete:u,cliMode:d=!1}){let f=(0,on.useRef)(!1),[p,h]=(0,on.useState)(!1),[g,ee]=(0,on.useState)(``),_=async()=>{let t=e.trim();if(!t){a(`Please enter a marketplace source`);return}let n=await Ot(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{h(!0),ee(``);let{name:e,resolvedSource:t}=await l(n,e=>{ee(e)});D(e,{source:t}),_e();let r=n.source;n.source===`github`&&(r=n.repo),mt(`tengu_marketplace_added`,{source_type:r}),u&&await u(),ee(``),h(!1),d?s(`Successfully added marketplace: ${e}`):c({type:`browse-marketplace`,targetMarketplace:e})}catch(e){let t=Ze(e);ft(t),a(t.message),ee(``),h(!1),s(d?`Error: ${t.message}`:null)}};return(0,on.useEffect)(()=>{e&&!f.current&&!i&&!o&&(f.current=!0,_())},[]),(0,U.jsxs)(z,{flexDirection:`column`,children:[(0,U.jsxs)(z,{flexDirection:`column`,paddingX:1,borderStyle:`round`,children:[(0,U.jsx)(z,{marginBottom:1,children:(0,U.jsx)(B,{bold:!0,children:`Add Marketplace`})}),(0,U.jsxs)(z,{flexDirection:`column`,children:[(0,U.jsx)(B,{children:`Enter marketplace source:`}),(0,U.jsx)(B,{dimColor:!0,children:`Examples:`}),(0,U.jsx)(B,{dimColor:!0,children:` · owner/repo (GitHub)`}),(0,U.jsx)(B,{dimColor:!0,children:` · git@github.com:owner/repo.git (SSH)`}),(0,U.jsx)(B,{dimColor:!0,children:` · https://example.com/marketplace.json`}),(0,U.jsx)(B,{dimColor:!0,children:` · ./path/to/marketplace`}),(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(N,{value:e,onChange:t,onSubmit:_,columns:80,cursorOffset:n,onChangeCursorOffset:r,focus:!0,showCursor:!0})})]}),p&&(0,U.jsxs)(z,{marginTop:1,children:[(0,U.jsx)(x,{}),(0,U.jsx)(B,{children:g||`Adding marketplace to configuration…`})]}),i&&(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(B,{color:`error`,children:i})}),o&&(0,U.jsx)(z,{marginTop:1,children:(0,U.jsx)(B,{children:o})})]}),(0,U.jsx)(z,{marginLeft:3,children:(0,U.jsx)(B,{dimColor:!0,italic:!0,children:(0,U.jsxs)(V,{children:[(0,U.jsx)(Me,{shortcut:`Enter`,action:`add`}),(0,U.jsx)(m,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})})]})}var on,U,sn=e((()=>{on=t(Le(),1),pt(),C(),We(),w(),I(),Ye(),dt(),M(),v(),At(),U=qe()}));function cn(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 ln({title:e,subtitle:t,configSchema:n,initialValues:r,onSave:i,onCancel:o}){let s=Object.keys(n),c=(0,un.useCallback)(e=>{if(n[e]?.sensitive===!0)return``;let t=r?.[e];return t===void 0?``:String(t)},[n,r]),[l,u]=(0,un.useState)(0),[d,f]=(0,un.useState)({}),[p,m]=(0,un.useState)(()=>s[0]?c(s[0]):``),h=s[l],g=h?n[h]:null;if(Fe(`confirm:no`,o,{context:`Settings`}),R({"confirm:nextField":(0,un.useCallback)(()=>{if(l<s.length-1&&h){f(e=>({...e,[h]:p})),u(e=>e+1);let e=s[l+1];m(e?c(e):``)}},[l,s,h,p,c]),"confirm:yes":(0,un.useCallback)(()=>{if(!h)return;let e={...d,[h]:p};if(l===s.length-1)i(cn(s,e,n,r));else{f(e),u(e=>e+1);let t=s[l+1];m(t?c(t):``)}},[h,d,p,l,s,n,i,c,r])},{context:`Confirmation`}),Re((e,t)=>{if(t.backspace||t.delete){m(e=>e.slice(0,-1));return}e&&!t.ctrl&&!t.meta&&!t.tab&&!t.return&&m(t=>t+e)}),!g||!h)return null;let ee=g.sensitive===!0,_=g.required===!0,v=ee?`*`.repeat(Ne(p)):p;return(0,dn.jsxs)(Ke,{title:e,subtitle:t,onCancel:o,isCancelActive:!1,children:[(0,dn.jsxs)(z,{flexDirection:`column`,children:[(0,dn.jsxs)(B,{bold:!0,children:[g.title||h,_&&(0,dn.jsx)(B,{color:`error`,children:` *`})]}),g.description&&(0,dn.jsx)(B,{dimColor:!0,children:g.description}),(0,dn.jsxs)(z,{marginTop:1,children:[(0,dn.jsxs)(B,{children:[a.pointerSmall,` `]}),(0,dn.jsx)(B,{children:v}),(0,dn.jsx)(B,{children:`█`})]})]}),(0,dn.jsxs)(z,{flexDirection:`column`,children:[(0,dn.jsxs)(B,{dimColor:!0,children:[`Field `,l+1,` of `,s.length]}),l<s.length-1&&(0,dn.jsx)(B,{dimColor:!0,children:`Tab: Next field · Enter: Save and continue`}),l===s.length-1&&(0,dn.jsx)(B,{dimColor:!0,children:`Enter: Save configuration`})]})]})}var un,dn,fn=e((()=>{i(),un=t(Le(),1),We(),me(),r(),dn=qe()}));async function pn(e){let{enabled:t,disabled:n}=await ye();return[...t,...n].find(t=>t.repository===e||t.source===e)}function mn({plugin:e,pluginId:t,onDone:n}){let[r]=hn.useState(()=>{let n=[],r=k(e);Object.keys(r).length>0&&n.push({key:`top-level`,title:`Configure ${e.name}`,subtitle:`Plugin options`,schema:r,load:()=>ie(t),save:n=>c(t,n,e.manifest.userConfig)});let i=y(e);for(let r of i)n.push({key:`channel:${r.server}`,title:`Configure ${r.displayName}`,subtitle:`Plugin: ${e.name}`,schema:r.configSchema,load:()=>L(t,r.server)??void 0,save:e=>ge(t,r.server,e,r.configSchema)});return n}),[i,a]=hn.useState(0),o=hn.useRef(n);if(o.current=n,hn.useEffect(()=>{r.length===0&&o.current(`skipped`)},[r.length]),r.length===0)return null;let s=r[i];function l(e){try{s.save(e)}catch(e){n(`error`,Je(e));return}let t=i+1;t<r.length?a(t):n(`configured`)}return(0,gn.jsx)(ln,{title:s.title,subtitle:s.subtitle,configSchema:s.schema,initialValues:s.load(),onSave:l,onCancel:()=>n(`skipped`)},s.key)}var hn,gn,_n=e((()=>{hn=t(Le(),1),Ye(),P(),Ce(),de(),ce(),fn(),gn=qe()}));function vn(){let e=s();return(0,yn.jsxs)(z,{marginBottom:1,children:[(0,yn.jsxs)(B,{color:`claude`,children:[a.warning,` `]}),(0,yn.jsxs)(B,{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 yn,bn=e((()=>{i(),We(),F(),yn=qe()}));function xn(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 Sn(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 Cn({hasSelection:e}){return(0,wn.jsx)(z,{marginTop:1,children:(0,wn.jsx)(B,{dimColor:!0,italic:!0,children:(0,wn.jsxs)(V,{children:[e&&(0,wn.jsx)(m,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,wn.jsx)(m,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,wn.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,wn.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}var wn,Tn=e((()=>{C(),We(),wn=qe()}));function En({totalItems:e,maxVisible:t=On,selectedIndex:n=0}){let r=e>t,i=(0,Dn.useRef)(0),a=(0,Dn.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,Dn.useCallback)(e=>r?e.slice(o,s):e,[r,o,s]),l=(0,Dn.useCallback)(e=>o+e,[o]),u=(0,Dn.useCallback)(e=>e>=o&&e<s,[o,s]),d=(0,Dn.useCallback)(e=>{},[]),f=(0,Dn.useCallback)(()=>{},[]),p=(0,Dn.useCallback)(()=>{},[]),m=(0,Dn.useCallback)((t,n)=>{n(Math.max(0,Math.min(t,e-1)))},[e]),h=(0,Dn.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 Dn,On,kn=e((()=>{Dn=t(Le(),1),On=5}));function An({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,targetMarketplace:s,targetPlugin:c}){let[l,u]=(0,W.useState)(`marketplace-list`),[d,f]=(0,W.useState)(null),[p,h]=(0,W.useState)(null),[g,ee]=(0,W.useState)([]),[_,v]=(0,W.useState)([]),[y,x]=(0,W.useState)(!0),[ne,C]=(0,W.useState)(null),[w,ie]=(0,W.useState)(0),[E,D]=(0,W.useState)(new Set),[O,k]=(0,W.useState)(new Set),oe=En({totalItems:_.length,selectedIndex:w}),[A,ce]=(0,W.useState)(0),[j,M]=(0,W.useState)(!1),[le,ue]=(0,W.useState)(null),[N,de]=(0,W.useState)(null);Fe(`confirm:no`,jn.useCallback(()=>{l===`plugin-list`?s?i({type:`manage-marketplaces`,targetMarketplace:s}):g.length===1?i({type:`menu`}):(u(`marketplace-list`),f(null),D(new Set)):l===`plugin-details`?(u(`plugin-list`),h(null)):i({type:`menu`})},[l,s,i,g.length]),{context:`Confirmation`}),(0,W.useEffect)(()=>{async function e(){try{let e=await b(),{marketplaces:n,failures:r}=await xe(e),i=[];for(let{name:e,config:t,data:r}of n)if(r){let n=tt(r.plugins,t=>T(te(t.name,e)));i.push({name:e,totalPlugins:r.plugins.length,installedCount:n,source:re(t.source)})}i.sort((e,t)=>e.name===`claude-plugin-directory`?-1:+(t.name===`claude-plugin-directory`)),ee(i);let a=se(r,tt(n,e=>e.data!==null));if(a)if(a.type===`warning`)de(`${a.message}. Showing available marketplaces.`);else throw Error(a.message);if(i.length===1&&!s&&!c){let e=i[0];e&&(f(e.name),u(`plugin-list`))}if(c){let n=null,r=null;for(let[t]of Object.entries(e)){let e=await S(t);if(e){let i=e.plugins.find(e=>e.name===c);if(i){let e=te(i.name,t);n={entry:i,marketplaceName:t,pluginId:e,isInstalled:De(e)},r=t;break}}}if(n&&r){let e=n.pluginId;De(e)?t(`Plugin '${e}' is already installed globally. Use '/plugin' to manage existing plugins.`):(f(r),h(n),u(`plugin-details`))}else t(`Plugin "${c}" not found in any marketplace`)}else s&&(i.some(e=>e.name===s)?(f(s),u(`plugin-list`)):t(`Marketplace "${s}" not found`))}catch(e){t(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{x(!1)}}e()},[t,s,c]),(0,W.useEffect)(()=>{if(!d)return;let e=!1;async function n(n){x(!0);try{let t=await S(n);if(e)return;if(!t)throw Error(`Failed to load marketplace: ${n}`);let r=[];for(let e of t.plugins){let t=te(e.name,n);fe(t)||r.push({entry:e,marketplaceName:n,pluginId:t,isInstalled:De(t)})}try{let t=await Nt();if(e)return;C(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;Qe(`Failed to fetch install counts: ${Je(t)}`),r.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}v(r),ie(0),D(new Set)}catch(n){if(e)return;t(n instanceof Error?n.message:`Failed to load plugins`)}finally{x(!1)}}return n(d),()=>{e=!0}},[d,t]);let P=async()=>{if(E.size===0)return;let e=_.filter(e=>E.has(e.pluginId));k(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await he({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}k(new Set),D(new Set),_e(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ae(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ae(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},F=async(e,t=`user`)=>{M(!0),ue(null);let n=await he({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){M(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else M(!1),ue(n.error)};(0,W.useEffect)(()=>{e&&r(e)},[e,r]),R({"select:previous":()=>{w>0&&ie(w-1)},"select:next":()=>{w<g.length-1&&ie(w+1)},"select:accept":()=>{let e=g[w];e&&(f(e.name),u(`plugin-list`))}},{context:`Select`,isActive:l===`marketplace-list`}),R({"select:previous":()=>{w>0&&oe.handleSelectionChange(w-1,ie)},"select:next":()=>{w<_.length-1&&oe.handleSelectionChange(w+1,ie)},"select:accept":()=>{if(w===_.length&&E.size>0)P();else if(w<_.length){let e=_[w];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(h(e),u(`plugin-details`),ce(0),ue(null)))}}},{context:`Select`,isActive:l===`plugin-list`}),R({"plugin:toggle":()=>{if(w<_.length){let e=_[w];if(e&&!e.isInstalled){let t=new Set(E);t.has(e.pluginId)?t.delete(e.pluginId):t.add(e.pluginId),D(t)}}},"plugin:install":()=>{E.size>0&&P()}},{context:`Plugin`,isActive:l===`plugin-list`});let pe=jn.useMemo(()=>{if(!p)return[];let e=p.entry.homepage;return Sn(e,xn(p))},[p]);if(R({"select:previous":()=>{A>0&&ce(A-1)},"select:next":()=>{A<pe.length-1&&ce(A+1)},"select:accept":()=>{if(!p)return;let e=pe[A]?.action,t=p.entry.homepage,n=xn(p);e===`install-user`?F(p,`user`):e===`install-project`?F(p,`project`):e===`install-local`?F(p,`local`):e===`homepage`&&t?Se(t):e===`github`&&n?Se(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),h(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!p}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,G.jsx)(mn,{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(y)return(0,G.jsx)(B,{children:`Loading…`});if(e)return(0,G.jsx)(B,{color:`error`,children:e});if(l===`marketplace-list`)return g.length===0?(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Select marketplace`})}),(0,G.jsx)(B,{children:`No marketplaces configured.`}),(0,G.jsxs)(B,{dimColor:!0,children:[`Add a marketplace first using `,`'Add marketplace'`,`.`]}),(0,G.jsx)(z,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(B,{dimColor:!0,children:(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]}):(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Select marketplace`})}),N&&(0,G.jsx)(z,{marginBottom:1,flexDirection:`column`,children:(0,G.jsxs)(B,{color:`warning`,children:[a.warning,` `,N]})}),g.map((e,t)=>(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:+(t<g.length-1),children:[(0,G.jsx)(z,{children:(0,G.jsxs)(B,{color:w===t?`suggestion`:void 0,children:[w===t?a.pointer:` `,` `,e.name]})}),(0,G.jsx)(z,{marginLeft:2,children:(0,G.jsxs)(B,{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)(z,{marginTop:1,children:(0,G.jsx)(B,{dimColor:!0,italic:!0,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(l===`plugin-details`&&p){let e=p.entry.homepage,t=Sn(e,xn(p));return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Plugin Details`})}),(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(B,{bold:!0,children:p.entry.name}),p.entry.version&&(0,G.jsxs)(B,{dimColor:!0,children:[`Version: `,p.entry.version]}),p.entry.description&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsx)(B,{children:p.entry.description})}),p.entry.author&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsxs)(B,{dimColor:!0,children:[`By:`,` `,typeof p.entry.author==`string`?p.entry.author:p.entry.author.name]})})]}),(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(B,{bold:!0,children:`Will install:`}),p.entry.commands&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Commands:`,` `,Array.isArray(p.entry.commands)?p.entry.commands.join(`, `):Object.keys(p.entry.commands).join(`, `)]}),p.entry.agents&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Agents:`,` `,Array.isArray(p.entry.agents)?p.entry.agents.join(`, `):Object.keys(p.entry.agents).join(`, `)]}),p.entry.hooks&&(0,G.jsxs)(B,{dimColor:!0,children:[`· Hooks: `,Object.keys(p.entry.hooks).join(`, `)]}),p.entry.mcpServers&&(0,G.jsxs)(B,{dimColor:!0,children:[`· MCP Servers:`,` `,Array.isArray(p.entry.mcpServers)?p.entry.mcpServers.join(`, `):typeof p.entry.mcpServers==`object`?Object.keys(p.entry.mcpServers).join(`, `):`configured`]}),!p.entry.commands&&!p.entry.agents&&!p.entry.hooks&&!p.entry.mcpServers&&(typeof p.entry.source==`object`&&`source`in p.entry.source&&(p.entry.source.source===`github`||p.entry.source.source===`url`||p.entry.source.source===`npm`||p.entry.source.source===`pip`)?(0,G.jsx)(B,{dimColor:!0,children:`· Component summary not available for remote plugin`}):(0,G.jsx)(B,{dimColor:!0,children:`· Components will be discovered at installation`}))]}),(0,G.jsx)(vn,{}),le&&(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsxs)(B,{color:`error`,children:[`Error: `,le]})}),(0,G.jsx)(z,{flexDirection:`column`,children:t.map((e,t)=>(0,G.jsxs)(z,{children:[A===t&&(0,G.jsx)(B,{children:`> `}),A!==t&&(0,G.jsx)(B,{children:` `}),(0,G.jsx)(B,{bold:A===t,children:j&&e.action===`install`?`Installing…`:e.label})]},e.action))}),(0,G.jsx)(z,{marginTop:1,paddingLeft:1,children:(0,G.jsx)(B,{dimColor:!0,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(_.length===0)return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Install plugins`})}),(0,G.jsx)(B,{dimColor:!0,children:`No new plugins available to install.`}),(0,G.jsx)(B,{dimColor:!0,children:`All plugins from this marketplace are already installed.`}),(0,G.jsx)(z,{marginLeft:3,children:(0,G.jsx)(B,{dimColor:!0,italic:!0,children:(0,G.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})})})]});let me=oe.getVisibleItems(_);return(0,G.jsxs)(z,{flexDirection:`column`,children:[(0,G.jsx)(z,{marginBottom:1,children:(0,G.jsx)(B,{bold:!0,children:`Install Plugins`})}),oe.scrollPosition.canScrollUp&&(0,G.jsx)(z,{children:(0,G.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),me.map((t,n)=>{let r=oe.toActualIndex(n),i=w===r,o=E.has(t.pluginId),s=O.has(t.pluginId);return(0,G.jsxs)(z,{flexDirection:`column`,marginBottom:n===me.length-1&&!e?0:1,children:[(0,G.jsxs)(z,{children:[(0,G.jsxs)(B,{color:i?`suggestion`:void 0,children:[i?a.pointer:` `,` `]}),(0,G.jsxs)(B,{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)(B,{dimColor:!0,children:[` [`,t.entry.category,`]`]}),t.entry.tags?.includes(`community-managed`)&&(0,G.jsx)(B,{dimColor:!0,children:` [Community Managed]`}),t.isInstalled&&(0,G.jsx)(B,{dimColor:!0,children:` (installed)`}),ne&&d===`claude-plugins-official`&&(0,G.jsxs)(B,{dimColor:!0,children:[` · `,Mt(ne.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,G.jsxs)(z,{marginLeft:4,children:[(0,G.jsx)(B,{dimColor:!0,children:ht(t.entry.description,60)}),t.entry.version&&(0,G.jsxs)(B,{dimColor:!0,children:[` · v`,t.entry.version]})]})]},t.pluginId)}),oe.scrollPosition.canScrollDown&&(0,G.jsx)(z,{children:(0,G.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,G.jsx)(z,{marginTop:1,children:(0,G.jsxs)(B,{color:`error`,children:[a.cross,` `,e]})}),(0,G.jsx)(Cn,{hasSelection:E.size>0})]})}var jn,W,G,Mn=e((()=>{i(),jn=t(Le(),1),W=t(Le(),1),C(),We(),me(),nt(),j(),$e(),Ye(),M(),kt(),ke(),F(),v(),ve(),be(),Ee(),_t(),gt(),_n(),bn(),Tn(),kn(),G=qe()}));function Nn({error:e,setError:t,result:n,setResult:r,setViewState:i,onInstallComplete:o,onSearchModeChange:s,targetPlugin:c}){let[l,u]=(0,K.useState)(`plugin-list`),[d,f]=(0,K.useState)(null),[p,h]=(0,K.useState)([]),[g,ee]=(0,K.useState)(!0),[_,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(!1),S=(0,K.useCallback)(e=>{x(e),s?.(e)},[s]),{query:ne,setQuery:C,cursorOffset:w}=Wt({isActive:l===`plugin-list`&&y&&!g,onExit:()=>{S(!1)}}),re=Ie(),{columns:ie}=He(),T=(0,K.useMemo)(()=>{if(!ne)return p;let e=ne.toLowerCase();return p.filter(t=>t.entry.name.toLowerCase().includes(e)||t.entry.description?.toLowerCase().includes(e)||t.marketplaceName.toLowerCase().includes(e))},[p,ne]),[E,D]=(0,K.useState)(0),[O,k]=(0,K.useState)(new Set),[A,ce]=(0,K.useState)(new Set),j=En({totalItems:T.length,selectedIndex:E});(0,K.useEffect)(()=>{D(0)},[ne]);let[M,le]=(0,K.useState)(0),[ue,N]=(0,K.useState)(!1),[de,P]=(0,K.useState)(null),[F,pe]=(0,K.useState)(null),[me,ge]=(0,K.useState)(null);(0,K.useEffect)(()=>{async function e(){try{let e=await b(),{marketplaces:n,failures:r}=await xe(e),i=[];for(let{name:e,data:t}of n)if(t)for(let n of t.plugins){let t=te(n.name,e);i.push({entry:n,marketplaceName:e,pluginId:t,isInstalled:De(t)})}let a=i.filter(e=>!e.isInstalled&&!fe(e.pluginId));try{let e=await Nt();v(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){Qe(`Failed to fetch install counts: ${Je(e)}`),a.sort((e,t)=>e.entry.name.localeCompare(t.entry.name))}h(a);let o=Object.keys(e).length;if(a.length===0){let e=await oe({configuredMarketplaceCount:o,failedMarketplaceCount:r.length});ge(e)}let s=se(r,tt(n,e=>e.data!==null));if(s)if(s.type===`warning`)pe(`${s.message}. Showing available plugins.`);else throw Error(s.message);if(c){let e=i.find(e=>e.entry.name===c);e?e.isInstalled?t(`Plugin '${e.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`):(f(e),u(`plugin-details`)):t(`Plugin "${c}" not found in any marketplace`)}}catch(e){t(e instanceof Error?e.message:`Failed to load plugins`)}finally{ee(!1)}}e()},[t,c]);let ve=async()=>{if(O.size===0)return;let e=p.filter(e=>O.has(e.pluginId));ce(new Set(e.map(e=>e.pluginId)));let n=0,a=0,s=[];for(let t of e){let e=await he({pluginId:t.pluginId,entry:t.entry,marketplaceName:t.marketplaceName,scope:`user`});e.success?n++:(a++,s.push({name:t.entry.name,reason:e.error}))}ce(new Set),k(new Set),_e(),a===0?r(`✓ Installed ${n} ${H(n,`plugin`)}. Run /reload-plugins to activate.`):n===0?t(`Failed to install: ${ae(s,!0)}`):r(`✓ Installed ${n} of ${n+a} plugins. Failed: ${ae(s,!1)}. Run /reload-plugins to activate successfully installed plugins.`),n>0&&o&&await o(),i({type:`menu`})},I=async(e,t=`user`)=>{N(!0),P(null);let n=await he({pluginId:e.pluginId,entry:e.entry,marketplaceName:e.marketplaceName,scope:t});if(n.success){let t=await pn(e.pluginId);if(t){N(!1),u({type:`plugin-options`,plugin:t,pluginId:e.pluginId});return}r(n.message),o&&await o(),i({type:`menu`})}else N(!1),P(n.error)};(0,K.useEffect)(()=>{e&&r(e)},[e,r]),Fe(`confirm:no`,()=>{u(`plugin-list`),f(null)},{context:`Confirmation`,isActive:l===`plugin-details`}),Fe(`confirm:no`,()=>{i({type:`menu`})},{context:`Confirmation`,isActive:l===`plugin-list`&&!y}),Re((e,t)=>{let n=!t.ctrl&&!t.meta;y||(e===`/`&&n?(S(!0),C(``)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==`i`&&(S(!0),C(e)))},{isActive:l===`plugin-list`&&!g}),R({"select:previous":()=>{E===0?S(!0):j.handleSelectionChange(E-1,D)},"select:next":()=>{E<T.length-1&&j.handleSelectionChange(E+1,D)},"select:accept":()=>{if(E===T.length&&O.size>0)ve();else if(E<T.length){let e=T[E];e&&(e.isInstalled?i({type:`manage-plugins`,targetPlugin:e.entry.name,targetMarketplace:e.marketplaceName}):(f(e),u(`plugin-details`),le(0),P(null)))}}},{context:`Select`,isActive:l===`plugin-list`&&!y}),R({"plugin:toggle":()=>{if(E<T.length){let e=T[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&&ve()}},{context:`Plugin`,isActive:l===`plugin-list`&&!y});let ye=In.useMemo(()=>{if(!d)return[];let e=d.entry.homepage;return Sn(e,xn(d))},[d]);if(R({"select:previous":()=>{M>0&&le(M-1)},"select:next":()=>{M<ye.length-1&&le(M+1)},"select:accept":()=>{if(!d)return;let e=ye[M]?.action,t=d.entry.homepage,n=xn(d);e===`install-user`?I(d,`user`):e===`install-project`?I(d,`project`):e===`install-local`?I(d,`local`):e===`homepage`&&t?Se(t):e===`github`&&n?Se(`https://github.com/${n}`):e===`back`&&(u(`plugin-list`),f(null))}},{context:`Select`,isActive:l===`plugin-details`&&!!d}),typeof l==`object`&&l.type===`plugin-options`){let{plugin:e,pluginId:t}=l;function n(e){r(e),o&&o(),i({type:`menu`})}return(0,q.jsx)(mn,{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(g)return(0,q.jsx)(B,{children:`Loading…`});if(e)return(0,q.jsx)(B,{color:`error`,children:e});if(l===`plugin-details`&&d){let e=d.entry.homepage,t=Sn(e,xn(d));return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(B,{bold:!0,children:`Plugin details`})}),(0,q.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(B,{bold:!0,children:d.entry.name}),(0,q.jsxs)(B,{dimColor:!0,children:[`from `,d.marketplaceName]}),d.entry.version&&(0,q.jsxs)(B,{dimColor:!0,children:[`Version: `,d.entry.version]}),d.entry.description&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{children:d.entry.description})}),d.entry.author&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsxs)(B,{dimColor:!0,children:[`By:`,` `,typeof d.entry.author==`string`?d.entry.author:d.entry.author.name]})})]}),(0,q.jsx)(vn,{}),de&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{color:`error`,children:[`Error: `,de]})}),(0,q.jsx)(z,{flexDirection:`column`,children:t.map((e,t)=>(0,q.jsxs)(z,{children:[M===t&&(0,q.jsx)(B,{children:`> `}),M!==t&&(0,q.jsx)(B,{children:` `}),(0,q.jsx)(B,{bold:M===t,children:ue&&e.action.startsWith(`install-`)?`Installing…`:e.label})]},e.action))}),(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,children:(0,q.jsxs)(V,{children:[(0,q.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,q.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(p.length===0)return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(B,{bold:!0,children:`Discover plugins`})}),(0,q.jsx)(Fn,{reason:me}),(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,italic:!0,children:`Esc to go back`})})]});let be=j.getVisibleItems(T);return(0,q.jsxs)(z,{flexDirection:`column`,children:[(0,q.jsxs)(z,{children:[(0,q.jsx)(B,{bold:!0,children:`Discover plugins`}),j.needsPagination&&(0,q.jsxs)(B,{dimColor:!0,children:[` `,`(`,j.scrollPosition.current,`/`,j.scrollPosition.total,`)`]})]}),(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsx)(Be,{query:ne,isFocused:y,isTerminalFocused:re,width:ie-4,cursorOffset:w})}),F&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{color:`warning`,children:[a.warning,` `,F]})}),T.length===0&&ne&&(0,q.jsx)(z,{marginBottom:1,children:(0,q.jsxs)(B,{dimColor:!0,children:[`No plugins match "`,ne,`"`]})}),j.scrollPosition.canScrollUp&&(0,q.jsx)(z,{children:(0,q.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),be.map((t,n)=>{let r=j.toActualIndex(n),i=E===r,o=O.has(t.pluginId),s=A.has(t.pluginId);return(0,q.jsxs)(z,{flexDirection:`column`,marginBottom:n===be.length-1&&!e?0:1,children:[(0,q.jsxs)(z,{children:[(0,q.jsxs)(B,{color:i&&!y?`suggestion`:void 0,children:[i&&!y?a.pointer:` `,` `]}),(0,q.jsxs)(B,{children:[s?a.ellipsis:o?a.radioOn:a.radioOff,` `,t.entry.name,(0,q.jsxs)(B,{dimColor:!0,children:[` · `,t.marketplaceName]}),t.entry.tags?.includes(`community-managed`)&&(0,q.jsx)(B,{dimColor:!0,children:` [Community Managed]`}),_&&t.marketplaceName===`claude-plugins-official`&&(0,q.jsxs)(B,{dimColor:!0,children:[` · `,Mt(_.get(t.pluginId)??0),` installs`]})]})]}),t.entry.description&&(0,q.jsx)(z,{marginLeft:4,children:(0,q.jsx)(B,{dimColor:!0,children:ht(t.entry.description,60)})})]},`${j.startIndex}-${t.pluginId}`)}),j.scrollPosition.canScrollDown&&(0,q.jsx)(z,{children:(0,q.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),e&&(0,q.jsx)(z,{marginTop:1,children:(0,q.jsxs)(B,{color:`error`,children:[a.cross,` `,e]})}),(0,q.jsx)(Pn,{hasSelection:O.size>0,canToggle:E<T.length&&!T[E]?.isInstalled})]})}function Pn({hasSelection:e,canToggle:t}){return(0,q.jsx)(z,{marginTop:1,children:(0,q.jsx)(B,{dimColor:!0,italic:!0,children:(0,q.jsxs)(V,{children:[e&&(0,q.jsx)(m,{action:`plugin:install`,context:`Plugin`,fallback:`i`,description:`install`,bold:!0}),(0,q.jsx)(B,{children:`type to search`}),t&&(0,q.jsx)(m,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,q.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,q.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})}function Fn({reason:e}){switch(e){case`git-not-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`Git is required to install marketplaces.`}),(0,q.jsx)(B,{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)(B,{dimColor:!0,children:`Your organization policy does not allow any external marketplaces.`}),(0,q.jsx)(B,{dimColor:!0,children:`Contact your administrator.`})]});case`policy-restricts-sources`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`Your organization restricts which marketplaces can be added.`}),(0,q.jsx)(B,{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)(B,{dimColor:!0,children:`Failed to load marketplace data.`}),(0,q.jsx)(B,{dimColor:!0,children:`Check your network connection.`})]});case`all-plugins-installed`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`All available plugins are already installed.`}),(0,q.jsx)(B,{dimColor:!0,children:`Check for new plugins later or add more marketplaces.`})]});default:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(B,{dimColor:!0,children:`No plugins available.`}),(0,q.jsx)(B,{dimColor:!0,children:`Add a marketplace first using the Marketplaces tab.`})]})}}var In,K,q,Ln=e((()=>{i(),In=t(Le(),1),K=t(Le(),1),C(),Ut(),We(),Gt(),Oe(),me(),nt(),j(),$e(),Ye(),M(),kt(),ke(),F(),v(),ve(),be(),Ee(),_t(),gt(),_n(),bn(),Tn(),kn(),q=qe()}));function Rn({setViewState:e,error:t,setError:n,setResult:r,exitState:i,onManageComplete:o,targetMarketplace:s,action:c}){let[l,d]=(0,Bn.useState)([]),[f,p]=(0,Bn.useState)(!0),[h,_]=(0,Bn.useState)(0),[v,y]=(0,Bn.useState)(!1),[x,S]=(0,Bn.useState)(null),[ne,C]=(0,Bn.useState)(null),[w,ie]=(0,Bn.useState)(null),[T,E]=(0,Bn.useState)(`list`),[D,O]=(0,Bn.useState)(null),[ae,k]=(0,Bn.useState)(0),oe=(0,Bn.useRef)(!1);(0,Bn.useEffect)(()=>{async function e(){try{let e=await b(),{enabled:r,disabled:i}=await ye(),a=[...r,...i],{marketplaces:o,failures:l}=await xe(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:re(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}u.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(u);let f=se(l,tt(o,e=>e.data!==null));if(f)if(f.type===`warning`)S(f.message);else throw Error(f.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(c){_(e+1);let t=[...u];c===`update`?t[e].pendingUpdate=!0:c===`remove`&&(t[e].pendingRemove=!0),d(t),setTimeout(j,100,t)}else t&&(_(e+1),O(t),E(`details`))}else n&&n(`Marketplace not found: ${s}`)}}catch(e){n&&n(e instanceof Error?e.message:`Failed to load marketplaces`),S(e instanceof Error?e.message:`Failed to load marketplaces`)}finally{p(!1)}}e()},[s,c,t]);let A=()=>l.some(e=>e.pendingUpdate||e.pendingRemove),ce=()=>({updateCount:tt(l,e=>e.pendingUpdate),removeCount:tt(l,e=>e.pendingRemove)}),j=async t=>{let i=t||l,s=T===`details`;y(!0),S(null),C(null),ie(null);try{let t=rt(`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=te(t.name,e.name);n[r]=!1}st(`userSettings`,{enabledPlugins:n})}await ee(e.name),c++,mt(`tengu_marketplace_removed`,{marketplace_name:e.name,plugins_uninstalled:e.installedPlugins?.length||0});continue}e.pendingUpdate&&(await u(e.name,e=>{ie(e)}),n++,l.add(e.name.toLowerCase()),mt(`tengu_marketplace_updated`,{marketplace_name:e.name}))}let f=0;l.size>0&&(f=(await en(l)).length),_e(),o&&await o();let p=await b(),{enabled:m,disabled:h}=await ye(),g=[...m,...h],{marketplaces:_}=await xe(p),v=[];for(let{name:e,config:t,data:n}of _){let r=g.filter(t=>t.source.endsWith(`@${e}`));v.push({name:e,source:re(t.source),lastUpdated:t.lastUpdated,pluginCount:n?.plugins.length,installedPlugins:r,pendingUpdate:!1,pendingRemove:!1,autoUpdate:ct(e,t)})}if(v.sort((e,t)=>e.name===`claude-plugin-directory`?-1:t.name===`claude-plugin-directory`?1:e.name.localeCompare(t.name)),d(v),s&&D){let e=v.find(e=>e.name===D.name);e&&O(e)}let y=[];if(n>0){let e=f>0?` (${f} ${H(f,`plugin`)} bumped)`:``;y.push(`Updated ${n} ${H(n,`marketplace`)}${e}`)}if(c>0&&y.push(`Removed ${c} ${H(c,`marketplace`)}`),y.length>0){let t=`${a.tick} ${y.join(`, `)}`;s?C(t):(r(t),setTimeout(e,2e3,{type:`menu`}))}else s||e({type:`menu`})}catch(e){let t=Je(e);S(t),n&&n(t)}finally{y(!1),ie(null)}},M=async()=>{if(!D)return;let e=l.map(e=>e.name===D.name?{...e,pendingRemove:!0}:e);d(e),await j(e)},le=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 lt()||t.push({label:e.autoUpdate?`Disable auto-update`:`Enable auto-update`,value:`toggle-auto-update`}),t.push({label:`Remove marketplace`,value:`remove`}),t},ue=async e=>{let t=!e.autoUpdate;try{await g(e.name,t),d(n=>n.map(n=>n.name===e.name?{...n,autoUpdate:t}:n)),O(e=>e&&{...e,autoUpdate:t})}catch(e){S(e instanceof Error?e.message:`Failed to update setting`)}};if(Fe(`confirm:no`,()=>{E(`list`),k(0)},{context:`Confirmation`,isActive:!v&&(T===`details`||T===`confirm-remove`)}),Fe(`confirm:no`,()=>{d(e=>e.map(e=>({...e,pendingUpdate:!1,pendingRemove:!1}))),_(0)},{context:`Confirmation`,isActive:!v&&T===`list`&&A()}),Fe(`confirm:no`,()=>{e({type:`menu`})},{context:`Confirmation`,isActive:!v&&T===`list`&&!A()}),R({"select:previous":()=>_(e=>Math.max(0,e-1)),"select:next":()=>{let e=l.length+1;_(t=>Math.min(e-1,t+1))},"select:accept":()=>{let t=h-1;if(h===0)e({type:`add-marketplace`});else if(A())j();else{let e=l[t];e&&(O(e),E(`details`),k(0))}}},{context:`Select`,isActive:!v&&T===`list`}),Re(e=>{let t=h-1;if((e===`u`||e===`U`)&&t>=0)d(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=l[t];e&&(O(e),E(`confirm-remove`))}},{isActive:!v&&T===`list`}),R({"select:previous":()=>k(e=>Math.max(0,e-1)),"select:next":()=>{let e=le(D);k(t=>Math.min(e.length-1,t+1))},"select:accept":()=>{if(!D)return;let t=le(D)[ae];if(t?.value===`browse`)e({type:`browse-marketplace`,targetMarketplace:D.name});else if(t?.value===`update`){let e=l.map(e=>e.name===D.name?{...e,pendingUpdate:!0}:e);d(e),j(e)}else t?.value===`toggle-auto-update`?ue(D):t?.value===`remove`&&E(`confirm-remove`)}},{context:`Select`,isActive:!v&&T===`details`}),Re(e=>{e===`y`||e===`Y`?M():(e===`n`||e===`N`)&&(E(`list`),O(null))},{isActive:!v&&T===`confirm-remove`}),f)return(0,J.jsx)(B,{children:`Loading marketplaces…`});if(l.length===0)return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(z,{marginBottom:1,children:(0,J.jsx)(B,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(B,{color:`suggestion`,children:[a.pointer,` +`]}),(0,J.jsx)(B,{bold:!0,color:`suggestion`,children:`Add Marketplace`})]}),(0,J.jsx)(z,{marginLeft:3,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:i.pending?(0,J.jsxs)(J.Fragment,{children:[`Press `,i.keyName,` again to go back`]}):(0,J.jsxs)(V,{children:[(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]});if(T===`confirm-remove`&&D){let e=D.installedPlugins?.length||0;return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsxs)(B,{bold:!0,color:`warning`,children:[`Remove marketplace `,(0,J.jsx)(B,{italic:!0,children:D.name}),`?`]}),(0,J.jsxs)(z,{flexDirection:`column`,children:[e>0&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{color:`warning`,children:[`This will also uninstall `,e,` `,H(e,`plugin`),` from this marketplace:`]})}),D.installedPlugins&&D.installedPlugins.length>0&&(0,J.jsx)(z,{flexDirection:`column`,marginTop:1,marginLeft:2,children:D.installedPlugins.map(e=>(0,J.jsxs)(B,{dimColor:!0,children:[`• `,e.name]},e.name))}),(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{children:[`Press `,(0,J.jsx)(B,{bold:!0,children:`y`}),` to confirm or `,(0,J.jsx)(B,{bold:!0,children:`n`}),` to cancel`]})})]})]})}if(T===`details`&&D){let e=D.pendingUpdate||v,t=le(D);return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(B,{bold:!0,children:D.name}),(0,J.jsx)(B,{dimColor:!0,children:D.source}),(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{children:[D.pluginCount||0,` available `,H(D.pluginCount||0,`plugin`)]})}),D.installedPlugins&&D.installedPlugins.length>0&&(0,J.jsxs)(z,{flexDirection:`column`,marginTop:1,children:[(0,J.jsxs)(B,{bold:!0,children:[`Installed plugins (`,D.installedPlugins.length,`):`]}),(0,J.jsx)(z,{flexDirection:`column`,marginLeft:1,children:D.installedPlugins.map(e=>(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(B,{children:a.bullet}),(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(B,{children:e.name}),(0,J.jsx)(B,{dimColor:!0,children:e.manifest.description})]})]},e.name))})]}),e&&(0,J.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,J.jsx)(B,{color:`claude`,children:`Updating marketplace…`}),w&&(0,J.jsx)(B,{dimColor:!0,children:w})]}),!e&&ne&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`claude`,children:ne})}),!e&&x&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`error`,children:x})}),!e&&(0,J.jsx)(z,{flexDirection:`column`,marginTop:1,children:t.map((e,t)=>{if(!e)return null;let n=t===ae;return(0,J.jsxs)(z,{children:[(0,J.jsxs)(B,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.label]}),e.secondaryLabel&&(0,J.jsxs)(B,{dimColor:!0,children:[` `,e.secondaryLabel]})]},e.value)})}),!e&&!lt()&&D.autoUpdate&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{dimColor:!0,children:`Auto-update enabled. Work Mate will automatically update this marketplace and its installed plugins.`})}),(0,J.jsx)(z,{marginLeft:3,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:e?(0,J.jsx)(J.Fragment,{children:`Please wait…`}):(0,J.jsxs)(V,{children:[(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})})]})}let{updateCount:N,removeCount:de}=ce();return(0,J.jsxs)(z,{flexDirection:`column`,children:[(0,J.jsx)(z,{marginBottom:1,children:(0,J.jsx)(B,{bold:!0,children:`Manage marketplaces`})}),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(B,{color:h===0?`suggestion`:void 0,children:[h===0?a.pointer:` `,` +`]}),(0,J.jsx)(B,{bold:!0,color:h===0?`suggestion`:void 0,children:`Add Marketplace`})]}),(0,J.jsx)(z,{flexDirection:`column`,children:l.map((e,t)=>{let n=t+1===h,r=[];return e.pendingUpdate&&r.push(`UPDATE`),e.pendingRemove&&r.push(`REMOVE`),(0,J.jsxs)(z,{flexDirection:`row`,gap:1,marginBottom:1,children:[(0,J.jsxs)(B,{color:n?`suggestion`:void 0,children:[n?a.pointer:` `,` `,e.pendingRemove?a.cross:a.bullet]}),(0,J.jsxs)(z,{flexDirection:`column`,flexGrow:1,children:[(0,J.jsxs)(z,{flexDirection:`row`,gap:1,children:[(0,J.jsxs)(B,{bold:!0,strikethrough:e.pendingRemove,dimColor:e.pendingRemove,children:[e.name===`claude-plugins-official`&&(0,J.jsx)(B,{color:`claude`,children:`✻ `}),e.name,e.name===`claude-plugins-official`&&(0,J.jsx)(B,{color:`claude`,children:` ✻`})]}),r.length>0&&(0,J.jsxs)(B,{color:`warning`,children:[`[`,r.join(`, `),`]`]})]}),(0,J.jsx)(B,{dimColor:!0,children:e.source}),(0,J.jsxs)(B,{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)})}),A()&&(0,J.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,J.jsxs)(B,{children:[(0,J.jsx)(B,{bold:!0,children:`Pending changes:`}),` `,(0,J.jsx)(B,{dimColor:!0,children:`Enter to apply`})]}),N>0&&(0,J.jsxs)(B,{children:[`• Update `,N,` `,H(N,`marketplace`)]}),de>0&&(0,J.jsxs)(B,{color:`warning`,children:[`• Remove `,de,` `,H(de,`marketplace`)]})]}),v&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`claude`,children:`Processing changes…`})}),x&&(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{color:`error`,children:x})}),(0,J.jsx)(zn,{exitState:i,hasPendingActions:A()})]})}function zn({exitState:e,hasPendingActions:t}){return e.pending?(0,J.jsx)(z,{marginTop:1,children:(0,J.jsxs)(B,{dimColor:!0,italic:!0,children:[`Press `,e.keyName,` again to go back`]})}):(0,J.jsx)(z,{marginTop:1,children:(0,J.jsx)(B,{dimColor:!0,italic:!0,children:(0,J.jsxs)(V,{children:[t&&(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`apply changes`}),!t&&(0,J.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),!t&&(0,J.jsx)(Me,{shortcut:`u`,action:`update`}),!t&&(0,J.jsx)(Me,{shortcut:`r`,action:`remove`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:t?`cancel`:`go back`})]})})})}var Bn,J,Vn=e((()=>{i(),Bn=t(Le(),1),pt(),C(),We(),me(),nt(),ut(),Ye(),M(),F(),v(),tn(),de(),ot(),at(),_t(),J=qe()}));function Hn(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 _(e)}function Un(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 Wn=e((()=>{E()}));function Gn({item:e,isSelected:t}){let[n]=Pe();if(e.type===`plugin`){let r,i;return e.pendingToggle?(r=ze(`suggestion`,n)(a.arrowRight),i=e.pendingToggle===`will-enable`?`will enable`:`will disable`):e.errorCount>0?(r=ze(`error`,n)(a.cross),i=`${e.errorCount} ${H(e.errorCount,`error`)}`):e.isEnabled?(r=ze(`success`,n)(a.tick),i=`enabled`):(r=ze(`inactive`,n)(a.radioOff),i=`disabled`),(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}if(e.type===`flagged-plugin`){let r=ze(`warning`,n)(a.warning);return(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:`removed`})]})}if(e.type===`failed-plugin`){let r=ze(`error`,n)(a.cross),i=`failed to load · ${e.errorCount} ${H(e.errorCount,`error`)}`;return(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`Plugin`})]}),(0,Y.jsxs)(B,{dimColor:!0,children:[` · `,e.marketplace]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}let r,i;return e.status===`connected`?(r=ze(`success`,n)(a.tick),i=`connected`):e.status===`disabled`?(r=ze(`inactive`,n)(a.radioOff),i=`disabled`):e.status===`pending`?(r=ze(`inactive`,n)(a.radioOff),i=`connecting…`):e.status===`needs-auth`?(r=ze(`warning`,n)(a.triangleUpOutline),i=`Enter to auth`):(r=ze(`error`,n)(a.cross),i=`failed`),e.indented?(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{dimColor:!t,children:`└ `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]}):(0,Y.jsxs)(z,{children:[(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:t?`${a.pointer} `:` `}),(0,Y.jsx)(B,{color:t?`suggestion`:void 0,children:e.name}),(0,Y.jsxs)(B,{dimColor:!t,children:[` `,(0,Y.jsx)(B,{backgroundColor:`userMessageBackground`,children:`MCP`})]}),(0,Y.jsxs)(B,{dimColor:!t,children:[` · `,r,` `]}),(0,Y.jsx)(B,{dimColor:!t,children:i})]})}var Y,Kn=e((()=>{i(),We(),_t(),Y=qe()}));async function qn(e){try{return(await rn.readdir(e,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(`.md`)).map(e=>nn.basename(e.name,`.md`))}catch(t){return Qe(`Failed to read plugin components from ${e}: ${Je(t)}`,{level:`error`}),ft(Ze(t)),[]}}async function Jn(e){try{let t=await rn.readdir(e,{withFileTypes:!0}),n=[];for(let r of t)if(r.isDirectory()||r.isSymbolicLink()){let t=nn.join(e,r.name,`SKILL.md`);try{(await rn.stat(t)).isFile()&&n.push(r.name)}catch{}}return n}catch(t){return Qe(`Failed to read skill directories from ${e}: ${Je(t)}`,{level:`error`}),ft(Ze(t)),[]}}function Yn({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=je(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 S(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 qn(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 qn(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 Jn(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)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(B,{bold:!0,children:`Components:`}),(0,Z.jsxs)(B,{dimColor:!0,children:[`Error: `,o]})]}):!n||!(n.commands||n.agents||n.skills||n.hooks||n.mcpServers)?null:(0,Z.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsx)(B,{bold:!0,children:`Installed components:`}),n.commands?(0,Z.jsxs)(B,{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)(B,{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)(B,{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)(B,{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)(B,{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 Xn(e,t){let n=(await S(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 Zn(e){return e.filter(e=>{let t=e.source.split(`@`)[1]||`local`;return!fe(`${e.name}@${t}`)})}function Qn({setViewState:e,setResult:t,onManageComplete:n,onSearchModeChange:r,targetPlugin:i,targetMarketplace:o,action:s}){let l=A(e=>e.mcp.clients),u=A(e=>e.mcp.tools),d=A(e=>e.plugins.errors),f=It(),[g,ee]=(0,X.useState)(!1),_=(0,X.useCallback)(e=>{ee(e),r?.(e)},[r]),v=Ie(),{columns:te}=He(),[y,b]=(0,X.useState)(`plugin-list`),{query:x,setQuery:S,cursorOffset:ne}=Wt({isActive:y===`plugin-list`&&g,onExit:()=>{_(!1)}}),[C,w]=(0,X.useState)(null),[re,T]=(0,X.useState)([]),[E,D]=(0,X.useState)([]),[O,ae]=(0,X.useState)(!0),[k,oe]=(0,X.useState)(new Map),se=(0,X.useRef)(!1),ce=(0,X.useRef)(void 0),j=zt();Fe(`confirm:no`,$n.useCallback(()=>{if(y===`plugin-details`)b(`plugin-list`),w(null),L(null);else if(typeof y==`object`&&y.type===`failed-plugin-details`)b(`plugin-list`),L(null);else if(y===`configuring`)b(`plugin-details`),Ce(null);else if(typeof y==`object`&&(y.type===`plugin-options`||y.type===`configuring-options`))b(`plugin-list`),w(null),t(`Plugin enabled. Configuration skipped — run /reload-plugins to apply.`),n&&n();else if(typeof y==`object`&&y.type===`flagged-detail`)b(`plugin-list`),L(null);else if(typeof y==`object`&&y.type===`mcp-detail`)b(`plugin-list`),L(null);else if(typeof y==`object`&&y.type===`mcp-tools`)b({type:`mcp-detail`,client:y.client});else if(typeof y==`object`&&y.type===`mcp-tool-detail`)b({type:`mcp-tools`,client:y.client});else{if(k.size>0){t(`Run /reload-plugins to apply plugin changes.`);return}e({type:`menu`})}},[y,e,k,t]),{context:`Confirmation`,isActive:(y!==`plugin-list`||!g)&&y!==`confirm-project-uninstall`&&!(typeof y==`object`&&y.type===`confirm-data-cleanup`)});let M=e=>e.type===`connected`?`connected`:e.type===`disabled`?`disabled`:e.type===`pending`?`pending`:e.type===`needs-auth`?`needs-auth`:`failed`,N=(0,X.useMemo)(()=>{let e=it(),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 E){let i=`${r.plugin.name}@${r.marketplace}`,a=e?.enabledPlugins?.[i]!==!1,o=d.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:k.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 d){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=yt(),s=[];for(let[e,t]of a){if(e in f)continue;let n=h(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:M(e),client:e}));let u={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},p=[],m=new Map;for(let{item:e,originalScope:t,childMcps:r}of n){let n=e.scope;m.has(n)||m.set(n,[]),m.get(n).push(e);for(let{displayName:e,client:n}of r){let r=t===`builtin`?`user`:t;m.has(r)||m.set(r,[]),m.get(r).push({type:`mcp`,id:`mcp:${n.name}`,name:e,description:void 0,scope:r,status:M(n),client:n,indented:!0})}}for(let e of c){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let e of s){let t=e.scope;m.has(t)||m.set(t,[]),m.get(t).push(e)}for(let[e,t]of Object.entries(f)){let n=h(e),r=n.name||e,i=n.marketplace||`unknown`;m.has(`flagged`)||m.set(`flagged`,[]),m.get(`flagged`).push({type:`flagged-plugin`,id:e,name:r,marketplace:i,scope:`flagged`,reason:`delisted`,text:`Removed from marketplace`,flaggedAt:t.flaggedAt})}let g=[...m.keys()].sort((e,t)=>(u[e]??99)-(u[t]??99));for(let e of g){let t=m.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)p.push(...e);p.push(...r)}return p},[E,l,d,k,f]),de=(0,X.useMemo)(()=>N.filter(e=>e.type===`flagged-plugin`).map(e=>e.id),[N]);(0,X.useEffect)(()=>{de.length>0&&Ft(de)},[de]);let fe=(0,X.useMemo)(()=>{if(!x)return N;let e=x.toLowerCase();return N.filter(t=>t.name.toLowerCase().includes(e)||`description`in t&&t.description?.toLowerCase().includes(e))},[N,x]),[P,F]=(0,X.useState)(0),me=En({totalItems:fe.length,selectedIndex:P,maxVisible:8}),[he,ge]=(0,X.useState)(0),[ve,I]=(0,X.useState)(!1),[be,L]=(0,X.useState)(null),[xe,Ce]=(0,X.useState)(null),[Ee,De]=(0,X.useState)(!1),[Oe,ke]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!C){ke(!1);return}async function e(){let e=C.plugin.manifest.mcpServers,t=!1;if(e&&(t=typeof e==`string`&&Te(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Te(e))),!t)try{let e=nn.join(C.plugin.path,`..`),n=nn.join(e,`.claude-plugin`,`marketplace.json`),r=Xe(await rn.readFile(n,`utf-8`)).plugins?.find(e=>e.name===C.plugin.name);if(r?.mcpServers){let e=r.mcpServers;t=typeof e==`string`&&Te(e)||Array.isArray(e)&&e.some(e=>typeof e==`string`&&Te(e))}}catch(e){Qe(`Failed to read raw marketplace.json: ${e}`)}ke(t)}e()},[C]),(0,X.useEffect)(()=>{async function e(){ae(!0);try{let{enabled:e,disabled:t}=await ye(),n=it(),r=Zn([...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=tt(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)),T(a);let o=[];for(let e of a)for(let t of e.installedPlugins){let n=`${t.name}@${e.name}`,r=t.isBuiltin?`builtin`:Tt(n).scope;o.push({plugin:t,marketplace:e.name,scope:r,pendingEnable:void 0,pendingUpdate:!1})}D(o),F(0)}finally{ae(!1)}}e()},[]),(0,X.useEffect)(()=>{if(!se.current&&i&&re.length>0&&!O){let{name:e,marketplace:n}=h(i),r=o??n,a=r?re.filter(e=>e.name===r):re;for(let t of a){let n=t.installedPlugins.find(t=>t.name===e);if(n){let{scope:e}=Tt(`${n.name}@${t.name}`),r={plugin:n,marketplace:t.name,scope:e,pendingEnable:void 0,pendingUpdate:!1};w(r),b(`plugin-details`),ce.current=s,se.current=!0;return}}let c=N.find(t=>t.type===`failed-plugin`&&t.name===e);c&&c.type===`failed-plugin`&&(b({type:`failed-plugin-details`,plugin:{id:c.id,name:c.name,marketplace:c.marketplace,errors:c.errors,scope:c.scope}}),se.current=!0),!se.current&&s&&(se.current=!0,t(`Plugin "${i}" is not installed in this project`))}},[i,o,re,O,N,s,t]);let Ae=async r=>{if(!C)return;let i=C.scope||`user`,a=i===`builtin`;if(a&&(r===`update`||r===`uninstall`)){L(`Built-in plugins cannot be updated or uninstalled.`);return}if(!a&&!wt(i)&&r!==`update`){L(`This plugin is managed by your organization. Contact your admin to disable it.`);return}I(!0),L(null);try{let o=`${C.plugin.name}@${C.marketplace}`,s;switch(r){case`enable`:{let e=await bt(o);if(!e.success)throw Error(e.message);break}case`disable`:{let e=await Ct(o);if(!e.success)throw Error(e.message);s=e.reverseDependents;break}case`uninstall`:{if(a||!wt(i))break;if(Dt(o)){I(!1),b(`confirm-project-uninstall`);return}let e=p().plugins[o],t=!e||e.length<=1?await pe(o):null;if(t){I(!1),b({type:`confirm-data-cleanup`,size:t});return}let n=await xt(o,i);if(!n.success)throw Error(n.message);s=n.reverseDependents;break}case`update`:{if(a)break;let r=await St(o,i);if(!r.success)throw Error(r.message);if(r.alreadyUpToDate){t(`${C.plugin.name} is already at the latest version (${r.newVersion}).`),n&&await n(),e({type:`menu`});return}break}}_e();let c=`${C.plugin.name}@${C.marketplace}`;if(it()?.enabledPlugins?.[c]!==!1){I(!1),b({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} ${C.plugin.name}${u}. Run /reload-plugins to apply.`),n&&await n(),e({type:`menu`})}catch(e){I(!1);let t=e instanceof Error?e.message:String(e);L(`Failed to ${r}: ${t}`),ft(Ze(e))}},je=(0,X.useRef)(Ae);je.current=Ae,(0,X.useEffect)(()=>{if(y===`plugin-details`&&C&&ce.current){let e=ce.current;ce.current=void 0,je.current(e)}},[y,C]);let Me=$n.useCallback(()=>{if(P>=fe.length)return;let e=fe[P];if(e?.type!==`flagged-plugin`)if(e?.type===`plugin`){let t=`${e.plugin.name}@${e.marketplace}`,n=it(),r=k.get(t),i=n?.enabledPlugins?.[t]!==!1,a=e.scope;if(a===`builtin`||wt(a)){let e=new Map(k);r?(e.delete(t),(async()=>{try{r===`will-disable`?await bt(t):await Ct(t),_e()}catch(e){ft(e)}})()):(e.set(t,i?`will-disable`:`will-enable`),(async()=>{try{i?await Ct(t):await bt(t),_e()}catch(e){ft(e)}})()),oe(e)}}else e?.type===`mcp`&&j(e.client.name)},[P,fe,k,E,j]);R({"select:previous":()=>{P===0?_(!0):me.handleSelectionChange(P-1,F)},"select:next":()=>{P<fe.length-1&&me.handleSelectionChange(P+1,F)},"select:accept":$n.useCallback(()=>{if(P>=fe.length)return;let e=fe[P];if(e?.type===`plugin`){let t=E.find(t=>t.plugin.name===e.plugin.name&&t.marketplace===e.marketplace);t&&(w(t),b(`plugin-details`),ge(0),L(null))}else e?.type===`flagged-plugin`?(b({type:`flagged-detail`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,reason:e.reason,text:e.text,flaggedAt:e.flaggedAt}}),L(null)):e?.type===`failed-plugin`?(b({type:`failed-plugin-details`,plugin:{id:e.id,name:e.name,marketplace:e.marketplace,errors:e.errors,scope:e.scope}}),ge(0),L(null)):e?.type===`mcp`&&(b({type:`mcp-detail`,client:e.client}),L(null))},[P,fe,E])},{context:`Select`,isActive:y===`plugin-list`&&!g}),R({"plugin:toggle":Me},{context:`Plugin`,isActive:y===`plugin-list`&&!g}),R({"select:accept":$n.useCallback(()=>{typeof y!=`object`||y.type!==`flagged-detail`||(Lt(y.plugin.id),b(`plugin-list`))},[y])},{context:`Select`,isActive:typeof y==`object`&&y.type===`flagged-detail`});let Ne=$n.useMemo(()=>{if(y!==`plugin-details`||!C)return[];let e=it(),t=`${C.plugin.name}@${C.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=C.marketplace===`builtin`,i=[];return i.push({label:n?`Disable plugin`:`Enable plugin`,action:()=>void Ae(n?`disable`:`enable`)}),r||(i.push({label:C.pendingUpdate?`Unmark for update`:`Mark for update`,action:async()=>{try{let e=await Xn(C.plugin.name,C.marketplace);if(e){L(e);return}let t=[...E],n=t.findIndex(e=>e.plugin.name===C.plugin.name&&e.marketplace===C.marketplace);n!==-1&&(t[n].pendingUpdate=!C.pendingUpdate,D(t),w({...C,pendingUpdate:!C.pendingUpdate}))}catch(e){L(e instanceof Error?e.message:`Failed to check plugin update availability`)}}}),Oe&&i.push({label:`Configure`,action:async()=>{De(!0);try{let e=C.plugin.manifest.mcpServers,t=null;if(typeof e==`string`&&Te(e))t=e;else if(Array.isArray(e)){for(let n of e)if(typeof n==`string`&&Te(n)){t=n;break}}if(!t){L(`No MCPB file found in plugin`),De(!1);return}let n=`${C.plugin.name}@${C.marketplace}`,r=await we(t,C.plugin.path,n,void 0,void 0,!0);`status`in r&&r.status===`needs-config`?(Ce(r),b(`configuring`)):L(`Failed to load MCPB for configuration`)}catch(e){let t=Je(e);L(`Failed to load configuration: ${t}`)}finally{De(!1)}}}),C.plugin.manifest.userConfig&&Object.keys(C.plugin.manifest.userConfig).length>0&&i.push({label:`Configure options`,action:()=>{b({type:`configuring-options`,schema:C.plugin.manifest.userConfig})}}),i.push({label:`Update now`,action:()=>void Ae(`update`)}),i.push({label:`Uninstall`,action:()=>void Ae(`uninstall`)})),C.plugin.manifest.homepage&&i.push({label:`Open homepage`,action:()=>void Se(C.plugin.manifest.homepage)}),C.plugin.manifest.repository&&i.push({label:`View repository`,action:()=>void Se(C.plugin.manifest.repository)}),i.push({label:`Back to plugin list`,action:()=>{b(`plugin-list`),w(null),L(null)}}),i},[y,C,Oe,E]);if(R({"select:previous":()=>{he>0&&ge(he-1)},"select:next":()=>{he<Ne.length-1&&ge(he+1)},"select:accept":()=>{Ne[he]&&Ne[he].action()}},{context:`Select`,isActive:y===`plugin-details`&&!!C}),R({"select:accept":()=>{typeof y==`object`&&y.type===`failed-plugin-details`&&(async()=>{I(!0),L(null);let e=y.plugin.id,t=y.plugin.scope,r=wt(t)?await xt(e,t,!1):await xt(e,`user`,!1),i=r.success;if(!i){for(let t of[`userSettings`,`projectSettings`,`localSettings`]){let n=rt(t);n?.enabledPlugins?.[e]!==void 0&&(st(t,{enabledPlugins:{...n.enabledPlugins,[e]:void 0}}),i=!0)}_e()}i?(n&&await n(),I(!1),b(`plugin-list`)):(I(!1),L(r.message))})()}},{context:`Select`,isActive:typeof y==`object`&&y.type===`failed-plugin-details`&&y.plugin.scope!==`managed`}),R({"confirm:yes":()=>{if(!C)return;I(!0),L(null);let r=`${C.plugin.name}@${C.marketplace}`,{error:i}=st(`localSettings`,{enabledPlugins:{...rt(`localSettings`)?.enabledPlugins,[r]:!1}});if(i){I(!1),L(`Failed to write settings: ${i.message}`);return}_e(),t(`✓ Disabled ${C.plugin.name} in .workmate/settings.local.json. Run /reload-plugins to apply.`),n&&n(),e({type:`menu`})},"confirm:no":()=>{b(`plugin-details`),L(null)}},{context:`Confirmation`,isActive:y===`confirm-project-uninstall`&&!!C&&!ve}),Re((r,i)=>{if(!C)return;let o=`${C.plugin.name}@${C.marketplace}`,s=C.scope;if(!s||s===`builtin`||!wt(s))return;let c=async r=>{I(!0),L(null);try{let i=await xt(o,s,r);if(!i.success)throw Error(i.message);_e();let c=r?``:` · data preserved`;t(`${a.tick} ${i.message}${c}`),n&&n(),e({type:`menu`})}catch(e){I(!1),L(e instanceof Error?e.message:String(e))}};r===`y`||r===`Y`?c(!0):r===`n`||r===`N`?c(!1):i.escape&&(b(`plugin-details`),L(null))},{isActive:typeof y==`object`&&y.type===`confirm-data-cleanup`&&!!C&&!ve}),$n.useEffect(()=>{F(0)},[x]),Re((e,t)=>{let n=!t.ctrl&&!t.meta;g||(e===`/`&&n?(_(!0),S(``),F(0)):n&&e.length>0&&!/^\s+$/.test(e)&&e!==`j`&&e!==`k`&&e!==` `&&(_(!0),S(e),F(0)))},{isActive:y===`plugin-list`}),O)return(0,Z.jsx)(B,{children:`Loading installed plugins…`});if(N.length===0)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(B,{bold:!0,children:`Manage plugins`})}),(0,Z.jsx)(B,{children:`No plugins or MCP servers installed.`}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,children:`Esc to go back`})})]});if(typeof y==`object`&&y.type===`plugin-options`&&C){let r=`${C.plugin.name}@${C.marketplace}`;function i(r){t(r),n&&n(),e({type:`menu`})}return(0,Z.jsx)(mn,{plugin:C.plugin,pluginId:r,onDone:(e,t)=>{switch(e){case`configured`:i(`✓ Enabled and configured ${C.plugin.name}. Run /reload-plugins to apply.`);break;case`skipped`:i(`✓ Enabled ${C.plugin.name}. Run /reload-plugins to apply.`);break;case`error`:i(`Failed to save configuration: ${t}`);break}}})}if(typeof y==`object`&&y.type===`configuring-options`&&C){let e=`${C.plugin.name}@${C.marketplace}`;return(0,Z.jsx)(ln,{title:`Configure ${C.plugin.name}`,subtitle:`Plugin options`,configSchema:y.schema,initialValues:ie(e),onSave:n=>{try{c(e,n,y.schema),_e(),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){L(`Failed to save configuration: ${Je(e)}`)}b(`plugin-details`)},onCancel:()=>b(`plugin-details`)})}if(y===`configuring`&&xe&&C){let e=`${C.plugin.name}@${C.marketplace}`;async function n(n){if(!(!xe||!C))try{let r=C.plugin.manifest.mcpServers,i=null;if(typeof r==`string`&&Te(r))i=r;else if(Array.isArray(r)){for(let e of r)if(typeof e==`string`&&Te(e)){i=e;break}}if(!i){L(`No MCPB file found`),b(`plugin-details`);return}await we(i,C.plugin.path,e,void 0,n),L(null),Ce(null),b(`plugin-details`),t(`Configuration saved. Run /reload-plugins for changes to take effect.`)}catch(e){let t=Je(e);L(`Failed to save configuration: ${t}`),b(`plugin-details`)}}function r(){Ce(null),b(`plugin-details`)}return(0,Z.jsx)(ln,{title:`Configure ${xe.manifest.name}`,subtitle:`Plugin: ${C.plugin.name}`,configSchema:xe.configSchema,initialValues:xe.existingConfig,onSave:n,onCancel:r})}if(typeof y==`object`&&y.type===`flagged-detail`){let e=y.plugin;return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{bold:!0,children:[e.name,` @ `,e.marketplace]})}),(0,Z.jsxs)(z,{marginBottom:1,children:[(0,Z.jsx)(B,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(B,{color:`error`,children:`Removed`})]}),(0,Z.jsxs)(z,{marginBottom:1,flexDirection:`column`,children:[(0,Z.jsxs)(B,{color:`error`,children:[`Removed from marketplace · reason: `,e.reason]}),(0,Z.jsx)(B,{children:e.text}),(0,Z.jsxs)(B,{dimColor:!0,children:[`Flagged on `,new Date(e.flaggedAt).toLocaleDateString()]})]}),(0,Z.jsx)(z,{marginTop:1,flexDirection:`column`,children:(0,Z.jsxs)(z,{children:[(0,Z.jsxs)(B,{children:[a.pointer,` `]}),(0,Z.jsx)(B,{color:`suggestion`,children:`Dismiss`})]})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`dismiss`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})]})}if(y===`confirm-project-uninstall`&&C)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{bold:!0,color:`warning`,children:[C.plugin.name,` is enabled in .workmate/settings.json (shared with your team)`]}),(0,Z.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(B,{children:`Disable it just for you in .workmate/settings.local.json?`}),(0,Z.jsx)(B,{dimColor:!0,children:`This has the same effect as uninstalling, without affecting other contributors.`})]}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:ve?(0,Z.jsx)(B,{dimColor:!0,children:`Disabling…`}):(0,Z.jsxs)(V,{children:[(0,Z.jsx)(m,{action:`confirm:yes`,context:`Confirmation`,fallback:`y`,description:`disable`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]});if(typeof y==`object`&&y.type===`confirm-data-cleanup`&&C)return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{bold:!0,children:[C.plugin.name,` has `,y.size.human,` of persistent data`]}),(0,Z.jsxs)(z,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)(B,{children:`Delete it along with the plugin?`}),(0,Z.jsx)(B,{dimColor:!0,children:le(`${C.plugin.name}@${C.marketplace}`)})]}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:ve?(0,Z.jsx)(B,{dimColor:!0,children:`Uninstalling…`}):(0,Z.jsxs)(B,{children:[(0,Z.jsx)(B,{bold:!0,children:`y`}),` to delete · `,(0,Z.jsx)(B,{bold:!0,children:`n`}),` to keep · `,(0,Z.jsx)(B,{bold:!0,children:`esc`}),` to cancel`]})})]});if(y===`plugin-details`&&C){let e=it(),t=`${C.plugin.name}@${C.marketplace}`,n=e?.enabledPlugins?.[t]!==!1,r=d.filter(e=>`plugin`in e&&e.plugin===C.plugin.name||e.source===t||e.source.startsWith(`${C.plugin.name}@`)),i=r.length===0?null:(0,Z.jsxs)(z,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(B,{bold:!0,color:`error`,children:[r.length,` `,H(r.length,`error`),`:`]}),r.map((e,t)=>{let n=Un(e);return(0,Z.jsxs)(z,{flexDirection:`column`,marginLeft:2,children:[(0,Z.jsx)(B,{color:`error`,children:Hn(e)}),n&&(0,Z.jsxs)(B,{dimColor:!0,italic:!0,children:[a.arrowRight,` `,n]})]},t)})]});return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{bold:!0,children:[C.plugin.name,` @ `,C.marketplace]})}),(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Scope: `}),(0,Z.jsx)(B,{children:C.scope||`user`})]}),C.plugin.manifest.version&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Version: `}),(0,Z.jsx)(B,{children:C.plugin.manifest.version})]}),C.plugin.manifest.description&&(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(B,{children:C.plugin.manifest.description})}),C.plugin.manifest.author&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(B,{dimColor:!0,children:`Author: `}),(0,Z.jsx)(B,{children:C.plugin.manifest.author.name})]}),(0,Z.jsxs)(z,{marginBottom:1,children:[(0,Z.jsx)(B,{dimColor:!0,children:`Status: `}),(0,Z.jsx)(B,{color:n?`success`:`warning`,children:n?`Enabled`:`Disabled`}),C.pendingUpdate&&(0,Z.jsx)(B,{color:`suggestion`,children:` · Marked for update`})]}),(0,Z.jsx)(Yn,{plugin:C.plugin,marketplace:C.marketplace}),i,(0,Z.jsx)(z,{marginTop:1,flexDirection:`column`,children:Ne.map((e,t)=>{let n=t===he;return(0,Z.jsxs)(z,{children:[n&&(0,Z.jsxs)(B,{children:[a.pointer,` `]}),!n&&(0,Z.jsx)(B,{children:` `}),(0,Z.jsx)(B,{bold:n,color:e.label.includes(`Uninstall`)?`error`:e.label.includes(`Update`)?`suggestion`:void 0,children:e.label})]},t)})}),ve&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{children:`Processing…`})}),be&&(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{color:`error`,children:be})}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[(0,Z.jsx)(m,{action:`select:previous`,context:`Select`,fallback:`↑`,description:`navigate`}),(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`select`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`failed-plugin-details`){let e=y.plugin,t=e.errors[0],n=t?Hn(t):`Failed to load`;return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(B,{bold:!0,children:e.name}),(0,Z.jsxs)(B,{dimColor:!0,children:[` @ `,e.marketplace]}),(0,Z.jsxs)(B,{dimColor:!0,children:[` (`,e.scope,`)`]})]}),(0,Z.jsx)(B,{color:`error`,children:n}),e.scope===`managed`?(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,children:`Managed by your organization — contact your admin`})}):(0,Z.jsxs)(z,{marginTop:1,children:[(0,Z.jsxs)(B,{color:`suggestion`,children:[a.pointer,` `]}),(0,Z.jsx)(B,{bold:!0,children:`Remove`})]}),ve&&(0,Z.jsx)(B,{children:`Processing…`}),be&&(0,Z.jsx)(B,{color:`error`,children:be}),(0,Z.jsx)(z,{marginTop:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[e.scope!==`managed`&&(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`remove`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})})]})}if(typeof y==`object`&&y.type===`mcp-detail`){let e=y.client,n=ue(u,e.name).length,r=()=>{b({type:`mcp-tools`,client:e})},i=()=>{b(`plugin-list`)},a=e=>{e&&t(e),b(`plugin-list`)},o=e.config.scope,s=e.config.type;return s===`stdio`?(0,Z.jsx)(Kt,{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)(Qt,{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)(Qt,{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)(Qt,{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}):(b(`plugin-list`),null)}if(typeof y==`object`&&y.type===`mcp-tools`){let e=y.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)($t,{server:r,onSelectTool:t=>{b({type:`mcp-tool-detail`,client:e,tool:t})},onBack:()=>b({type:`mcp-detail`,client:e})})}if(typeof y==`object`&&y.type===`mcp-tool-detail`){let{client:e,tool:t}=y,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)(Zt,{tool:t,server:i,onBack:()=>b({type:`mcp-tools`,client:e})})}let Pe=me.getVisibleItems(fe);return(0,Z.jsxs)(z,{flexDirection:`column`,children:[(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsx)(Be,{query:x,isFocused:g,isTerminalFocused:v,width:te-4,cursorOffset:ne})}),fe.length===0&&x&&(0,Z.jsx)(z,{marginBottom:1,children:(0,Z.jsxs)(B,{dimColor:!0,children:[`No items match "`,x,`"`]})}),me.scrollPosition.canScrollUp&&(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{dimColor:!0,children:[` `,a.arrowUp,` more above`]})}),Pe.map((e,t)=>{let n=me.toActualIndex(t)===P&&!g,r=t>0?Pe[t-1]:null,i=!r||r.scope!==e.scope;return(0,Z.jsxs)($n.Fragment,{children:[i&&(0,Z.jsx)(z,{marginTop:+(t>0),paddingLeft:2,children:(0,Z.jsx)(B,{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)(Gn,{item:e,isSelected:n})]},e.id)}),me.scrollPosition.canScrollDown&&(0,Z.jsx)(z,{children:(0,Z.jsxs)(B,{dimColor:!0,children:[` `,a.arrowDown,` more below`]})}),(0,Z.jsx)(z,{marginTop:1,marginLeft:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(V,{children:[(0,Z.jsx)(B,{children:`type to search`}),(0,Z.jsx)(m,{action:`plugin:toggle`,context:`Plugin`,fallback:`Space`,description:`toggle`}),(0,Z.jsx)(m,{action:`select:accept`,context:`Select`,fallback:`Enter`,description:`details`}),(0,Z.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`back`})]})})}),k.size>0&&(0,Z.jsx)(z,{marginLeft:1,children:(0,Z.jsx)(B,{dimColor:!0,italic:!0,children:`Run /reload-plugins to apply changes`})})]})}var $n,X,Z,er=e((()=>{i(),$n=t(Le(),1),X=t(Le(),1),C(),We(),qt(),Xt(),Jt(),Yt(),Ut(),Gt(),Oe(),me(),d(),Bt(),f(),Et(),O(),nt(),j(),$e(),Ye(),dt(),M(),ke(),v(),P(),Ae(),Rt(),ne(),de(),ce(),Ee(),vt(),at(),et(),_t(),Wn(),fn(),_n(),Kn(),kn(),Z=qe()}));function tr(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 nr=e((()=>{}));function rr({onComplete:e,path:t}){return(0,ir.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{Bo as t,Co as n,Eo as r,Fw as i,Io as a,Lo as o,Mo as s,Nw as c,xo as l}from"./loadAgentsDir-CwEfQDOw.js";import{P as u,R as d,c as f,i as p}from"./debug-BQj6h99Q.js";import{vt as m,xt as h}from"./settings-CvhsRFaT.js";import{b as g,h as _}from"./config-BSkuQZNf.js";import{o as v,s as y}from"./log-BlJ7CcKG.js";import{f as b,s as x}from"./pluginOperations-C7BCR7pw.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await o(),t=s(),n=new Set;for(let[r,i]of Object.entries(e)){let e=t[r]?.autoUpdate;(e===void 0?h(r,i):e)&&n.add(r.toLowerCase())}return n}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,f(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||f(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){f(`Plugin autoupdate: error updating ${e}: ${u(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=r(),a=Object.keys(t.plugins);return a.length===0?[]:(await Promise.allSettled(a.map(async r=>{let{marketplace:a}=i(r);if(!a||!e.has(a.toLowerCase()))return null;let o=t.plugins[r];if(!o||o.length===0)return null;let s=o.filter(n);return s.length===0?null:w(r,s)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(g()){f(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let n=(await Promise.allSettled(Array.from(e).map(async e=>{try{await t(e,void 0,{disableCredentialHelper:!0})}catch(t){f(`Plugin autoupdate: failed to refresh marketplace ${e}: ${u(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);n.length>0&&f(`Plugin autoupdate: ${n.length} marketplace refresh(es) failed`,{level:`warn`}),f(`Plugin autoupdate: checking installed plugins`);let r=await E(e);r.length>0&&(O?O(r):k=r)}catch(e){y(e)}})()}var O,k,A=e((()=>{x(),_(),p(),d(),v(),l(),a(),c(),m(),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{Bo as t,Co as n,Eo as r,Fw as i,Io as a,Lo as o,Mo as s,Nw as c,xo as l}from"./loadAgentsDir-CbtNPJV3.js";import{P as u,R as d,c as f,i as p}from"./debug-BQj6h99Q.js";import{vt as m,xt as h}from"./settings-CvhsRFaT.js";import{b as g,h as _}from"./config-BSkuQZNf.js";import{o as v,s as y}from"./log-BlJ7CcKG.js";import{f as b,s as x}from"./pluginOperations-wUUdFpu9.js";function S(e){return O=e,k!==null&&k.length>0&&(e(k),k=null),()=>{O=null}}async function C(){let e=await o(),t=s(),n=new Set;for(let[r,i]of Object.entries(e)){let e=t[r]?.autoUpdate;(e===void 0?h(r,i):e)&&n.add(r.toLowerCase())}return n}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,f(`Plugin autoupdate: updated ${e} from ${t.oldVersion} to ${t.newVersion}`)):t.alreadyUpToDate||f(`Plugin autoupdate: failed to update ${e}: ${t.message}`,{level:`warn`})}catch(t){f(`Plugin autoupdate: error updating ${e}: ${u(t)}`,{level:`warn`})}return n?e:null}async function T(e){let t=r(),a=Object.keys(t.plugins);return a.length===0?[]:(await Promise.allSettled(a.map(async r=>{let{marketplace:a}=i(r);if(!a||!e.has(a.toLowerCase()))return null;let o=t.plugins[r];if(!o||o.length===0)return null;let s=o.filter(n);return s.length===0?null:w(r,s)}))).filter(e=>e.status===`fulfilled`&&e.value!==null).map(e=>e.value)}async function E(e){return T(e)}function D(){(async()=>{if(g()){f(`Plugin autoupdate: skipped (auto-updater disabled)`);return}try{let e=await C();if(e.size===0)return;let n=(await Promise.allSettled(Array.from(e).map(async e=>{try{await t(e,void 0,{disableCredentialHelper:!0})}catch(t){f(`Plugin autoupdate: failed to refresh marketplace ${e}: ${u(t)}`,{level:`warn`})}}))).filter(e=>e.status===`rejected`);n.length>0&&f(`Plugin autoupdate: ${n.length} marketplace refresh(es) failed`,{level:`warn`}),f(`Plugin autoupdate: checking installed plugins`);let r=await E(e);r.length>0&&(O?O(r):k=r)}catch(e){y(e)}})()}var O,k,A=e((()=>{x(),_(),p(),d(),v(),l(),a(),c(),m(),O=null,k=null}));export{T as i,A as n,S as r,D as t};
@@ -1 +1 @@
1
- import{Do as e,Io as t,No as n,Ro as r,xo as i}from"./loadAgentsDir-CwEfQDOw.js";import{P as a,R as o,c as s,i as c}from"./debug-BQj6h99Q.js";import{d as l,s as u}from"./pluginOperations-C7BCR7pw.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-srvq9H7p.js";u(),c(),o(),i(),t(),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 t=e(),i=f(),o=await r(),c=[];for(let e of Object.keys(o))try{let r=await n(e);if(!r.forceRemoveDeletedPlugins)continue;let o=h(t,r,e);for(let e of o){if(e in i)continue;let n=t.plugins[e]??[];if(n.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let t of n){let{scope:n}=t;if(!(n!==`user`&&n!==`project`&&n!==`local`))try{await l(e,n)}catch(t){s(`Failed to auto-uninstall delisted plugin ${e} from ${n}: ${a(t)}`,{level:`error`})}}await m(e),c.push(e)}}}catch(t){s(`Failed to check for delisted plugins in "${e}": ${a(t)}`,{level:`warn`})}return c}export{g as t};
1
+ import{Do as e,Io as t,No as n,Ro as r,xo as i}from"./loadAgentsDir-CbtNPJV3.js";import{P as a,R as o,c as s,i as c}from"./debug-BQj6h99Q.js";import{d as l,s as u}from"./pluginOperations-wUUdFpu9.js";import{i as d,n as f,r as p,t as m}from"./pluginFlagging-C0PtAJEg.js";u(),c(),o(),i(),t(),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 t=e(),i=f(),o=await r(),c=[];for(let e of Object.keys(o))try{let r=await n(e);if(!r.forceRemoveDeletedPlugins)continue;let o=h(t,r,e);for(let e of o){if(e in i)continue;let n=t.plugins[e]??[];if(n.some(e=>e.scope===`user`||e.scope===`project`||e.scope===`local`)){for(let t of n){let{scope:n}=t;if(!(n!==`user`&&n!==`project`&&n!==`local`))try{await l(e,n)}catch(t){s(`Failed to auto-uninstall delisted plugin ${e} from ${n}: ${a(t)}`,{level:`error`})}}await m(e),c.push(e)}}}catch(t){s(`Failed to check for delisted plugins in "${e}": ${a(t)}`,{level:`warn`})}return c}export{g as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./figures-5ThXQEtq.js";import{$d as n,Cf as r,Fw as i,Nw as a,Tf as o,Zd as s,bo as c,wf as l,yo as u}from"./loadAgentsDir-CwEfQDOw.js";import{P as d,R as f}from"./debug-BQj6h99Q.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-BlJ7CcKG.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-C7BCR7pw.js";e(),f(),n(),h(),c(),a(),p(),o(),_(),T();function E(e,n,a){g(e);let o=a?`${n} plugin "${a}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${o}: ${d(e)}`);let s=a?(()=>{let{name:e,marketplace:t}=i(a);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...r(e,t,u())}})():{};v(`tengu_plugin_command_failed`,{command:n,error_category:l(e),...s}),process.exit(1)}async function D(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let a=await b(e,n);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);v(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:a.scope||n,install_source:`cli-explicit`,...r(o,s,u())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,a=!1){try{let o=await x(e,n,!a);if(!o.success)throw Error(o.message);console.log(`${t.tick} ${o.message}`);let{name:s,marketplace:c}=i(o.pluginId||e);v(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:s,...c&&{_PROTO_marketplace_name:c},scope:o.scope||n,...r(s,c,u())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,n){try{let a=await y(e,n);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);v(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:a.scope,...r(o,s,u())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,n){try{let a=await C(e,n);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);v(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:a.scope,...r(o,s,u())}),process.exit(0)}catch(t){E(t,`disable`,e)}}async function j(){try{let e=await w();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),v(`tengu_plugin_disabled_all_cli`,{}),process.exit(0)}catch(e){E(e,`disable-all`)}}async function M(e,n){try{m(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let a=await S(e,n);if(!a.success)throw Error(a.message);if(m(`${t.tick} ${a.message}\n`),!a.alreadyUpToDate){let{name:t,marketplace:n}=i(a.pluginId||e);v(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...n&&{_PROTO_marketplace_name:n},old_version:a.oldVersion||`unknown`,new_version:a.newVersion||`unknown`,...r(t,n,u())})}await s(0)}catch(t){E(t,`update`,e)}}export{O as a,D as i,A as n,M as o,k as r,j as t};
1
+ import{n as e,t}from"./figures-5ThXQEtq.js";import{$d as n,Cf as r,Fw as i,Nw as a,Tf as o,Zd as s,bo as c,wf as l,yo as u}from"./loadAgentsDir-CbtNPJV3.js";import{P as d,R as f}from"./debug-BQj6h99Q.js";import{n as p,o as m}from"./process-gEbdy6uY.js";import{o as h,s as g}from"./log-BlJ7CcKG.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{a as y,c as b,d as x,f as S,i as C,r as w,s as T}from"./pluginOperations-wUUdFpu9.js";e(),f(),n(),h(),c(),a(),p(),o(),_(),T();function E(e,n,a){g(e);let o=a?`${n} plugin "${a}"`:n===`disable-all`?`disable all plugins`:`${n} plugins`;console.error(`${t.cross} Failed to ${o}: ${d(e)}`);let s=a?(()=>{let{name:e,marketplace:t}=i(a);return{_PROTO_plugin_name:e,...t&&{_PROTO_marketplace_name:t},...r(e,t,u())}})():{};v(`tengu_plugin_command_failed`,{command:n,error_category:l(e),...s}),process.exit(1)}async function D(e,n=`user`){try{console.log(`Installing plugin "${e}"...`);let a=await b(e,n);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);v(`tengu_plugin_installed_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:a.scope||n,install_source:`cli-explicit`,...r(o,s,u())}),process.exit(0)}catch(t){E(t,`install`,e)}}async function O(e,n=`user`,a=!1){try{let o=await x(e,n,!a);if(!o.success)throw Error(o.message);console.log(`${t.tick} ${o.message}`);let{name:s,marketplace:c}=i(o.pluginId||e);v(`tengu_plugin_uninstalled_cli`,{_PROTO_plugin_name:s,...c&&{_PROTO_marketplace_name:c},scope:o.scope||n,...r(s,c,u())}),process.exit(0)}catch(t){E(t,`uninstall`,e)}}async function k(e,n){try{let a=await y(e,n);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);v(`tengu_plugin_enabled_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:a.scope,...r(o,s,u())}),process.exit(0)}catch(t){E(t,`enable`,e)}}async function A(e,n){try{let a=await C(e,n);if(!a.success)throw Error(a.message);console.log(`${t.tick} ${a.message}`);let{name:o,marketplace:s}=i(a.pluginId||e);v(`tengu_plugin_disabled_cli`,{_PROTO_plugin_name:o,...s&&{_PROTO_marketplace_name:s},scope:a.scope,...r(o,s,u())}),process.exit(0)}catch(t){E(t,`disable`,e)}}async function j(){try{let e=await w();if(!e.success)throw Error(e.message);console.log(`${t.tick} ${e.message}`),v(`tengu_plugin_disabled_all_cli`,{}),process.exit(0)}catch(e){E(e,`disable-all`)}}async function M(e,n){try{m(`Checking for updates for plugin "${e}" at ${n} scope…\n`);let a=await S(e,n);if(!a.success)throw Error(a.message);if(m(`${t.tick} ${a.message}\n`),!a.alreadyUpToDate){let{name:t,marketplace:n}=i(a.pluginId||e);v(`tengu_plugin_updated_cli`,{_PROTO_plugin_name:t,...n&&{_PROTO_marketplace_name:n},old_version:a.oldVersion||`unknown`,new_version:a.newVersion||`unknown`,...r(t,n,u())})}await s(0)}catch(t){E(t,`update`,e)}}export{O as a,D as i,A as n,M as o,k as r,j as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{vw as t,yw as n}from"./loadAgentsDir-CwEfQDOw.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-BQj6h99Q.js";import{o as u,s as d}from"./log-BlJ7CcKG.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{vw as t,yw as n}from"./loadAgentsDir-CbtNPJV3.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-BQj6h99Q.js";import{o as u,s as d}from"./log-BlJ7CcKG.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};