import{Bc as x,Cc as o}from"./cli-0.5.12-zf4k1ja2.mjs";import{As as v,CH as O,DH as a,FA as M,Hs as $,Is as d,LA as l,OH as R,Os as y,Qs as u,RH as i,UI as W,XI as t,pu as K,rn as Y,ru as m,tn as g,us as Z}from"./cli-0.5.12-zc0qwdy2.mjs";import{Bca as X,Jca as h}from"./cli-0.5.12-g4wb8mj2.mjs";import{fga as I,iga as c}from"./cli-0.5.12-p5ps8gf0.mjs";import{Gga as f,zga as V}from"./cli-0.5.12-tfdwzg37.mjs";import{Gia as U,rma as _}from"./cli-0.5.12-c8f4daey.mjs";import{aoa as C}from"./cli-0.5.12-xzeb7mtb.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 xc,p as yc};
