import{vc as x,wc as o}from"./cli-0.5.4-zy4nyw3m.mjs";import{AH as R,DA as M,DH as i,Fs as $,GI as W,Gs as d,JA as l,JI as t,Ms as y,Os as u,Xm as Y,Zm as g,oH as O,pH as a,ss as Z,uu as K,wu as m,ys as v}from"./cli-0.5.4-k5fz4zd3.mjs";import{B6 as X,J6 as h}from"./cli-0.5.4-cbq01zg3.mjs";import{Pfa as I,Sfa as c}from"./cli-0.5.4-end8wj9r.mjs";import{Gga as V,Nga as f}from"./cli-0.5.4-sgcaw17t.mjs";import{ima as _,xia as U}from"./cli-0.5.4-jmc3bzbn.mjs";import{Zma as C}from"./cli-0.5.4-aacw1src.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};
