import{vc as x,wc as o}from"./cli-0.5.3-zfn4tvdr.mjs";import{BA as M,BH as i,Ds as $,EI as W,Es as d,HA as l,HI as t,Ks as y,Ms as u,Vm as Y,Xm as g,mH as O,nH as a,qs as Z,su as K,uu as m,ws as v,yH as R}from"./cli-0.5.3-jbzr8k4s.mjs";import{H6 as h,z6 as X}from"./cli-0.5.3-t65dek0m.mjs";import{Nfa as I,Qfa as c}from"./cli-0.5.3-n3cxyxpg.mjs";import{Ega as V,Lga as f}from"./cli-0.5.3-c8bcrqa4.mjs";import{gma as _,via as U}from"./cli-0.5.3-qrvd6cmy.mjs";import{Xma as C}from"./cli-0.5.3-0df3r78b.mjs";async function Lj(w){I("refreshActivePlugins: clearing all plugin caches"),R(),K();let G=await W(),[E,F]=await Promise.all([O(),Z(U())]),{enabled:z,disabled:B,errors:H}=G;x(E);let[P,S]=await Promise.all([Promise.all(z.map(async(j)=>{if(j.mcpServers)return Object.keys(j.mcpServers).length;let q=await Y(j,H);if(q)j.mcpServers=q;return q?Object.keys(q).length:0})),Promise.all(z.map(async(j)=>{if(j.lspServers)return Object.keys(j.lspServers).length;let q=await $(j,H);if(q)j.lspServers=q;return q?Object.keys(q).length:0}))]),J=P.reduce((j,q)=>j+q,0),L=S.reduce((j,q)=>j+q,0);w((j)=>({...j,plugins:{...j.plugins,enabled:z,disabled:B,commands:[],errors:n(j.plugins.errors,H),needsRefresh:!1},agentDefinitions:F,mcp:{...j.mcp,pluginReconnectKey:j.mcp.pluginReconnectKey+1}})),y();let N=!1;try{await M()}catch(j){N=!0,X(j),I(`refreshActivePlugins: loadPluginHooks failed: ${V(j)}`)}let Q=z.reduce((j,q)=>{if(!q.hooksConfig)return j;return j+Object.values(q.hooksConfig).reduce((k,A)=>k+(A?.reduce((D,b)=>D+b.hooks.length,0)??0),0)},0);return I(`refreshActivePlugins: ${z.length} enabled, ${E.length} commands, ${F.allAgents.length} agents, ${Q} hooks, ${J} MCP, ${L} LSP`),{enabled_count:z.length,disabled_count:B.length,command_count:E.length,agent_count:F.allAgents.length,hook_count:Q,mcp_count:J,lsp_count:L,error_count:H.length+(N?1:0),agentDefinitions:F,pluginCommands:E}}function n(w,G){let E=w.filter((B)=>B.source==="lsp-manager"||B.source.startsWith("plugin:")),F=new Set(G.map(T));return[...E.filter((B)=>!F.has(T(B))),...G]}function T(w){return w.type==="generic-error"?`generic-error:${w.source}:${w.error}`:`${w.type}:${w.source}`}var p=C(()=>{_();u();o();v();c();f();h();i();a();l();d();g();m();t()});
export{Lj as rc,p as sc};
