MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / KS6

Function KS6

package/cli.js:6088–6088  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6086${K}
6087</${RW6}>`}function R47(q,K){if((q==="team"||q==="enterprise")&&K)return{entries:K,source:"org"};return{entries:sg8(),source:"ledger"}}function dH6(q,K){let _=q.split(":");return K.find((z)=>z.kind==="server"?q===z.name:_[0]==="plugin"&&_[1]===z.name)}function R78(q,K,_){if(!K?.experimental?.["claude/channel"])return{action:"skip",kind:"capability",reason:"server did not declare claude/channel capability"};if(!QH6())return{action:"skip",kind:"disabled",reason:"channels feature is not currently available"};if(!Kq()?.accessToken)return{action:"skip",kind:"auth",reason:"channels requires claude.ai authentication (run /login)"};let z=yK(),Y=z==="team"||z==="enterprise",$=Y?v1("policySettings"):void 0;if(Y&&$?.channelsEnabled!==!0)return{action:"skip",kind:"policy",reason:"channels not enabled by org policy (set channelsEnabled: true in managed settings)"};let A=dH6(q,eH());if(!A)return{action:"skip",kind:"session",reason:`server ${q} not in --channels list for this session`};if(A.kind==="plugin"){let O=_?Z4(_).marketplace:void 0;if(O!==A.marketplace)return{action:"skip",kind:"marketplace",reason:`you asked for plugin:${A.name}@${A.marketplace} but the installed ${A.name} plugin is from ${O??"an unknown source"}`};if(!A.dev){let{entries:w,source:j}=R47(z,$?.allowedChannelPlugins);if(!w.some((H)=>H.plugin===A.name&&H.marketplace===A.marketplace))return{action:"skip",kind:"allowlist",reason:j==="org"?`plugin ${A.name}@${A.marketplace} is not on your org's approved channels list (set allowedChannelPlugins in managed settings)`:`plugin ${A.name}@${A.marketplace} is not on the approved channels allowlist (use --dangerously-load-development-channels for local dev)`}}}else if(!A.dev)return{action:"skip",kind:"allowlist",reason:`server ${A.name} is not on the approved channels allowlist (use --dangerously-load-development-channels for local dev)`};return{action:"register"}}var E78,L47="notifications/claude/channel/permission",UNK,QNK="notifications/claude/channel/permission_request",iJY;var h78=y(()=>{x7();v8();RY();G7();hP();U1();y78();E78=B6(()=>L.object({method:L.literal("notifications/claude/channel"),params:L.object({content:L.string(),meta:L.record(L.string(),L.string()).optional()})})),UNK=B6(()=>L.object({method:L.literal(L47),params:L.object({request_id:L.string(),behavior:L.enum(["allow","deny"])})})),iJY=/^[a-zA-Z_][a-zA-Z0-9_]*$/});function cNK(){return g8("tengu_harbor_permissions",!1)}function dNK(q){let K=2166136261;for(let z=0;z<q.length;z++)K^=q.charCodeAt(z),K=Math.imul(K,16777619);K=K>>>0;let _="";for(let z=0;z<5;z++)_+=rJY[K%25],K=Math.floor(K/25);return _}function lNK(q){let K=dNK(q);for(let _=0;_<10;_++){if(!oJY.some((z)=>K.includes(z)))return K;K=dNK(`${q}:${_}`)}return K}function nNK(q){try{let K=g6(q);return K.length>200?K.slice(0,200)+"…":K}catch{return"(unserializable)"}}function iNK(q,K){return q.filter((_)=>_.type==="connected"&&K(_.name)&&_.capabilities?.experimental?.["claude/channel"]!==void 0&&_.capabilities?.experimental?.["claude/channel/permission"]!==void 0)}function rNK(){let q=new Map;return{onResponse(K,_){let z=K.toLowerCase();return q.set(z,_),()=>{q.delete(z)}},resolve(K,_,z){let Y=K.toLowerCase(),$=q.get(Y);if(!$)return!1;return q.delete(Y),$({behavior:_,fromServer:z}),!0}}}var rJY="abcdefghijkmnopqrstuvwxyz",oJY;var h47=y(()=>{l8();o1();oJY=["fuck","shit","cunt","cock","dick","twat","piss","crap","bitch","whore","ass","tit","cum","fag","dyke","nig","kike","rape","nazi","damn","poo","pee","wank","anus"]});function oNK(q){let K="plugin"in q?q.plugin:"no-plugin";return`${q.type}:${q.source}:${K}`}function aNK(q,K){if(K.length===0)return;q((_)=>{let z=new Set(_.plugins.errors.map(($)=>oNK($))),Y=K.filter(($)=>!z.has(oNK($)));if(Y.length===0)return _;return{..._,plugins:{..._.plugins,errors:[..._.plugins.errors,...Y]}}})}function sNK(q,K=!1){let _=jz(),z=P8((Z)=>Z.authVersion),Y=P8((Z)=>Z.mcp.pluginReconnectKey),$=s7(),A=s0.useRef(new Map),O=s0.useRef(new Set),w=s0.useRef(null);if(w.current===null)w.current=rNK();s0.useEffect(()=>{{let Z=w.current;if(!Z)return;if(!cNK())return;return $((T)=>{if(T.channelPermissionCallbacks===Z)return T;return{...T,channelPermissionCallbacks:Z}}),()=>{$((T)=>{if(T.channelPermissionCallbacks===void 0)return T;return{...T,channelPermissionCallbacks:void 0}})}}},[$]);let{addNotification:j}=PK(),H=16,J=s0.useRef([]),M=s0.useRef(null),X=s0.useCallback(()=>{M.current=null;let Z=J.current;if(Z.length===0)return;J.current=[],$((T)=>{let v=T.mcp;for(let V of Z){let{tools:E,commands:S,resources:R,...x}=V,I=x.type==="disabled"||x.type==="failed"?E??[]:E,B=x.type==="disabled"||x.type==="failed"?S??[]:S,p=x.type==="disabled"||x.type==="failed"?R??[]:R,C=kE(x.name),F=v.clients.findIndex((t)=>t.name===x.name)===-1?[...v.clients,x]:v.clients.map((t)=>t.name===x.name?x:t),U=I===void 0?v.tools:[...D0(v.tools,(t)=>t.name?.startsWith(C)),...I],c=B===void 0?v.commands:[...D0(v.commands,(t)=>LU(t,x.name)),...B],K6=p===void 0?v.resources:{...v.resources,...p.length>0?{[x.name]:p}:W56(v.resources,x.name)};v={...v,clients:F,tools:U,commands:c,resources:K6}}return{...T,mcp:v}})},[$]),P=s0.useCallback((Z)=>{if(J.current.push(Z),M.current===null)M.current=setTimeout(X,H)},[X]),W=s0.useCallback(({client:Z,tools:T,commands:v,resources:V})=>{switch(P({...Z,tools:T,commands:v,resources:V}),Z.type){case"connected":{AS4(Z.client,Z.name,$),Z.client.onclose=()=>{let E=Z.config.type??"stdio";if(pG(Z.name,Z.config).catch(()=>{N(`Failed to invalidate the server cache: ${Z.name}`)}),bG(Z.name)){C8(Z.name,"Server is disabled, skipping automatic reconnection");return}if(E!=="stdio"&&E!=="sdk"){let S=eJY(E);C8(Z.name,`${S} transport closed/disconnected, attempting automatic reconnection`);let R=A.current.get(Z.name);if(R)clearTimeout(R),A.current.delete(Z.name);(async()=>{for(let I=1;I<=ch6;I++){if(bG(Z.name)){C8(Z.name,"Server disabled during reconnection, stopping retry"),A.current.delete(Z.name);return}P({...Z,type:"pending",reconnectAttempt:I,maxReconnectAttempts:ch6});let B=Date.now();try{let C=await qm(Z.name,Z.config),g=Date.now()-B;if(C.client.type==="connected"){C8(Z.name,`${S} reconnection successful after ${g}ms (attempt ${I})`),A.current.delete(Z.name),W(C);return}if(C8(Z.name,`${S} reconnection attempt ${I} completed with status: ${C.client.type}`),I===ch6){C8(Z.name,`Max reconnection attempts (${ch6}) reached, giving up`),A.current.delete(Z.name),W(C);return}}catch(C){let g=Date.now()-B;if(Qz(Z.name,`${S} reconnection attempt ${I} failed after ${g}ms: ${C}`),I===ch6){C8(Z.name,`Max reconnection attempts (${ch6}) reached, giving up`),A.current.delete(Z.name),P({...Z,type:"failed"});return}}let p=Math.min(sJY*Math.pow(2,I-1),tJY);C8(Z.name,`Scheduling reconnection attempt ${I+1} in ${p}ms`),await new Promise((C)=>{let g=setTimeout(C,p);A.current.set(Z.name,g)})}})()}else P({...Z,type:"failed"})};{let E=R78(Z.name,Z.capabilities,Z.config.pluginSource),S=dH6(Z.name,eH()),R=S?.kind==="plugin"?`${S.name}@${S.marketplace}`:void 0;if(E.action==="register"||E.kind!=="capability")d("tengu_mcp_channel_gate",{registered:E.action==="register",skip_kind:E.action==="skip"?E.kind:void 0,entry_kind:S?.kind,is_dev:S?.dev??!1,plugin:R});switch(E.action){case"register":if(C8(Z.name,"Channel notifications registered"),Z.client.setNotificationHandler(E78(),async(x)=>{let{content:I,meta:B}=x.params;C8(Z.name,`notifications/claude/channel: ${I.slice(0,80)}`),d("tengu_mcp_channel_message",{content_length:I.length,meta_key_count:Object.keys(B??{}).length,entry_kind:S?.kind,is_dev:S?.dev??!1,plugin:R}),jM({mode:"prompt",value:L78(Z.name,I,B),priority:"next",isMeta:!0,origin:{kind:"channel",server:Z.name},skipSlashCommands:!0})}),Z.capabilities?.experimental?.["claude/channel/permission"]!==void 0)Z.client.setNotificationHandler(UNK(),async(x)=>{let{request_id:I,behavior:B}=x.params,p=w.current?.resolve(I,B,Z.name)??!1;C8(Z.name,`notifications/claude/channel/permission: ${I} → ${B} (${p?"matched pending":"no pending entry — stale or unknown ID"})`)});break;case"skip":if(Z.client.removeNotificationHandler("notifications/claude/channel"),Z.client.removeNotificationHandler(L47),C8(Z.name,`Channel notifications skipped: ${E.reason}`),E.kind!=="capability"&&E.kind!=="session"&&!O.current.has(E.kind)&&(E.kind==="marketplace"||E.kind==="allowlist"||S!==void 0)){O.current.add(E.kind);let x=E.kind==="disabled"?"Channels are not currently available":E.kind==="auth"?"Channels require claude.ai authentication · run /login":E.kind==="policy"?"Channels are not enabled for your org · have an administrator set channelsEnabled: true in managed settings":E.reason;j({key:`channels-blocked-${E.kind}`,priority:"high",text:x,color:"warning",timeoutMs:12000})}break}}if(Z.capabilities?.tools?.listChanged)Z.client.setNotificationHandler(Lu6,async()=>{C8(Z.name,"Received tools/list_changed notification, refreshing tools");try{let E=mL.cache.get(Z.name);mL.cache.delete(Z.name);let S=await mL(Z),R=S.length;if(E)E.then((x)=>{d("tengu_mcp_list_changed",{type:"tools",previousCount:x.length,newCount:R})},()=>{d("tengu_mcp_list_changed",{type:"tools",newCount:R})});else d("tengu_mcp_list_changed",{type:"tools",newCount:R});P({...Z,tools:S})}catch(E){Qz(Z.name,`Failed to refresh tools after list_changed notification: ${d6(E)}`)}});if(Z.capabilities?.prompts?.listChanged)Z.client.setNotificationHandler(yu6,async()=>{C8(Z.name,"Received prompts/list_changed notification, refreshing prompts"),d("tengu_mcp_list_changed",{type:"prompts"});try{Fw6.cache.delete(Z.name);let[E,S]=await Promise.all([Fw6(Z),Promise.resolve([])]);P({...Z,commands:[...E,...S]}),aJY?.()}catch(E){Qz(Z.name,`Failed to refresh prompts after list_changed notification: ${d6(E)}`)}});if(Z.capabilities?.resources?.listChanged)Z.client.setNotificationHandler(Vu6,async()=>{C8(Z.name,"Received resources/list_changed notification, refreshing resources"),d("tengu_mcp_list_changed",{type:"resources"});try{lr.cache.delete(Z.name);{let E=await lr(Z);P({...Z,resources:E})}}catch(E){Qz(Z.name,`Failed to refresh resources after list_changed notification: ${d6(E)}`)}});break}case"needs-auth":case"failed":case"pending":case"disabled":break}},[P]),D=N8();s0.useEffect(()=>{async function Z(){let{servers:T,errors:v}=K?{servers:{},errors:[]}:await Rw6(q),V={...T,...q};aNK($,v),$((E)=>{let{stale:S,...R}=VR4(E.mcp,V);for(let B of S){let p=A.current.get(B.name);if(p)clearTimeout(p),A.current.delete(B.name);if(B.type==="connected")B.client.onclose=void 0,pG(B.name,B.config).catch(()=>{})}let x=new Set(R.clients.map((B)=>B.name)),I=Object.entries(V).filter(([B])=>!x.has(B)).map(([B,p])=>({name:B,type:bG(B)?"disabled":"pending",config:p}));if(I.length===0&&S.length===0)return E;return{...E,mcp:{...E.mcp,...R,clients:[...R.clients,...I]}}})}Z().catch((T)=>{Qz("useManageMCPConnections",`Failed to initialize servers as pending: ${d6(T)}`)})},[K,q,$,D,Y]),s0.useEffect(()=>{let Z=!1;async function T(){let v;if(K||uq6())v=Promise.resolve({});else PR4(),v=Ew6();let{servers:V,errors:E}=K?{servers:{},errors:[]}:await Rw6(q,v);if(Z)return;aNK($,E);let S={...V,...q},R=Object.fromEntries(Object.entries(S).filter(([C])=>!bG(C)));mN6(W,R).catch((C)=>{Qz("useManageMcpConnections",`Failed to get MCP resources: ${d6(C)}`)});let x={};if(!K){if(x=bq6(await v).allowed,Z)return;if(Object.keys(x).length>0){let{servers:C}=Ya6(x,S);x=C}if(Object.keys(x).length>0){$((g)=>{let F=new Set(g.mcp.clients.map((c)=>c.name)),U=Object.entries(x).filter(([c])=>!F.has(c)).map(([c,K6])=>({name:c,type:bG(c)?"disabled":"pending",config:K6}));if(U.length===0)return g;return{...g,mcp:{...g.mcp,clients:[...g.mcp.clients,...U]}}});let C=Object.fromEntries(Object.entries(x).filter(([g])=>!bG(g)));mN6(W,C).catch((g)=>{Qz("useManageMcpConnections",`Failed to get claude.ai MCP resources: ${d6(g)}`)})}}let I={...S,...x},B={enterprise:0,global:0,project:0,user:0,plugin:0,claudeai:0},p=[];for(let[C,g]of Object.entries(I))if(g.scope==="enterprise")B.enterprise++;else if(g.scope==="user")B.global++;else if(g.scope==="project")B.project++;else if(g.scope==="local")B.user++;else if(g.scope==="dynamic")B.plugin++;else if(g.scope==="claudeai")B.claudeai++;d("tengu_mcp_servers",{...B,...{}})}return T(),()=>{Z=!0}},[K,q,W,$,z,D,Y]),s0.useEffect(()=>{let Z=A.current;return()=>{for(let T of Z.values())clearTimeout(T);if(Z.clear(),M.current!==null)clearTimeout(M.current),M.current=null,X()}},[X]);let f=s0.useCallback(async(Z)=>{let T=_.getState().mcp.clients.find((E)=>E.name===Z);if(!T)throw Error(`MCP server ${Z} not found`);let v=A.current.get(Z);if(v)clearTimeout(v),A.current.delete(Z);let V=await qm(Z,T.config);return W(V),V},[_,W]),G=s0.useCallback(async(Z)=>{let T=_.getState().mcp.clients.find((V)=>V.name===Z);if(!T)throw Error(`MCP server ${Z} not found`);if(T.type!=="disabled"){let V=A.current.get(Z);if(V)clearTimeout(V),A.current.delete(Z);if(HN6(Z,!1),T.type==="connected")await pG(Z,T.config);P({name:Z,type:"disabled",config:T.config})}else{HN6(Z,!0),P({name:Z,type:"pending",config:T.config});let V=await qm(Z,T.config);W(V)}},[_,P,W]);return{reconnectMcpServer:f,toggleMcpServer:G}}function eJY(q){switch(q){case"http":return"HTTP";case"ws":case"ws-ide":return"WebSocket";default:return"SSE"}}var s0,aJY=null,ch6=5,sJY=1000,tJY=30000;var tNK=y(()=>{v8();PD();lM();y47();By8();k8();f0();_8();v8();h$();C7();y8();E8();p2();h78();h47();ON6();CE8();ok();NJ();s0=O6(D6(),1)});function lh6(){let q=cH6.useContext(S47);if(!q)throw Error("useMcpReconnect must be used within MCPConnectionManager");return q.reconnectMcpServer}function f56(){let q=cH6.useContext(S47);if(!q)throw Error("useMcpToggleEnabled must be used within MCPConnectionManager");return q.toggleMcpServer}function tg8(q){let K=z6(6),{children:_,dynamicMcpConfig:z,isStrictMcpConfig:Y}=q,{reconnectMcpServer:$,toggleMcpServer:A}=sNK(z,Y),O;if(K[0]!==$||K[1]!==A)O={reconnectMcpServer:$,toggleMcpServer:A},K[0]=$,K[1]=A,K[2]=O;else O=K[2];let w=O,j;if(K[3]!==_||K[4]!==w)j=cH6.default.createElement(S47.Provider,{value:w},_),K[3]=_,K[4]=w,K[5]=j;else j=K[5];return j}var cH6,S47;var Z56=y(()=>{q8();tNK();cH6=O6(D6(),1),S47=cH6.createContext(null)});function C47(q){let K=z6(25),{serverName:_,onComplete:z}=q,[Y]=Aq(),$=jz(),A=lh6(),[O,w]=t0.useState(!0),[j,H]=t0.useState(null),J,M;if(K[0]!==z||K[1]!==A||K[2]!==_||K[3]!==$)J=()=>{(async function(){try{if(!$.getState().mcp.clients.find((f)=>f.name===_)){H(`MCP server "${_}" not found`),w(!1),z(`MCP server "${_}" not found`);return}let D=await A(_);q:switch(D.client.type){case"connected":{w(!1),z(`Successfully reconnected to ${_}`);break q}case"needs-auth":{H(`${_} requires authentication`),w(!1),z(`${_} requires authentication. Use /mcp to authenticate.`);break q}case"pending":case"failed":case"disabled":H(`Failed to reconnect to ${_}`),w(!1),z(`Failed to reconnect to ${_}`)}}catch(W){let D=W,f=D instanceof Error?D.message:String(D);H(f),w(!1),z(`Error: ${f}`)}})()},M=[_,A,$,z],K[0]=z,K[1]=A,K[2]=_,K[3]=$,K[4]=J,K[5]=M;else J=K[4],M=K[5];if(t0.useEffect(J,M),O){let X;if(K[6]!==_)X=t0.default.createElement(k,{color:"text"},"Reconnecting to ",t0.default.createElement(k,{bold:!0},_)),K[6]=_,K[7]=X;else X=K[7];let P;if(K[8]===Symbol.for("react.memo_cache_sentinel"))P=t0.default.createElement(u,null,t0.default.createElement(IK,null),t0.default.createElement(k,null," Establishing connection to MCP server")),K[8]=P;else P=K[8];let W;if(K[9]!==X)W=t0.default.createElement(u,{flexDirection:"column",gap:1,padding:1},X,P),K[9]=X,K[10]=W;else W=K[10];return W}if(j){let X;if(K[11]!==Y)X=h7("error",Y)(t6.cross),K[11]=Y,K[12]=X;else X=K[12];let P;if(K[13]!==X)P=t0.default.createElement(k,null,X," "),K[13]=X,K[14]=P;else P=K[14];let W;if(K[15]!==_)W=t0.default.createElement(k,{color:"error"},"Failed to reconnect to ",_),K[15]=_,K[16]=W;else W=K[16];let D;if(K[17]!==P||K[18]!==W)D=t0.default.createElement(u,null,P,W),K[17]=P,K[18]=W,K[19]=D;else D=K[19];let f;if(K[20]!==j)f=t0.default.createElement(k,{dimColor:!0},"Error: ",j),K[20]=j,K[21]=f;else f=K[21];let G;if(K[22]!==D||K[23]!==f)G=t0.default.createElement(u,{flexDirection:"column",gap:1,padding:1},D,f),K[22]=D,K[23]=f,K[24]=G;else G=K[24];return G}return null}var t0;var b47=y(()=>{q8();bq();s6();Z56();C7();Q2();t0=O6(D6(),1)});function eg8(q){let K=z6(9),{serverToolsCount:_,serverPromptsCount:z,serverResourcesCount:Y}=q,$;if(K[0]!==z||K[1]!==Y||K[2]!==_){if($=[],_>0)$.push("tools");if(Y>0)$.push("resources");if(z>0)$.push("prompts");K[0]=z,K[1]=Y,K[2]=_,K[3]=$}else $=K[3];let A;if(K[4]===Symbol.for("react.memo_cache_sentinel"))A=S78.default.createElement(k,{bold:!0},"Capabilities: "),K[4]=A;else A=K[4];let O;if(K[5]!==$)O=$.length>0?S78.default.createElement(I1,null,$):"none",K[5]=$,K[6]=O;else O=K[6];let w;if(K[7]!==O)w=S78.default.createElement(u,null,A,S78.default.createElement(k,{color:"text"},O)),K[7]=O,K[8]=w;else w=K[8];return w}var S78;var x47=y(()=>{q8();s6();QK();S78=O6(D6(),1)});function qF8(q,K){switch(q.client.type){case"connected":return{message:`Reconnected to ${K}.`,success:!0};case"needs-auth":return{message:`${K} requires authentication. Use the 'Authenticate' option.`,success:!1};case"failed":return{message:`Failed to reconnect to ${K}.`,success:!1};default:return{message:`Unknown result when reconnecting to ${K}.`,success:!1}}}function C78(q,K){let _=q instanceof Error?q.message:String(q);return`Error reconnecting to ${K}: ${_}`}function lH6({server:q,serverToolsCount:K,onViewTools:_,onCancel:z,onComplete:Y,borderless:$=!1}){let[A]=Aq(),O=o5(),{columns:w}=t1(),[j,H]=l1.default.useState(!1),[J,M]=l1.default.useState(null),X=P8((f6)=>f6.mcp),P=s7(),[W,D]=l1.default.useState(null),[f,G]=l1.useState(!1),Z=l1.useRef(null),[T,v]=l1.useState(!1),[V,E]=l1.useState(null),[S,R]=l1.useState(!1),[x,I]=l1.useState(null),[B,p]=l1.useState(!1),[C,g]=l1.useState(!1),F=l1.useRef(void 0),U=l1.useRef(!1),[c,K6]=l1.useState(""),[t,q6]=l1.useState(0),[e,i]=l1.useState(null);l1.useEffect(()=>()=>{if(U.current=!0,Z.current?.abort(),F.current!==void 0)clearTimeout(F.current)},[]);let $6=q.isAuthenticated||q.client.type==="connected"&&K>0,M6=lh6(),j6=l1.default.useCallback(async()=>{v(!1),E(null),G(!0);try{let f6=await M6(q.name),N6=f6.client.type==="connected";if(d("tengu_claudeai_mcp_auth_completed",{success:N6}),N6)Y?.(`Authentication successful. Connected to ${q.name}.`);else if(f6.client.type==="needs-auth")Y?.("Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.");else Y?.("Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.")}catch(f6){d("tengu_claudeai_mcp_auth_completed",{success:!1}),Y?.(C78(f6,q.name))}finally{G(!1)}},[M6,q.name,Y]),G6=l1.default.useCallback(async()=>{await pG(q.name,{...q.config,scope:q.scope}),P((f6)=>{let N6=f6.mcp.clients.map((T6)=>T6.name===q.name?{...T6,type:"needs-auth"}:T6),Z6=$E8(f6.mcp.tools,q.name),V6=JN6(f6.mcp.commands,q.name),y6=MN6(f6.mcp.resources,q.name);return{...f6,mcp:{...f6.mcp,clients:N6,tools:Z6,commands:V6,resources:y6}}}),d("tengu_claudeai_mcp_clear_auth_completed",{}),Y?.(`Disconnected from ${q.name}.`),R(!1),I(null),p(!1)},[q.name,q.config,q.scope,P,Y]);P1("confirm:no",()=>{Z.current?.abort(),Z.current=null,H(!1),D(null)},{context:"Confirmation",isActive:j}),P1("confirm:no",()=>{v(!1),E(null)},{context:"Confirmation",isActive:T}),P1("confirm:no",()=>{R(!1),I(null),p(!1)},{context:"Confirmation",isActive:S}),k4((f6,N6)=>{if(N6.return&&T)j6();if(N6.return&&S)if(B)G6();else{let Z6=`${u7().CLAUDE_AI_ORIGIN}/settings/connectors`;I(Z6),p(!0),m3(Z6)}if(f6==="c"&&!C){let Z6=W||V||x;if(Z6)XX(Z6).then((V6)=>{if(U.current)return;if(V6)process.stdout.write(V6);if(g(!0),F.current!==void 0)clearTimeout(F.current);F.current=setTimeout(g,2000,!1)})}});let w6=Tf(String(q.name)),o=YE8(X.commands,q.name).length,s=f56(),a=l1.default.useCallback(async()=>{let f6=u7().CLAUDE_AI_ORIGIN,Z6=B_()?.organizationUuid,V6;if(Z6&&q.config.type==="claudeai-proxy"&&q.config.id){let y6=q.config.id.startsWith("mcprs")?"mcpsrv"+q.config.id.slice(5):q.config.id,T6=encodeURIComponent(process.env.CLAUDE_CODE_ENTRYPOINT||"cli");V6=`${f6}/api/organizations/${Z6}/mcp/start-auth/${y6}?product_surface=${T6}`}else V6=`${f6}/settings/connectors`;E(V6),v(!0),d("tengu_claudeai_mcp_auth_started",{}),await m3(V6)},[q.config]),n=l1.default.useCallback(()=>{R(!0),d("tengu_claudeai_mcp_clear_auth_started",{})},[]),l=l1.default.useCallback(async()=>{let f6=q.client.type!=="disabled";try{if(await s(q.name),q.config.type==="claudeai-proxy")d("tengu_claudeai_mcp_toggle",{new_state:f6?"disabled":"enabled"});z()}catch(N6){Y?.(`Failed to ${f6?"disable":"enable"} MCP server '${q.name}': ${d6(N6)}`)}},[q.client.type,q.config.type,q.name,s,z,Y]),A6=l1.default.useCallback(async()=>{if(q.config.type==="claudeai-proxy")return;H(!0),M(null);let f6=new AbortController;Z.current=f6;try{if(q.isAuthenticated&&q.config)await wa6(q.name,q.config,{preserveStepUpState:!0});if(q.config){await pq6(q.name,q.config,D,f6.signal,{onWaitingForCallback:(Z6)=>{i(()=>Z6)}}),d("tengu_mcp_auth_config_authenticate",{wasAuthenticated:q.isAuthenticated});let N6=await M6(q.name);if(N6.client.type==="connected"){let Z6=$6?`Authentication successful. Reconnected to ${q.name}.`:`Authentication successful. Connected to ${q.name}.`;Y?.(Z6)}else if(N6.client.type==="needs-auth")Y?.("Authentication successful, but server still requires authentication. You may need to manually restart Claude Code.");else C8(q.name,"Reconnection failed after authentication"),Y?.("Authentication successful, but server reconnection failed. You may need to manually restart Claude Code for the changes to take effect.")}}catch(N6){if(N6 instanceof Error&&!(N6 instanceof hU))M(N6.message)}finally{H(!1),Z.current=null,i(null),K6("")}},[q.isAuthenticated,q.config,q.name,Y,M6,$6]),J6=async()=>{if(q.config.type==="claudeai-proxy")return;if(q.config)await wa6(q.name,q.config),d("tengu_mcp_auth_config_clear",{}),await pG(q.name,{...q.config,scope:q.scope}),P((f6)=>{let N6=f6.mcp.clients.map((T6)=>T6.name===q.name?{...T6,type:"failed"}:T6),Z6=$E8(f6.mcp.tools,q.name),V6=JN6(f6.mcp.commands,q.name),y6=MN6(f6.mcp.resources,q.name);return{...f6,mcp:{...f6.mcp,clients:N6,tools:Z6,commands:V6,resources:y6}}}),Y?.(`Authentication cleared for ${q.name}.`)};if(j){let f6=q.config.type!=="claudeai-proxy"&&q.config.oauth?.xaa?" Authenticating via your identity provider":" A browser window will open for authentication";return l1.default.createElement(u,{flexDirection:"column",gap:1,padding:1},l1.default.createElement(k,{color:"claude"},"Authenticating with ",q.name,"…"),l1.default.createElement(u,null,l1.default.createElement(IK,null),l1.default.createElement(k,null,f6)),W&&l1.default.createElement(u,{flexDirection:"column"},l1.default.createElement(u,null,l1.default.createElement(k,{dimColor:!0},"If your browser doesn't open automatically, copy this URL manually"," "),C?l1.default.createElement(k,{color:"success"},"(Copied!)"):l1.default.createElement(k,{dimColor:!0},l1.default.createElement(t8,{shortcut:"c",action:"copy",parens:!0}))),l1.default.createElement(hq,{url:W})),j&&W&&e&&l1.default.createElement(u,{flexDirection:"column",marginTop:1},l1.default.createElement(k,{dimColor:!0},"If the redirect page shows a connection error, paste the URL from your browser's address bar:"),l1.default.createElement(u,null,l1.default.createElement(k,{dimColor:!0},"URL ",">"," "),l1.default.createElement(r3,{value:c,onChange:K6,onSubmit:(N6)=>{e(N6.trim()),K6("")},cursorOffset:t,onChangeCursorOffset:q6,columns:w-8}))),l1.default.createElement(u,{marginLeft:3},l1.default.createElement(k,{dimColor:!0},"Return here after authenticating in your browser. Press Esc to go back.")))}if(T)return l1.default.createElement(u,{flexDirection:"column",gap:1,padding:1},l1.default.createElement(k,{color:"claude"},"Authenticating with ",q.name,"…"),l1.default.createElement(u,null,l1.default.createElement(IK,null),l1.default.createElement(k,null," A browser window will open for authentication")),V&&l1.default.createElement(u,{flexDirection:"column"},l1.default.createElement(u,null,l1.default.createElement(k,{dimColor:!0},"If your browser doesn't open automatically, copy this URL manually"," "),C?l1.default.createElement(k,{color:"success"},"(Copied!)"):l1.default.createElement(k,{dimColor:!0},l1.default.createElement(t8,{shortcut:"c",action:"copy",parens:!0}))),l1.default.createElement(hq,{url:V})),l1.default.createElement(u,{marginLeft:3,flexDirection:"column"},l1.default.createElement(k,{color:"permission"},"Press ",l1.default.createElement(k,{bold:!0},"Enter")," after authenticating in your browser."),l1.default.createElement(k,{dimColor:!0,italic:!0},l1.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"}))));if(S)return l1.default.createElement(u,{flexDirection:"column",gap:1,padding:1},l1.default.createElement(k,{color:"claude"},"Clear authentication for ",q.name),B?l1.default.createElement(l1.default.Fragment,null,l1.default.createElement(k,null,'Find the MCP server in the browser and click "Disconnect".'),x&&l1.default.createElement(u,{flexDirection:"column"},l1.default.createElement(u,null,l1.default.createElement(k,{dimColor:!0},"If your browser didn't open automatically, copy this URL manually"," "),C?l1.default.createElement(k,{color:"success"},"(Copied!)"):l1.default.createElement(k,{dimColor:!0},l1.default.createElement(t8,{shortcut:"c",action:"copy",parens:!0}))),l1.default.createElement(hq,{url:x})),l1.default.createElement(u,{marginLeft:3,flexDirection:"column"},l1.default.createElement(k,{color:"permission"},"Press ",l1.default.createElement(k,{bold:!0},"Enter")," when done."),l1.default.createElement(k,{dimColor:!0,italic:!0},l1.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))):l1.default.createElement(l1.default.Fragment,null,l1.default.createElement(k,null,'This will open claude.ai in the browser. Find the MCP server in the list and click "Disconnect".'),l1.default.createElement(u,{marginLeft:3,flexDirection:"column"},l1.default.createElement(k,{color:"permission"},"Press ",l1.default.createElement(k,{bold:!0},"Enter")," to open the browser."),l1.default.createElement(k,{dimColor:!0,italic:!0},l1.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))));if(f)return l1.default.createElement(u,{flexDirection:"column",gap:1,padding:1},l1.default.createElement(k,{color:"text"},"Connecting to ",l1.default.createElement(k,{bold:!0},q.name),"…"),l1.default.createElement(u,null,l1.default.createElement(IK,null),l1.default.createElement(k,null," Establishing connection to MCP server")),l1.default.createElement(k,{dimColor:!0},"This may take a few moments."));let X6=[];if(q.client.type==="disabled")X6.push({label:"Enable",value:"toggle-enabled"});if(q.client.type==="connected"&&K>0)X6.push({label:"View tools",value:"tools"});if(q.config.type==="claudeai-proxy"){if(q.client.type==="connected")X6.push({label:"Clear authentication",value:"claudeai-clear-auth"});else if(q.client.type!=="disabled")X6.push({label:"Authenticate",value:"claudeai-auth"})}else{if($6)X6.push({label:"Re-authenticate",value:"reauth"}),X6.push({label:"Clear authentication",value:"clear-auth"});if(!$6)X6.push({label:"Authenticate",value:"auth"})}if(q.client.type!=="disabled"){if(q.client.type!=="needs-auth")X6.push({label:"Reconnect",value:"reconnectMcpServer"});X6.push({label:"Disable",value:"toggle-enabled"})}if(X6.length===0)X6.push({label:"Back",value:"back"});return l1.default.createElement(u,{flexDirection:"column"},l1.default.createElement(u,{flexDirection:"column",paddingX:1,borderStyle:$?void 0:"round"},l1.default.createElement(u,{marginBottom:1},l1.default.createElement(k,{bold:!0},w6," MCP Server")),l1.default.createElement(u,{flexDirection:"column",gap:0},l1.default.createElement(u,null,l1.default.createElement(k,{bold:!0},"Status: "),q.client.type==="disabled"?l1.default.createElement(k,null,h7("inactive",A)(t6.radioOff)," disabled"):q.client.type==="connected"?l1.default.createElement(k,null,h7("success",A)(t6.tick)," connected"):q.client.type==="pending"?l1.default.createElement(l1.default.Fragment,null,l1.default.createElement(k,{dimColor:!0},t6.radioOff),l1.default.createElement(k,null," connecting…")):q.client.type==="needs-auth"?l1.default.createElement(k,null,h7("warning",A)(t6.triangleUpOutline)," needs authentication"):l1.default.createElement(k,null,h7("error",A)(t6.cross)," failed")),q.transport!=="claudeai-proxy"&&l1.default.createElement(u,null,l1.default.createElement(k,{bold:!0},"Auth: "),$6?l1.default.createElement(k,null,h7("success",A)(t6.tick)," authenticated"):l1.default.createElement(k,null,h7("error",A)(t6.cross)," not authenticated")),l1.default.createElement(u,null,l1.default.createElement(k,{bold:!0},"URL: "),l1.default.createElement(k,{dimColor:!0},q.config.url)),l1.default.createElement(u,null,l1.default.createElement(k,{bold:!0},"Config location: "),l1.default.createElement(k,{dimColor:!0},xG(q.scope))),q.client.type==="connected"&&l1.default.createElement(eg8,{serverToolsCount:K,serverPromptsCount:o,serverResourcesCount:X.resources[q.name]?.length||0}),q.client.type==="connected"&&K>0&&l1.default.createElement(u,null,l1.default.createElement(k,{bold:!0},"Tools: "),l1.default.createElement(k,{dimColor:!0},K," tools"))),J&&l1.default.createElement(u,{marginTop:1},l1.default.createElement(k,{color:"error"},"Error: ",J)),X6.length>0&&l1.default.createElement(u,{marginTop:1},l1.default.createElement(H1,{options:X6,onChange:async(f6)=>{switch(f6){case"tools":_();break;case"auth":case"reauth":await A6();break;case"clear-auth":await J6();break;case"claudeai-auth":await a();break;case"claudeai-clear-auth":n();break;case"reconnectMcpServer":G(!0);try{let N6=await M6(q.name);if(q.config.type==="claudeai-proxy")d("tengu_claudeai_mcp_reconnect",{success:N6.client.type==="connected"});let{message:Z6}=qF8(N6,q.name);Y?.(Z6)}catch(N6){if(q.config.type==="claudeai-proxy")d("tengu_claudeai_mcp_reconnect",{success:!1});Y?.(C78(N6,q.name))}finally{G(!1)}break;case"toggle-enabled":await l();break;case"back":z();break}},onCancel:z}))),l1.default.createElement(u,{marginTop:1},l1.default.createElement(k,{dimColor:!0,italic:!0},O.pending?l1.default.createElement(l1.default.Fragment,null,"Press ",O.keyName," again to exit"):l1.default.createElement(I1,null,l1.default.createElement(t8,{shortcut:"↑↓",action:"navigate"}),l1.default.createElement(t8,{shortcut:"Enter",action:"select"}),l1.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))))}var l1;var KF8=y(()=>{bq();k8();H3();z2();t4();YM();s6();Oq();or();PD();Z56();NJ();C7();G7();hH();y8();E8();a5();d_();QK();rK();Q2();CH();x47();l1=O6(D6(),1)});function b78({server:q,serverToolsCount:K,onViewTools:_,onCancel:z,onComplete:Y,borderless:$=!1}){let[A]=Aq(),O=o5(),w=P8((f)=>f.mcp),j=lh6(),H=f56(),[J,M]=R3.useState(!1),X=R3.default.useCallback(async()=>{let f=q.client.type!=="disabled";try{await H(q.name),z()}catch(G){Y(`Failed to ${f?"disable":"enable"} MCP server '${q.name}': ${d6(G)}`)}},[q.client.type,q.name,H,z,Y]),P=Tf(String(q.name)),W=YE8(w.commands,q.name).length,D=[];if(q.client.type!=="disabled"&&K>0)D.push({label:"View tools",value:"tools"});if(q.client.type!=="disabled")D.push({label:"Reconnect",value:"reconnectMcpServer"});if(D.push({label:q.client.type!=="disabled"?"Disable":"Enable",value:"toggle-enabled"}),D.length===0)D.push({label:"Back",value:"back"});if(J)return R3.default.createElement(u,{flexDirection:"column",gap:1,padding:1},R3.default.createElement(k,{color:"text"},"Reconnecting to ",R3.default.createElement(k,{bold:!0},q.name)),R3.default.createElement(u,null,R3.default.createElement(IK,null),R3.default.createElement(k,null," Restarting MCP server process")),R3.default.createElement(k,{dimColor:!0},"This may take a few moments."));return R3.default.createElement(u,{flexDirection:"column"},R3.default.createElement(u,{flexDirection:"column",paddingX:1,borderStyle:$?void 0:"round"},R3.default.createElement(u,{marginBottom:1},R3.default.createElement(k,{bold:!0},P," MCP Server")),R3.default.createElement(u,{flexDirection:"column",gap:0},R3.default.createElement(u,null,R3.default.createElement(k,{bold:!0},"Status: "),q.client.type==="disabled"?R3.default.createElement(k,null,h7("inactive",A)(t6.radioOff)," disabled"):q.client.type==="connected"?R3.default.createElement(k,null,h7("success",A)(t6.tick)," connected"):q.client.type==="pending"?R3.default.createElement(R3.default.Fragment,null,R3.default.createElement(k,{dimColor:!0},t6.radioOff),R3.default.createElement(k,null," connecting…")):R3.default.createElement(k,null,h7("error",A)(t6.cross)," failed")),R3.default.createElement(u,null,R3.default.createElement(k,{bold:!0},"Command: "),R3.default.createElement(k,{dimColor:!0},q.config.command)),q.config.args&&q.config.args.length>0&&R3.default.createElement(u,null,R3.default.createElement(k,{bold:!0},"Args: "),R3.default.createElement(k,{dimColor:!0},q.config.args.join(" "))),R3.default.createElement(u,null,R3.default.createElement(k,{bold:!0},"Config location: "),R3.default.createElement(k,{dimColor:!0},xG(EN(q.name)?.scope??"dynamic"))),q.client.type==="connected"&&R3.default.createElement(eg8,{serverToolsCount:K,serverPromptsCount:W,serverResourcesCount:w.resources[q.name]?.length||0}),q.client.type==="connected"&&K>0&&R3.default.createElement(u,null,R3.default.createElement(k,{bold:!0},"Tools: "),R3.default.createElement(k,{dimColor:!0},K," tools"))),D.length>0&&R3.default.createElement(u,{marginTop:1},R3.default.createElement(H1,{options:D,onChange:async(f)=>{if(f==="tools")_();else if(f==="reconnectMcpServer"){M(!0);try{let G=await j(q.name),{message:Z}=qF8(G,q.name);Y?.(Z)}catch(G){Y?.(C78(G,q.name))}finally{M(!1)}}else if(f==="toggle-enabled")await X();else if(f==="back")z()},onCancel:z}))),R3.default.createElement(u,{marginTop:1},R3.default.createElement(k,{dimColor:!0,italic:!0},O.pending?R3.default.createElement(R3.default.Fragment,null,"Press ",O.keyName," again to exit"):R3.default.createElement(I1,null,R3.default.createElement(t8,{shortcut:"↑↓",action:"navigate"}),R3.default.createElement(t8,{shortcut:"Enter",action:"select"}),R3.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))))}var R3;var _F8=y(()=>{bq();z2();s6();f0();Z56();NJ();C7();y8();a5();d_();QK();rK();Q2();x47();R3=O6(D6(),1)});function x78(q){let K=z6(44),{tool:_,server:z,onBack:Y}=q,[$,A]=lO.default.useState(""),O,w;if(K[0]!==z.name||K[1]!==_){w=GA8(_.name,z.name);let g=_.userFacingName?_.userFacingName({}):w;O=TA8(g),K[0]=z.name,K[1]=_,K[2]=O,K[3]=w}else O=K[2],w=K[3];let j=O,H;if(K[4]!==_)H=_.isReadOnly?.({})??!1,K[4]=_,K[5]=H;else H=K[5];let J=H,M;if(K[6]!==_)M=_.isDestructive?.({})??!1,K[6]=_,K[7]=M;else M=K[7];let X=M,P;if(K[8]!==_)P=_.isOpenWorld?.({})??!1,K[8]=_,K[9]=P;else P=K[9];let W=P,D,f;if(K[10]!==_)D=()=>{(async function(){try{let U=await _.description({},{isNonInteractiveSession:!1,toolPermissionContext:{mode:"default",additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1},tools:[]});A(U)}catch{A("Failed to load description")}})()},f=[_],K[10]=_,K[11]=D,K[12]=f;else D=K[11],f=K[12];lO.default.useEffect(D,f);let G;if(K[13]!==J)G=J&&lO.default.createElement(k,{color:"success"}," [read-only]"),K[13]=J,K[14]=G;else G=K[14];let Z;if(K[15]!==X)Z=X&&lO.default.createElement(k,{color:"error"}," [destructive]"),K[15]=X,K[16]=Z;else Z=K[16];let T;if(K[17]!==W)T=W&&lO.default.createElement(k,{dimColor:!0}," [open-world]"),K[17]=W,K[18]=T;else T=K[18];let v;if(K[19]!==j||K[20]!==G||K[21]!==Z||K[22]!==T)v=lO.default.createElement(lO.default.Fragment,null,j,G,Z,T),K[19]=j,K[20]=G,K[21]=Z,K[22]=T,K[23]=v;else v=K[23];let V=v,E;if(K[24]===Symbol.for("react.memo_cache_sentinel"))E=lO.default.createElement(k,{bold:!0},"Tool name: "),K[24]=E;else E=K[24];let S;if(K[25]!==w)S=lO.default.createElement(u,null,E,lO.default.createElement(k,{dimColor:!0},w)),K[25]=w,K[26]=S;else S=K[26];let R;if(K[27]===Symbol.for("react.memo_cache_sentinel"))R=lO.default.createElement(k,{bold:!0},"Full name: "),K[27]=R;else R=K[27];let x;if(K[28]!==_.name)x=lO.default.createElement(u,null,R,lO.default.createElement(k,{dimColor:!0},_.name)),K[28]=_.name,K[29]=x;else x=K[29];let I;if(K[30]!==$)I=$&&lO.default.createElement(u,{flexDirection:"column",marginTop:1},lO.default.createElement(k,{bold:!0},"Description:"),lO.default.createElement(k,{wrap:"wrap"},$)),K[30]=$,K[31]=I;else I=K[31];let B;if(K[32]!==_.inputJSONSchema)B=_.inputJSONSchema&&_.inputJSONSchema.properties&&Object.keys(_.inputJSONSchema.properties).length>0&&lO.default.createElement(u,{flexDirection:"column",marginTop:1},lO.default.createElement(k,{bold:!0},"Parameters:"),lO.default.createElement(u,{marginLeft:2,flexDirection:"column"},Object.entries(_.inputJSONSchema.properties).map((g)=>{let[F,U]=g,K6=_.inputJSONSchema?.required?.includes(F);return lO.default.createElement(k,{key:F},"• ",F,K6&&lO.default.createElement(k,{dimColor:!0}," (required)"),":"," ",lO.default.createElement(k,{dimColor:!0},typeof U==="object"&&U&&"type"in U?String(U.type):"unknown"),typeof U==="object"&&U&&"description"in U&&lO.default.createElement(k,{dimColor:!0}," - ",String(U.description)))}))),K[32]=_.inputJSONSchema,K[33]=B;else B=K[33];let p;if(K[34]!==S||K[35]!==x||K[36]!==I||K[37]!==B)p=lO.default.createElement(u,{flexDirection:"column"},S,x,I,B),K[34]=S,K[35]=x,K[36]=I,K[37]=B,K[38]=p;else p=K[38];let C;if(K[39]!==Y||K[40]!==z.name||K[41]!==p||K[42]!==V)C=lO.default.createElement(R1,{title:V,subtitle:z.name,onCancel:Y,inputGuide:qMY},p),K[39]=Y,K[40]=z.name,K[41]=p,K[42]=V,K[43]=C;else C=K[43];return C}function qMY(q){return q.pending?lO.default.createElement(k,null,"Press ",q.keyName," again to exit"):lO.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"go back"})}var lO;var zF8=y(()=>{q8();s6();ok();a5();e4();lO=O6(D6(),1)});function I78(q){let K=z6(21),{server:_,onSelectTool:z,onBack:Y}=q,$=P8(_MY),A;q:{if(_.client.type!=="connected"){let f;if(K[0]===Symbol.for("react.memo_cache_sentinel"))f=[],K[0]=f;else f=K[0];A=f;break q}let D;if(K[1]!==$||K[2]!==_.name)D=EU($,_.name),K[1]=$,K[2]=_.name,K[3]=D;else D=K[3];A=D}let O=A,w;if(K[4]!==_.name||K[5]!==O){let D;if(K[7]!==_.name)D=(f,G)=>{let Z=GA8(f.name,_.name),T=f.userFacingName?f.userFacingName({}):Z,v=TA8(T),V=f.isReadOnly?.({})??!1,E=f.isDestructive?.({})??!1,S=f.isOpenWorld?.({})??!1,R=[];if(V)R.push("read-only");if(E)R.push("destructive");if(S)R.push("open-world");return{label:v,value:G.toString(),description:R.length>0?R.join(", "):void 0,descriptionColor:E?"error":V?"success":void 0}},K[7]=_.name,K[8]=D;else D=K[8];w=O.map(D),K[4]=_.name,K[5]=O,K[6]=w}else w=K[6];let j=w,H=`Tools for ${_.name}`,J=O.length,M;if(K[9]!==O.length)M=A7(O.length,"tool"),K[9]=O.length,K[10]=M;else M=K[10];let X=`${J} ${M}`,P;if(K[11]!==Y||K[12]!==z||K[13]!==O||K[14]!==j)P=O.length===0?Ks.default.createElement(k,{dimColor:!0},"No tools available"):Ks.default.createElement(H1,{options:j,onChange:(D)=>{let f=parseInt(D),G=O[f];if(G)z(G,f)},onCancel:Y}),K[11]=Y,K[12]=z,K[13]=O,K[14]=j,K[15]=P;else P=K[15];let W;if(K[16]!==Y||K[17]!==H||K[18]!==X||K[19]!==P)W=Ks.default.createElement(R1,{title:H,subtitle:X,onCancel:Y,inputGuide:KMY},P),K[16]=Y,K[17]=H,K[18]=X,K[19]=P,K[20]=W;else W=K[20];return W}function KMY(q){return q.pending?Ks.default.createElement(k,null,"Press ",q.keyName," again to exit"):Ks.default.createElement(I1,null,Ks.default.createElement(t8,{shortcut:"↑↓",action:"navigate"}),Ks.default.createElement(t8,{shortcut:"Enter",action:"select"}),Ks.default.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"}))}function _MY(q){return q.mcp.tools}var Ks;var YF8=y(()=>{q8();s6();ok();NJ();C7();a5();d_();QK();e4();rK();Ks=O6(D6(),1)});function $F8(q){let K=z6(66),{onComplete:_}=q,z=P8(AMY),Y=P8($MY),$=z.clients,A;if(K[0]===Symbol.for("react.memo_cache_sentinel"))A={type:"list"},K[0]=A;else A=K[0];let[O,w]=Fb.default.useState(A),j;if(K[1]===Symbol.for("react.memo_cache_sentinel"))j=[],K[1]=j;else j=K[1];let[H,J]=Fb.default.useState(j),M;if(K[2]!==Y.allAgents)M=ER4(Y.allAgents),K[2]=Y.allAgents,K[3]=M;else M=K[3];let X=M,P;if(K[4]!==$)P=$.filter(YMY).sort(zMY),K[4]=$,K[5]=P;else P=K[5];let W=P,D,f;if(K[6]!==W||K[7]!==z.tools)D=()=>{let T=!1;return async function(){let E=await Promise.all(W.map(async(S)=>{let R=S.config.scope,x=S.config.type==="sse",I=S.config.type==="http",B=S.config.type==="claudeai-proxy",p=void 0;if(x||I){let F=await new Sw6(S.name,S.config).tokens(),U=WD()!==null&&S.type==="connected",c=S.type==="connected"&&EU(z.tools,S.name).length>0;p=Boolean(F)||U||c}let C={name:S.name,client:S,scope:R};if(B)return{...C,transport:"claudeai-proxy",isAuthenticated:!1,config:S.config};else if(x)return{...C,transport:"sse",isAuthenticated:p,config:S.config};else if(I)return{...C,transport:"http",isAuthenticated:p,config:S.config};else return{...C,transport:"stdio",config:S.config}}));if(T)return;J(E)}(),()=>{T=!0}},f=[W,z.tools],K[6]=W,K[7]=z.tools,K[8]=D,K[9]=f;else D=K[8],f=K[9];Fb.default.useEffect(D,f);let G,Z;if(K[10]!==X.length||K[11]!==W.length||K[12]!==_||K[13]!==H.length)G=()=>{if(H.length===0&&W.length>0)return;if(H.length===0&&X.length===0)_("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.claude.com/docs/en/mcp to learn more.")},Z=[H.length,W.length,X.length,_],K[10]=X.length,K[11]=W.length,K[12]=_,K[13]=H.length,K[14]=G,K[15]=Z;else G=K[14],Z=K[15];switch(Fb.useEffect(G,Z),O.type){case"list":{let T,v;if(K[16]===Symbol.for("react.memo_cache_sentinel"))v=(E)=>w({type:"server-menu",server:E}),T=(E)=>w({type:"agent-server-menu",agentServer:E}),K[16]=T,K[17]=v;else T=K[16],v=K[17];let V;if(K[18]!==X||K[19]!==_||K[20]!==H||K[21]!==O.defaultTab)V=Fb.default.createElement(V47,{servers:H,agentServers:X,onSelectServer:v,onSelectAgentServer:T,onComplete:_,defaultTab:O.defaultTab}),K[18]=X,K[19]=_,K[20]=H,K[21]=O.defaultTab,K[22]=V;else V=K[22];return V}case"server-menu":{let T;if(K[23]!==z.tools||K[24]!==O.server.name)T=EU(z.tools,O.server.name),K[23]=z.tools,K[24]=O.server.name,K[25]=T;else T=K[25];let v=T,V=O.server.transport==="claudeai-proxy"?"claude.ai":"Claude Code";if(O.server.transport==="stdio"){let E;if(K[26]!==O.server)E=()=>w({type:"server-tools",server:O.server}),K[26]=O.server,K[27]=E;else E=K[27];let S;if(K[28]!==V)S=()=>w({type:"list",defaultTab:V}),K[28]=V,K[29]=S;else S=K[29];let R;if(K[30]!==_||K[31]!==v.length||K[32]!==E||K[33]!==S||K[34]!==O.server)R=Fb.default.createElement(b78,{server:O.server,serverToolsCount:v.length,onViewTools:E,onCancel:S,onComplete:_}),K[30]=_,K[31]=v.length,K[32]=E,K[33]=S,K[34]=O.server,K[35]=R;else R=K[35];return R}else{let E;if(K[36]!==O.server)E=()=>w({type:"server-tools",server:O.server}),K[36]=O.server,K[37]=E;else E=K[37];let S;if(K[38]!==V)S=()=>w({type:"list",defaultTab:V}),K[38]=V,K[39]=S;else S=K[39];let R;if(K[40]!==_||K[41]!==v.length||K[42]!==E||K[43]!==S||K[44]!==O.server)R=Fb.default.createElement(lH6,{server:O.server,serverToolsCount:v.length,onViewTools:E,onCancel:S,onComplete:_}),K[40]=_,K[41]=v.length,K[42]=E,K[43]=S,K[44]=O.server,K[45]=R;else R=K[45];return R}}case"server-tools":{let T,v;if(K[46]!==O.server)v=(E,S)=>w({type:"server-tool-detail",server:O.server,toolIndex:S}),T=()=>w({type:"server-menu",server:O.server}),K[46]=O.server,K[47]=T,K[48]=v;else T=K[47],v=K[48];let V;if(K[49]!==T||K[50]!==v||K[51]!==O.server)V=Fb.default.createElement(I78,{server:O.server,onSelectTool:v,onBack:T}),K[49]=T,K[50]=v,K[51]=O.server,K[52]=V;else V=K[52];return V}case"server-tool-detail":{let T;if(K[53]!==z.tools||K[54]!==O.server.name)T=EU(z.tools,O.server.name),K[53]=z.tools,K[54]=O.server.name,K[55]=T;else T=K[55];let V=T[O.toolIndex];if(!V)return w({type:"server-tools",server:O.server}),null;let E;if(K[56]!==O.server)E=()=>w({type:"server-tools",server:O.server}),K[56]=O.server,K[57]=E;else E=K[57];let S;if(K[58]!==E||K[59]!==V||K[60]!==O.server)S=Fb.default.createElement(x78,{tool:V,server:O.server,onBack:E}),K[58]=E,K[59]=V,K[60]=O.server,K[61]=S;else S=K[61];return S}case"agent-server-menu":{let T;if(K[62]===Symbol.for("react.memo_cache_sentinel"))T=()=>w({type:"list",defaultTab:"Agents"}),K[62]=T;else T=K[62];let v;if(K[63]!==_||K[64]!==O.agentServer)v=Fb.default.createElement(v47,{agentServer:O.agentServer,onCancel:T,onComplete:_}),K[63]=_,K[64]=O.agentServer,K[65]=v;else v=K[65];return v}}}function zMY(q,K){return q.name.localeCompare(K.name)}function YMY(q){return q.name!=="ide"}function $MY(q){return q.agentDefinitions}function AMY(q){return q.mcp}var Fb;var eNK=y(()=>{q8();or();NJ();C7();nC();k47();N47();KF8();_F8();zF8();YF8();Fb=O6(D6(),1)});var qyK=y(()=>{k47();N47();b47();KF8();eNK();_F8();zF8();YF8()});var _yK={};T8(_yK,{settingSourceToScope:()=>HMY,isPersistableScope:()=>jMY,installSelectedPlugins:()=>I47,getPluginEditableScopes:()=>G56,getInstalledPlugins:()=>KyK,findMissingPlugins:()=>JMY,checkEnabledPlugins:()=>wMY});import{join as OMY}from"path";async function wMY(){let q=N7(),K=[],_=uA6();for(let[z,Y]of Object.entries(_))if(z.includes("@")&&Y)K.push(z);if(q.enabledPlugins)for(let[z,Y]of Object.entries(q.enabledPlugins)){if(!z.includes("@"))continue;let $=K.indexOf(z);if(Y){if($===-1)K.push(z)}else if($!==-1)K.splice($,1)}return K}function G56(){let q=new Map,K=uA6();for(let[z,Y]of Object.entries(K)){if(!z.includes("@"))continue;if(Y===!0)q.set(z,"flag");else if(Y===!1)q.delete(z)}let _=[{scope:"managed",source:"policySettings"},{scope:"user",source:"userSettings"},{scope:"project",source:"projectSettings"},{scope:"local",source:"localSettings"},{scope:"flag",source:"flagSettings"}];for(let{scope:z,source:Y}of _){let $=v1(Y);if(!$?.enabledPlugins)continue;for(let[A,O]of Object.entries($.enabledPlugins)){if(!A.includes("@"))continue;if(A in K&&K[A]!==O)N(`Plugin ${A} from --add-dir (${K[A]}) overridden by ${Y} (${O})`);if(O===!0)q.set(A,z);else if(O===!1)q.delete(A)}}return N(`Found ${q.size} enabled plugins with scopes: ${Array.from(q.entries()).map(([z,Y])=>`${z}(${Y})`).join(", ")}`),q}function jMY(q){return q!=="flag"}function HMY(q){return yh1[q]}async function KyK(){l17().catch((_)=>{H6(_)});let q=g18(),K=Object.keys(q.plugins);return N(`Found ${K.length} installed plugins`),K}async function JMY(q){try{let K=await KyK(),_=q.filter(($)=>!K.includes($));return(await Promise.all(_.map(async($)=>{try{let A=await aG($);return{pluginId:$,found:A!==null&&A!==void 0}}catch(A){return N(`Failed to check plugin ${$} in marketplace: ${A}`),{pluginId:$,found:!1}}}))).filter(({found:$})=>$).map(({pluginId:$})=>$)}catch(K){return H6(K),[]}}async function I47(q,K,_="user"){let z=_!=="user"?Z8():void 0,Y=hF(_),$=v1(Y),A={...$?.enabledPlugins},O=[],w=[];for(let j=0;j<q.length;j++){let H=q[j];if(!H)continue;if(K)K(H,j+1,q.length);try{let J=await aG(H);if(!J){w.push({name:H,error:"Plugin not found in any marketplace"});continue}let{entry:M,marketplaceInstallLocation:X}=J;if(!Gp6(M.source))await U18(H,M,_,z);else w0K({pluginId:H,installPath:OMY(X,M.source),version:M.version},_,z);A[H]=!0,O.push(H)}catch(J){let M=J instanceof Error?J.message:String(J);w.push({name:H,error:M}),H6(J)}}return W7(Y,{...$,enabledPlugins:A}),{installed:O,failed:w}}var nh6=y(()=>{I7();_8();E8();U1();UG8();pX();Nw();hP();_56();BZ()});import{homedir as MMY}from"os";import{resolve as XMY}from"path";async function AF8(q){let K=q.trim(),_=X8(),z=K.match(/^([a-zA-Z0-9._-]+@[^:]+:.+?(?:\.git)?)(#(.+))?$/);if(z?.[1]){let A=z[1],O=z[3];return O?{source:"git",url:A,ref:O}:{source:"git",url:A}}if(K.startsWith("http://")||K.startsWith("https://")){let A=K.match(/^([^#]+)(#(.+))?$/),O=A?.[1]||K,w=A?.[3];if(O.endsWith(".git")||O.includes("/_git/"))return w?{source:"git",url:O,ref:w}:{source:"git",url:O};let j;try{j=new URL(O)}catch(H){return{source:"url",url:O}}if(j.hostname==="github.com"||j.hostname==="www.github.com"){if(j.pathname.match(/^\/([^/]+\/[^/]+?)(\/|\.git|$)/)?.[1]){let J=O.endsWith(".git")?O:`${O}.git`;return w?{source:"git",url:J,ref:w}:{source:"git",url:J}}}return{source:"url",url:O}}let $=process.platform==="win32"&&(K.startsWith(".\\")||K.startsWith("..\\")||/^[a-zA-Z]:[/\\]/.test(K));if(K.startsWith("./")||K.startsWith("../")||K.startsWith("/")||K.startsWith("~")||$){let A=XMY(K.startsWith("~")?K.replace(/^~/,MMY()):K),O;try{O=await _.stat(A)}catch(w){let j=s1(w);return{error:j==="ENOENT"?`Path does not exist: ${A}`:`Cannot access path: ${A} (${j??w})`}}if(O.isFile())if(A.endsWith(".json"))return{source:"file",path:A};else return{error:`File path must point to a .json file (marketplace.json), but got: ${A}`};else if(O.isDirectory())return{source:"directory",path:A};else return{error:`Path is neither a file nor a directory: ${A}`}}if(K.includes("/")&&!K.startsWith("@")){if(K.includes(":"))return null;let A=K.match(/^([^#@]+)(?:[#@](.+))?$/),O=A?.[1]||K,w=A?.[2];return w?{source:"github",repo:O,ref:w}:{source:"github",repo:O}}return null}var u47=y(()=>{y8();e7()});function zyK({inputValue:q,setInputValue:K,cursorOffset:_,setCursorOffset:z,error:Y,setError:$,result:A,setResult:O,setViewState:w,onAddComplete:j,cliMode:H=!1}){let J=nH6.useRef(!1),[M,X]=nH6.useState(!1),[P,W]=nH6.useState(""),D=async()=>{let f=q.trim();if(!f){$("Please enter a marketplace source");return}let G=await AF8(f);if(!G){$("Invalid marketplace source format. Try: owner/repo, https://..., or ./path");return}if("error"in G){$(G.error);return}$(null);try{X(!0),W("");let{name:Z,resolvedSource:T}=await Yd(G,(V)=>{W(V)});I18(Z,{source:T}),Sz();let v=G.source;if(G.source==="github")v=G.repo;if(d("tengu_marketplace_added",{source_type:v}),j)await j();if(W(""),X(!1),H)O(`Successfully added marketplace: ${Z}`);else w({type:"browse-marketplace",targetMarketplace:Z})}catch(Z){let T=x1(Z);if(H6(T),$(T.message),W(""),X(!1),H)O(`Error: ${T.message}`);else O(null)}};return nH6.useEffect(()=>{if(q&&!J.current&&!Y&&!A)J.current=!0,D()},[]),s5.createElement(u,{flexDirection:"column"},s5.createElement(u,{flexDirection:"column",paddingX:1,borderStyle:"round"},s5.createElement(u,{marginBottom:1},s5.createElement(k,{bold:!0},"Add Marketplace")),s5.createElement(u,{flexDirection:"column"},s5.createElement(k,null,"Enter marketplace source:"),s5.createElement(k,{dimColor:!0},"Examples:"),s5.createElement(k,{dimColor:!0}," · owner/repo (GitHub)"),s5.createElement(k,{dimColor:!0}," · git@github.com:owner/repo.git (SSH)"),s5.createElement(k,{dimColor:!0}," · https://example.com/marketplace.json"),s5.createElement(k,{dimColor:!0}," · ./path/to/marketplace"),s5.createElement(u,{marginTop:1},s5.createElement(r3,{value:q,onChange:K,onSubmit:D,columns:80,cursorOffset:_,onChangeCursorOffset:z,focus:!0,showCursor:!0}))),M&&s5.createElement(u,{marginTop:1},s5.createElement(IK,null),s5.createElement(k,null,P||"Adding marketplace to configuration…")),Y&&s5.createElement(u,{marginTop:1},s5.createElement(k,{color:"error"},Y)),A&&s5.createElement(u,{marginTop:1},s5.createElement(k,null,A))),s5.createElement(u,{marginLeft:3},s5.createElement(k,{dimColor:!0,italic:!0},s5.createElement(I1,null,s5.createElement(t8,{shortcut:"Enter",action:"add"}),s5.createElement(W1,{action:"confirm:no",context:"Settings",fallback:"Esc",description:"cancel"})))))}var s5,nH6;var YyK=y(()=>{k8();a5();QK();rK();Q2();CH();s6();y8();E8();Jy();Nw();u47();s5=O6(D6(),1),nH6=O6(D6(),1)});import{randomBytes as PMY}from"crypto";import{readFile as WMY,rename as DMY,unlink as fMY,writeFile as ZMY}from"fs/promises";import{join as GMY}from"path";function $yK(){return GMY(GX(),TMY)}async function kMY(){let q=$yK();try{let K=await WMY(q,{encoding:"utf-8"}),_=r8(K);if(typeof _!=="object"||_===null||!("version"in _)||!("fetchedAt"in _)||!("counts"in _))return N("Install counts cache has invalid structure"),null;let z=_;if(z.version!==m47)return N(`Install counts cache version mismatch (got ${z.version}, expected ${m47})`),null;if(typeof z.fetchedAt!=="string"||!Array.isArray(z.counts))return N("Install counts cache has invalid structure"),null;let Y=new Date(z.fetchedAt).getTime();if(Number.isNaN(Y))return N("Install counts cache has invalid fetchedAt timestamp"),null;if(!z.counts.every((O)=>typeof O==="object"&&O!==null&&typeof O.plugin==="string"&&typeof O.unique_installs==="number"))return N("Install counts cache has malformed entries"),null;if(Date.now()-Y>vMY)return N("Install counts cache is stale (>24h old)"),null;return{version:z.version,fetchedAt:z.fetchedAt,counts:z.counts}}catch(K){if(s1(K)!=="ENOENT")N(`Failed to load install counts cache: ${d6(K)}`);return null}}async function VMY(q){let K=$yK(),_=`${K}.${PMY(8).toString("hex")}.tmp`;try{let z=GX();await X8().mkdir(z);let Y=g6(q,null,2);await ZMY(_,Y,{encoding:"utf-8",mode:384}),await DMY(_,K),N("Install counts cache saved successfully")}catch(z){H6(z);try{await fMY(_)}catch{}}}async function NMY(){N(`Fetching install counts from ${u78}`);let q=performance.now();try{let K=await $1.get(u78,{timeout:1e4});if(!K.data?.plugins||!Array.isArray(K.data.plugins))throw Error("Invalid response format from install counts API");return KD("install_counts",u78,"success",performance.now()-q),K.data.plugins}catch(K){throw KD("install_counts",u78,"failure",performance.now()-q,zC(K)),K}}async function ih6(){let q=await kMY();if(q){N("Using cached install counts"),KD("install_counts",u78,"cache_hit",0);let K=new Map;for(let _ of q.counts)K.set(_.plugin,_.unique_installs);return K}try{let K=await NMY(),_={version:m47,fetchedAt:new Date().toISOString(),counts:K};await VMY(_);let z=new Map;for(let Y of K)z.set(Y.plugin,Y.unique_installs);return z}catch(K){return H6(K),N(`Failed to fetch install counts: ${d6(K)}`),null}}function OF8(q){if(q<1000)return String(q);if(q<1e6){let Y=(q/1000).toFixed(1);return Y.endsWith(".0")?`${Y.slice(0,-2)}K`:`${Y}K`}let _=(q/1e6).toFixed(1);return _.endsWith(".0")?`${_.slice(0,-2)}M`:`${_}M`}var m47=1,TMY="install-counts-cache.json",u78="https://raw.githubusercontent.com/anthropics/claude-plugins-official/refs/heads/stats/stats/plugin-installs.json",vMY=86400000;var wF8=y(()=>{CK();_8();y8();e7();E8();l8();kn6();aV()});function yMY(q,K,_,z){let Y={};for(let $ of q){let A=_[$],O=K[$]??"";if(A?.sensitive===!0&&O===""&&z?.[$]!==void 0)continue;if(A?.type==="number"){if(O.trim()==="")continue;let w=Number(O);Y[$]=Number.isNaN(w)?O:w}else if(A?.type==="boolean")Y[$]=i6(O);else Y[$]=O}return Y}function m78(q){let K=z6(70),{title:_,subtitle:z,configSchema:Y,initialValues:$,onSave:A,onCancel:O}=q,w;if(K[0]!==Y)w=Object.keys(Y),K[0]=Y,K[1]=w;else w=K[1];let j=w,H;if(K[2]!==Y||K[3]!==$)H=(l)=>{if(Y[l]?.sensitive===!0)return"";let A6=$?.[l];return A6===void 0?"":String(A6)},K[2]=Y,K[3]=$,K[4]=H;else H=K[4];let J=H,[M,X]=cD.useState(0),P;if(K[5]===Symbol.for("react.memo_cache_sentinel"))P={},K[5]=P;else P=K[5];let[W,D]=cD.useState(P),f;if(K[6]!==j[0]||K[7]!==J)f=()=>j[0]?J(j[0]):"",K[6]=j[0],K[7]=J,K[8]=f;else f=K[8];let[G,Z]=cD.useState(f),T=j[M],v=T?Y[T]:null,V;if(K[9]===Symbol.for("react.memo_cache_sentinel"))V={context:"Settings"},K[9]=V;else V=K[9];P1("confirm:no",O,V);let E;if(K[10]!==T||K[11]!==M||K[12]!==G||K[13]!==j||K[14]!==J)E=()=>{if(M<j.length-1&&T){D((A6)=>({...A6,[T]:G})),X(RMY);let l=j[M+1];Z(l?J(l):"")}},K[10]=T,K[11]=M,K[12]=G,K[13]=j,K[14]=J,K[15]=E;else E=K[15];let S=E,R;if(K[16]!==Y||K[17]!==T||K[18]!==M||K[19]!==G||K[20]!==j||K[21]!==J||K[22]!==$||K[23]!==A||K[24]!==W)R=()=>{if(!T)return;let l={...W,[T]:G};if(M===j.length-1)A(yMY(j,l,Y,$));else{D(l),X(LMY);let A6=j[M+1];Z(A6?J(A6):"")}},K[16]=Y,K[17]=T,K[18]=M,K[19]=G,K[20]=j,K[21]=J,K[22]=$,K[23]=A,K[24]=W,K[25]=R;else R=K[25];let x=R,I;if(K[26]!==x||K[27]!==S)I={"confirm:nextField":S,"confirm:yes":x},K[26]=x,K[27]=S,K[28]=I;else I=K[28];let B;if(K[29]===Symbol.for("react.memo_cache_sentinel"))B={context:"Confirmation"},K[29]=B;else B=K[29];o7(I,B);let p;if(K[30]===Symbol.for("react.memo_cache_sentinel"))p=(l,A6)=>{if(A6.backspace||A6.delete){Z(EMY);return}if(l&&!A6.ctrl&&!A6.meta&&!A6.tab&&!A6.return)Z((J6)=>J6+l)},K[30]=p;else p=K[30];if(k4(p),!v||!T)return null;let C=v.sensitive===!0,g=v.required===!0,F;if(K[31]!==G||K[32]!==C)F=C?"*".repeat(O1(G)):G,K[31]=G,K[32]=C,K[33]=F;else F=K[33];let U=F,c=v.title||T,K6;if(K[34]!==g)K6=g&&cD.default.createElement(k,{color:"error"}," *"),K[34]=g,K[35]=K6;else K6=K[35];let t;if(K[36]!==c||K[37]!==K6)t=cD.default.createElement(k,{bold:!0},c,K6),K[36]=c,K[37]=K6,K[38]=t;else t=K[38];let q6;if(K[39]!==v.description)q6=v.description&&cD.default.createElement(k,{dimColor:!0},v.description),K[39]=v.description,K[40]=q6;else q6=K[40];let e;if(K[41]===Symbol.for("react.memo_cache_sentinel"))e=cD.default.createElement(k,null,t6.pointerSmall," "),K[41]=e;else e=K[41];let i;if(K[42]!==U)i=cD.default.createElement(k,null,U),K[42]=U,K[43]=i;else i=K[43];let $6;if(K[44]===Symbol.for("react.memo_cache_sentinel"))$6=cD.default.createElement(k,null,"█"),K[44]=$6;else $6=K[44];let M6;if(K[45]!==i)M6=cD.default.createElement(u,{marginTop:1},e,i,$6),K[45]=i,K[46]=M6;else M6=K[46];let j6;if(K[47]!==t||K[48]!==q6||K[49]!==M6)j6=cD.default.createElement(u,{flexDirection:"column"},t,q6,M6),K[47]=t,K[48]=q6,K[49]=M6,K[50]=j6;else j6=K[50];let G6=M+1,w6;if(K[51]!==j.length||K[52]!==G6)w6=cD.default.createElement(k,{dimColor:!0},"Field ",G6," of ",j.length),K[51]=j.length,K[52]=G6,K[53]=w6;else w6=K[53];let o;if(K[54]!==M||K[55]!==j.length)o=M<j.length-1&&cD.default.createElement(k,{dimColor:!0},"Tab: Next field · Enter: Save and continue"),K[54]=M,K[55]=j.length,K[56]=o;else o=K[56];let s;if(K[57]!==M||K[58]!==j.length)s=M===j.length-1&&cD.default.createElement(k,{dimColor:!0},"Enter: Save configuration"),K[57]=M,K[58]=j.length,K[59]=s;else s=K[59];let a;if(K[60]!==w6||K[61]!==o||K[62]!==s)a=cD.default.createElement(u,{flexDirection:"column"},w6,o,s),K[60]=w6,K[61]=o,K[62]=s,K[63]=a;else a=K[63];let n;if(K[64]!==O||K[65]!==z||K[66]!==j6||K[67]!==a||K[68]!==_)n=cD.default.createElement(R1,{title:_,subtitle:z,onCancel:O,isCancelActive:!1},j6,a),K[64]=O,K[65]=z,K[66]=j6,K[67]=a,K[68]=_,K[69]=n;else n=K[69];return n}function EMY(q){return q.slice(0,-1)}function LMY(q){return q+1}function RMY(q){return q+1}var cD;var p47=y(()=>{q8();bq();e4();Q5();s6();Oq();m8();cD=O6(D6(),1)});async function jF8(q){let{enabled:K,disabled:_}=await LM();return[...K,..._].find((z)=>z.repository===q||z.source===q)}function rh6({plugin:q,pluginId:K,onDone:_}){let[z]=Zd.useState(()=>{let j=[],H=b24(q);if(Object.keys(H).length>0)j.push({key:"top-level",title:`Configure ${q.name}`,subtitle:"Plugin options",schema:H,load:()=>VG(K),save:(M)=>$k8(K,M,q.manifest.userConfig)});let J=MR4(q);for(let M of J)j.push({key:`channel:${M.server}`,title:`Configure ${M.displayName}`,subtitle:`Plugin: ${q.name}`,schema:M.configSchema,load:()=>TO6(K,M.server)??void 0,save:(X)=>zk8(K,M.server,X,M.configSchema)});return j}),[Y,$]=Zd.useState(0),A=Zd.useRef(_);if(A.current=_,Zd.useEffect(()=>{if(z.length===0)A.current("skipped")},[z.length]),z.length===0)return null;let O=z[Y];function w(j){try{O.save(j)}catch(J){_("error",d6(J));return}let H=Y+1;if(H<z.length)$(H);else _("configured")}return Zd.createElement(m78,{key:O.key,title:O.title,subtitle:O.subtitle,configSchema:O.schema,initialValues:O.load(),onSave:w,onCancel:()=>_("skipped")})}var Zd;var HF8=y(()=>{y8();gi6();AN6();bj();mu();p47();Zd=O6(D6(),1)});function JF8(){let q=z6(3),K;if(q[0]===Symbol.for("react.memo_cache_sentinel"))K=gfK(),q[0]=K;else K=q[0];let _=K,z;if(q[1]===Symbol.for("react.memo_cache_sentinel"))z=iH6.createElement(k,{color:"claude"},t6.warning," "),q[1]=z;else z=q[1];let Y;if(q[2]===Symbol.for("react.memo_cache_sentinel"))Y=iH6.createElement(u,{marginBottom:1},z,iH6.createElement(k,{dimColor:!0,italic:!0},"Make sure you trust a plugin before installing, updating, or using it. Anthropic does 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.",_?` ${_}`:"")),q[2]=Y;else Y=q[2];return Y}var iH6;var B47=y(()=>{q8();bq();s6();qd();iH6=O6(D6(),1)});function T56(q){if(q.entry.source&&typeof q.entry.source==="object"&&"source"in q.entry.source&&q.entry.source.source==="github"&&typeof q.entry.source==="object"&&"repo"in q.entry.source)return q.entry.source.repo;return null}function oh6(q,K){let _=[{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"}];if(q)_.push({label:"Open homepage",action:"homepage"});if(K)_.push({label:"View on GitHub",action:"github"});return _.push({label:"Back to plugin list",action:"back"}),_}function AyK(q){let K=z6(7),{hasSelection:_}=q,z;if(K[0]!==_)z=_&&wk.createElement(W1,{action:"plugin:install",context:"Plugin",fallback:"i",description:"install",bold:!0}),K[0]=_,K[1]=z;else z=K[1];let Y,$,A;if(K[2]===Symbol.for("react.memo_cache_sentinel"))Y=wk.createElement(W1,{action:"plugin:toggle",context:"Plugin",fallback:"Space",description:"toggle"}),$=wk.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"details"}),A=wk.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"}),K[2]=Y,K[3]=$,K[4]=A;else Y=K[2],$=K[3],A=K[4];let O;if(K[5]!==z)O=wk.createElement(u,{marginTop:1},wk.createElement(k,{dimColor:!0,italic:!0},wk.createElement(I1,null,z,Y,$,A))),K[5]=z,K[6]=O;else O=K[6];return O}var wk;var g47=y(()=>{q8();a5();QK();s6();wk=O6(D6(),1)});function ah6({totalItems:q,maxVisible:K=hMY,selectedIndex:_=0}){let z=q>K,Y=fR.useRef(0),$=fR.useMemo(()=>{if(!z)return 0;let G=Y.current;if(_<G)return Y.current=_,_;if(_>=G+K){let v=_-K+1;return Y.current=v,v}let Z=Math.max(0,q-K),T=Math.min(G,Z);return Y.current=T,T},[_,K,z,q]),A=$,O=Math.min($+K,q),w=fR.useCallback((G)=>{if(!z)return G;return G.slice(A,O)},[z,A,O]),j=fR.useCallback((G)=>{return A+G},[A]),H=fR.useCallback((G)=>{return G>=A&&G<O},[A,O]),J=fR.useCallback((G)=>{},[]),M=fR.useCallback(()=>{},[]),X=fR.useCallback(()=>{},[]),P=fR.useCallback((G,Z)=>{let T=Math.max(0,Math.min(G,q-1));Z(T)},[q]),W=fR.useCallback((G,Z)=>{return!1},[]),D=Math.max(1,Math.ceil(q/K));return{currentPage:Math.floor($/K),totalPages:D,startIndex:A,endIndex:O,needsPagination:z,pageSize:K,getVisibleItems:w,toActualIndex:j,isOnCurrentPage:H,goToPage:J,nextPage:M,prevPage:X,handleSelectionChange:P,handlePageNavigation:W,scrollPosition:{current:_+1,total:q,canScrollUp:$>0,canScrollDown:$+K<q}}}var fR,hMY=5;var MF8=y(()=>{fR=O6(D6(),1)});function OyK({error:q,setError:K,result:_,setResult:z,setViewState:Y,onInstallComplete:$,targetMarketplace:A,targetPlugin:O}){let[w,j]=_W.useState("marketplace-list"),[H,J]=_W.useState(null),[M,X]=_W.useState(null),[P,W]=_W.useState([]),[D,f]=_W.useState([]),[G,Z]=_W.useState(!0),[T,v]=_W.useState(null),[V,E]=_W.useState(0),[S,R]=_W.useState(new Set),[x,I]=_W.useState(new Set),B=ah6({totalItems:D.length,selectedIndex:V}),[p,C]=_W.useState(0),[g,F]=_W.useState(!1),[U,c]=_W.useState(null),[K6,t]=_W.useState(null),q6=w1.useCallback(()=>{if(w==="plugin-list")if(A)Y({type:"manage-marketplaces",targetMarketplace:A});else if(P.length===1)Y({type:"menu"});else j("marketplace-list"),J(null),R(new Set);else if(w==="plugin-details")j("plugin-list"),X(null);else Y({type:"menu"})},[w,A,Y,P.length]);P1("confirm:no",q6,{context:"Confirmation"}),_W.useEffect(()=>{async function j6(){try{let G6=await r_(),{marketplaces:w6,failures:o}=await Xp(G6),s=[];for(let{name:l,config:A6,data:J6}of w6)if(J6){let X6=$7(J6.plugins,(f6)=>Zb(eQ(f6.name,l)));s.push({name:l,totalPlugins:J6.plugins.length,installedCount:X6,source:h18(A6.source)})}s.sort((l,A6)=>{if(l.name==="claude-plugin-directory")return-1;if(A6.name==="claude-plugin-directory")return 1;return 0}),W(s);let a=$7(w6,(l)=>l.data!==null),n=Jh6(o,a);if(n)if(n.type==="warning")t(n.message+". Showing available marketplaces.");else throw Error(n.message);if(s.length===1&&!A&&!O){let l=s[0];if(l)J(l.name),j("plugin-list")}if(O){let l=null,A6=null;for(let[J6]of Object.entries(G6)){let X6=await r0(J6);if(X6){let f6=X6.plugins.find((N6)=>N6.name===O);if(f6){let N6=eQ(f6.name,J6);l={entry:f6,marketplaceName:J6,pluginId:N6,isInstalled:Xh6(N6)},A6=J6;break}}}if(l&&A6){let J6=l.pluginId;if(Xh6(J6))K(`Plugin '${J6}' is already installed globally. Use '/plugin' to manage existing plugins.`);else J(A6),X(l),j("plugin-details")}else K(`Plugin "${O}" not found in any marketplace`)}else if(A)if(s.some((A6)=>A6.name===A))J(A),j("plugin-list");else K(`Marketplace "${A}" not found`)}catch(G6){K(G6 instanceof Error?G6.message:"Failed to load marketplaces")}finally{Z(!1)}}j6()},[K,A,O]),_W.useEffect(()=>{if(!H)return;let j6=!1;async function G6(w6){Z(!0);try{let o=await r0(w6);if(j6)return;if(!o)throw Error(`Failed to load marketplace: ${w6}`);let s=[];for(let a of o.plugins){let n=eQ(a.name,w6);if(zR(n))continue;s.push({entry:a,marketplaceName:w6,pluginId:n,isInstalled:Xh6(n)})}try{let a=await ih6();if(j6)return;if(v(a),a)s.sort((n,l)=>{let A6=a.get(n.pluginId)??0,J6=a.get(l.pluginId)??0;if(A6!==J6)return J6-A6;return n.entry.name.localeCompare(l.entry.name)});else s.sort((n,l)=>n.entry.name.localeCompare(l.entry.name))}catch(a){if(j6)return;N(`Failed to fetch install counts: ${d6(a)}`),s.sort((n,l)=>n.entry.name.localeCompare(l.entry.name))}f(s),E(0),R(new Set)}catch(o){if(j6)return;K(o instanceof Error?o.message:"Failed to load plugins")}finally{Z(!1)}}return G6(H),()=>{j6=!0}},[H,K]);let e=async()=>{if(S.size===0)return;let j6=D.filter((s)=>S.has(s.pluginId));I(new Set(j6.map((s)=>s.pluginId)));let G6=0,w6=0,o=[];for(let s of j6){let a=await K56({pluginId:s.pluginId,entry:s.entry,marketplaceName:s.marketplaceName,scope:"user"});if(a.success)G6++;else w6++,o.push({name:s.entry.name,reason:a.error})}if(I(new Set),R(new Set),Sz(),w6===0){let s=`✓ Installed ${G6} ${A7(G6,"plugin")}. Run /reload-plugins to activate.`;z(s)}else if(G6===0)K(`Failed to install: ${Hh6(o,!0)}`);else{let s=`✓ Installed ${G6} of ${G6+w6} plugins. Failed: ${Hh6(o,!1)}. Run /reload-plugins to activate successfully installed plugins.`;z(s)}if(G6>0){if($)await $()}Y({type:"menu"})},i=async(j6,G6="user")=>{F(!0),c(null);let w6=await K56({pluginId:j6.pluginId,entry:j6.entry,marketplaceName:j6.marketplaceName,scope:G6});if(w6.success){let o=await jF8(j6.pluginId);if(o){F(!1),j({type:"plugin-options",plugin:o,pluginId:j6.pluginId});return}if(z(w6.message),$)await $();Y({type:"menu"})}else F(!1),c(w6.error)};_W.useEffect(()=>{if(q)z(q)},[q,z]),o7({"select:previous":()=>{if(V>0)E(V-1)},"select:next":()=>{if(V<P.length-1)E(V+1)},"select:accept":()=>{let j6=P[V];if(j6)J(j6.name),j("plugin-list")}},{context:"Select",isActive:w==="marketplace-list"}),o7({"select:previous":()=>{if(V>0)B.handleSelectionChange(V-1,E)},"select:next":()=>{if(V<D.length-1)B.handleSelectionChange(V+1,E)},"select:accept":()=>{if(V===D.length&&S.size>0)e();else if(V<D.length){let j6=D[V];if(j6)if(j6.isInstalled)Y({type:"manage-plugins",targetPlugin:j6.entry.name,targetMarketplace:j6.marketplaceName});else X(j6),j("plugin-details"),C(0),c(null)}}},{context:"Select",isActive:w==="plugin-list"}),o7({"plugin:toggle":()=>{if(V<D.length){let j6=D[V];if(j6&&!j6.isInstalled){let G6=new Set(S);if(G6.has(j6.pluginId))G6.delete(j6.pluginId);else G6.add(j6.pluginId);R(G6)}}},"plugin:install":()=>{if(S.size>0)e()}},{context:"Plugin",isActive:w==="plugin-list"});let $6=w1.useMemo(()=>{if(!M)return[];let j6=M.entry.homepage,G6=T56(M);return oh6(j6,G6)},[M]);if(o7({"select:previous":()=>{if(p>0)C(p-1)},"select:next":()=>{if(p<$6.length-1)C(p+1)},"select:accept":()=>{if(!M)return;let j6=$6[p]?.action,G6=M.entry.homepage,w6=T56(M);if(j6==="install-user")i(M,"user");else if(j6==="install-project")i(M,"project");else if(j6==="install-local")i(M,"local");else if(j6==="homepage"&&G6)m3(G6);else if(j6==="github"&&w6)m3(`https://github.com/${w6}`);else if(j6==="back")j("plugin-list"),X(null)}},{context:"Select",isActive:w==="plugin-details"&&!!M}),typeof w==="object"&&w.type==="plugin-options"){let w6=function(o){if(z(o),$)$();Y({type:"menu"})},{plugin:j6,pluginId:G6}=w;return w1.createElement(rh6,{plugin:j6,pluginId:G6,onDone:(o,s)=>{switch(o){case"configured":w6(`✓ Installed and configured ${j6.name}. Run /reload-plugins to apply.`);break;case"skipped":w6(`✓ Installed ${j6.name}. Run /reload-plugins to apply.`);break;case"error":w6(`Installed but failed to save config: ${s}`);break}}})}if(G)return w1.createElement(k,null,"Loading…");if(q)return w1.createElement(k,{color:"error"},q);if(w==="marketplace-list"){if(P.length===0)return w1.createElement(u,{flexDirection:"column"},w1.createElement(u,{marginBottom:1},w1.createElement(k,{bold:!0},"Select marketplace")),w1.createElement(k,null,"No marketplaces configured."),w1.createElement(k,{dimColor:!0},"Add a marketplace first using ","'Add marketplace'","."),w1.createElement(u,{marginTop:1,paddingLeft:1},w1.createElement(k,{dimColor:!0},w1.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"go back"}))));return w1.createElement(u,{flexDirection:"column"},w1.createElement(u,{marginBottom:1},w1.createElement(k,{bold:!0},"Select marketplace")),K6&&w1.createElement(u,{marginBottom:1,flexDirection:"column"},w1.createElement(k,{color:"warning"},t6.warning," ",K6)),P.map((j6,G6)=>w1.createElement(u,{key:j6.name,flexDirection:"column",marginBottom:G6<P.length-1?1:0},w1.createElement(u,null,w1.createElement(k,{color:V===G6?"suggestion":void 0},V===G6?t6.pointer:" "," ",j6.name)),w1.createElement(u,{marginLeft:2},w1.createElement(k,{dimColor:!0},j6.totalPlugins," ",A7(j6.totalPlugins,"plugin")," available",j6.installedCount>0&&` · ${j6.installedCount} already installed`,j6.source&&` · ${j6.source}`)))),w1.createElement(u,{marginTop:1},w1.createElement(k,{dimColor:!0,italic:!0},w1.createElement(I1,null,w1.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),w1.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"go back"})))))}if(w==="plugin-details"&&M){let j6=M.entry.homepage,G6=T56(M),w6=oh6(j6,G6);return w1.createElement(u,{flexDirection:"column"},w1.createElement(u,{marginBottom:1},w1.createElement(k,{bold:!0},"Plugin Details")),w1.createElement(u,{flexDirection:"column",marginBottom:1},w1.createElement(k,{bold:!0},M.entry.name),M.entry.version&&w1.createElement(k,{dimColor:!0},"Version: ",M.entry.version),M.entry.description&&w1.createElement(u,{marginTop:1},w1.createElement(k,null,M.entry.description)),M.entry.author&&w1.createElement(u,{marginTop:1},w1.createElement(k,{dimColor:!0},"By:"," ",typeof M.entry.author==="string"?M.entry.author:M.entry.author.name))),w1.createElement(u,{flexDirection:"column",marginBottom:1},w1.createElement(k,{bold:!0},"Will install:"),M.entry.commands&&w1.createElement(k,{dimColor:!0},"· Commands:"," ",Array.isArray(M.entry.commands)?M.entry.commands.join(", "):Object.keys(M.entry.commands).join(", ")),M.entry.agents&&w1.createElement(k,{dimColor:!0},"· Agents:"," ",Array.isArray(M.entry.agents)?M.entry.agents.join(", "):Object.keys(M.entry.agents).join(", ")),M.entry.hooks&&w1.createElement(k,{dimColor:!0},"· Hooks: ",Object.keys(M.entry.hooks).join(", ")),M.entry.mcpServers&&w1.createElement(k,{dimColor:!0},"· MCP Servers:"," ",Array.isArray(M.entry.mcpServers)?M.entry.mcpServers.join(", "):typeof M.entry.mcpServers==="object"?Object.keys(M.entry.mcpServers).join(", "):"configured"),!M.entry.commands&&!M.entry.agents&&!M.entry.hooks&&!M.entry.mcpServers&&w1.createElement(w1.Fragment,null,typeof M.entry.source==="object"&&"source"in M.entry.source&&(M.entry.source.source==="github"||M.entry.source.source==="url"||M.entry.source.source==="npm"||M.entry.source.source==="pip")?w1.createElement(k,{dimColor:!0},"· Component summary not available for remote plugin"):w1.createElement(k,{dimColor:!0},"· Components will be discovered at installation"))),w1.createElement(JF8,null),U&&w1.createElement(u,{marginBottom:1},w1.createElement(k,{color:"error"},"Error: ",U)),w1.createElement(u,{flexDirection:"column"},w6.map((o,s)=>w1.createElement(u,{key:o.action},p===s&&w1.createElement(k,null,"> "),p!==s&&w1.createElement(k,null," "),w1.createElement(k,{bold:p===s},g&&o.action==="install"?"Installing…":o.label)))),w1.createElement(u,{marginTop:1,paddingLeft:1},w1.createElement(k,{dimColor:!0},w1.createElement(I1,null,w1.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),w1.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))))}if(D.length===0)return w1.createElement(u,{flexDirection:"column"},w1.createElement(u,{marginBottom:1},w1.createElement(k,{bold:!0},"Install plugins")),w1.createElement(k,{dimColor:!0},"No new plugins available to install."),w1.createElement(k,{dimColor:!0},"All plugins from this marketplace are already installed."),w1.createElement(u,{marginLeft:3},w1.createElement(k,{dimColor:!0,italic:!0},w1.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"go back"}))));let M6=B.getVisibleItems(D);return w1.createElement(u,{flexDirection:"column"},w1.createElement(u,{marginBottom:1},w1.createElement(k,{bold:!0},"Install Plugins")),B.scrollPosition.canScrollUp&&w1.createElement(u,null,w1.createElement(k,{dimColor:!0}," ",t6.arrowUp," more above")),M6.map((j6,G6)=>{let w6=B.toActualIndex(G6),o=V===w6,s=S.has(j6.pluginId),a=x.has(j6.pluginId),n=G6===M6.length-1;return w1.createElement(u,{key:j6.pluginId,flexDirection:"column",marginBottom:n&&!q?0:1},w1.createElement(u,null,w1.createElement(k,{color:o?"suggestion":void 0},o?t6.pointer:" "," "),w1.createElement(k,{color:j6.isInstalled?"success":void 0},j6.isInstalled?t6.tick:a?t6.ellipsis:s?t6.radioOn:t6.radioOff," ",j6.entry.name,j6.entry.category&&w1.createElement(k,{dimColor:!0}," [",j6.entry.category,"]"),j6.entry.tags?.includes("community-managed")&&w1.createElement(k,{dimColor:!0}," [Community Managed]"),j6.isInstalled&&w1.createElement(k,{dimColor:!0}," (installed)"),T&&H===C2&&w1.createElement(k,{dimColor:!0}," · ",OF8(T.get(j6.pluginId)??0)," ","installs"))),j6.entry.description&&w1.createElement(u,{marginLeft:4},w1.createElement(k,{dimColor:!0},T4(j6.entry.description,60)),j6.entry.version&&w1.createElement(k,{dimColor:!0}," · v",j6.entry.version)))}),B.scrollPosition.canScrollDown&&w1.createElement(u,null,w1.createElement(k,{dimColor:!0}," ",t6.arrowDown," more below")),q&&w1.createElement(u,{marginTop:1},w1.createElement(k,{color:"error"},t6.cross," ",q)),w1.createElement(AyK,{hasSelection:S.size>0}))}var w1,_W;var wyK=y(()=>{bq();a5();QK();s6();Oq();hH();_8();y8();Jy();wF8();pX();qd();Nw();oi();_56();Sj6();P98();HF8();B47();g47();MF8();w1=O6(D6(),1),_W=O6(D6(),1)});function jyK({error:q,setError:K,result:_,setResult:z,setViewState:Y,onInstallComplete:$,onSearchModeChange:A,targetPlugin:O}){let[w,j]=lH.useState("plugin-list"),[H,J]=lH.useState(null),[M,X]=lH.useState([]),[P,W]=lH.useState(!0),[D,f]=lH.useState(null),[G,Z]=lH.useState(!1),T=lH.useCallback((n)=>{Z(n),A?.(n)},[A]),{query:v,setQuery:V,cursorOffset:E}=XR({isActive:w==="plugin-list"&&G&&!P,onExit:()=>{T(!1)}}),S=CO(),{columns:R}=t1(),x=lH.useMemo(()=>{if(!v)return M;let n=v.toLowerCase();return M.filter((l)=>l.entry.name.toLowerCase().includes(n)||l.entry.description?.toLowerCase().includes(n)||l.marketplaceName.toLowerCase().includes(n))},[M,v]),[I,B]=lH.useState(0),[p,C]=lH.useState(new Set),[g,F]=lH.useState(new Set),U=ah6({totalItems:x.length,selectedIndex:I});lH.useEffect(()=>{B(0)},[v]);let[c,K6]=lH.useState(0),[t,q6]=lH.useState(!1),[e,i]=lH.useState(null),[$6,M6]=lH.useState(null),[j6,G6]=lH.useState(null);lH.useEffect(()=>{async function n(){try{let l=await r_(),{marketplaces:A6,failures:J6}=await Xp(l),X6=[];for(let{name:y6,data:T6}of A6)if(T6)for(let n6 of T6.plugins){let o6=eQ(n6.name,y6);X6.push({entry:n6,marketplaceName:y6,pluginId:o6,isInstalled:Xh6(o6)})}let f6=X6.filter((y6)=>!y6.isInstalled&&!zR(y6.pluginId));try{let y6=await ih6();if(f(y6),y6)f6.sort((T6,n6)=>{let o6=y6.get(T6.pluginId)??0,I6=y6.get(n6.pluginId)??0;if(o6!==I6)return I6-o6;return T6.entry.name.localeCompare(n6.entry.name)});else f6.sort((T6,n6)=>T6.entry.name.localeCompare(n6.entry.name))}catch(y6){N(`Failed to fetch install counts: ${d6(y6)}`),f6.sort((T6,n6)=>T6.entry.name.localeCompare(n6.entry.name))}X(f6);let N6=Object.keys(l).length;if(f6.length===0){let y6=await UfK({configuredMarketplaceCount:N6,failedMarketplaceCount:J6.length});G6(y6)}let Z6=$7(A6,(y6)=>y6.data!==null),V6=Jh6(J6,Z6);if(V6)if(V6.type==="warning")M6(V6.message+". Showing available plugins.");else throw Error(V6.message);if(O){let y6=X6.find((T6)=>T6.entry.name===O);if(y6)if(y6.isInstalled)K(`Plugin '${y6.pluginId}' is already installed. Use '/plugin' to manage existing plugins.`);else J(y6),j("plugin-details");else K(`Plugin "${O}" not found in any marketplace`)}}catch(l){K(l instanceof Error?l.message:"Failed to load plugins")}finally{W(!1)}}n()},[K,O]);let w6=async()=>{if(p.size===0)return;let n=M.filter((X6)=>p.has(X6.pluginId));F(new Set(n.map((X6)=>X6.pluginId)));let l=0,A6=0,J6=[];for(let X6 of n){let f6=await K56({pluginId:X6.pluginId,entry:X6.entry,marketplaceName:X6.marketplaceName,scope:"user"});if(f6.success)l++;else A6++,J6.push({name:X6.entry.name,reason:f6.error})}if(F(new Set),C(new Set),Sz(),A6===0){let X6=`✓ Installed ${l} ${A7(l,"plugin")}. Run /reload-plugins to activate.`;z(X6)}else if(l===0)K(`Failed to install: ${Hh6(J6,!0)}`);else{let X6=`✓ Installed ${l} of ${l+A6} plugins. Failed: ${Hh6(J6,!1)}. Run /reload-plugins to activate successfully installed plugins.`;z(X6)}if(l>0){if($)await $()}Y({type:"menu"})},o=async(n,l="user")=>{q6(!0),i(null);let A6=await K56({pluginId:n.pluginId,entry:n.entry,marketplaceName:n.marketplaceName,scope:l});if(A6.success){let J6=await jF8(n.pluginId);if(J6){q6(!1),j({type:"plugin-options",plugin:J6,pluginId:n.pluginId});return}if(z(A6.message),$)await $();Y({type:"menu"})}else q6(!1),i(A6.error)};lH.useEffect(()=>{if(q)z(q)},[q,z]),P1("confirm:no",()=>{j("plugin-list"),J(null)},{context:"Confirmation",isActive:w==="plugin-details"}),P1("confirm:no",()=>{Y({type:"menu"})},{context:"Confirmation",isActive:w==="plugin-list"&&!G}),k4((n,l)=>{let A6=!l.ctrl&&!l.meta;if(!G){if(n==="/"&&A6)T(!0),V("");else if(A6&&n.length>0&&!/^\s+$/.test(n)&&n!=="j"&&n!=="k"&&n!=="i")T(!0),V(n)}},{isActive:w==="plugin-list"&&!P}),o7({"select:previous":()=>{if(I===0)T(!0);else U.handleSelectionChange(I-1,B)},"select:next":()=>{if(I<x.length-1)U.handleSelectionChange(I+1,B)},"select:accept":()=>{if(I===x.length&&p.size>0)w6();else if(I<x.length){let n=x[I];if(n)if(n.isInstalled)Y({type:"manage-plugins",targetPlugin:n.entry.name,targetMarketplace:n.marketplaceName});else J(n),j("plugin-details"),K6(0),i(null)}}},{context:"Select",isActive:w==="plugin-list"&&!G}),o7({"plugin:toggle":()=>{if(I<x.length){let n=x[I];if(n&&!n.isInstalled){let l=new Set(p);if(l.has(n.pluginId))l.delete(n.pluginId);else l.add(n.pluginId);C(l)}}},"plugin:install":()=>{if(p.size>0)w6()}},{context:"Plugin",isActive:w==="plugin-list"&&!G});let s=A1.useMemo(()=>{if(!H)return[];let n=H.entry.homepage,l=T56(H);return oh6(n,l)},[H]);if(o7({"select:previous":()=>{if(c>0)K6(c-1)},"select:next":()=>{if(c<s.length-1)K6(c+1)},"select:accept":()=>{if(!H)return;let n=s[c]?.action,l=H.entry.homepage,A6=T56(H);if(n==="install-user")o(H,"user");else if(n==="install-project")o(H,"project");else if(n==="install-local")o(H,"local");else if(n==="homepage"&&l)m3(l);else if(n==="github"&&A6)m3(`https://github.com/${A6}`);else if(n==="back")j("plugin-list"),J(null)}},{context:"Select",isActive:w==="plugin-details"&&!!H}),typeof w==="object"&&w.type==="plugin-options"){let A6=function(J6){if(z(J6),$)$();Y({type:"menu"})},{plugin:n,pluginId:l}=w;return A1.createElement(rh6,{plugin:n,pluginId:l,onDone:(J6,X6)=>{switch(J6){case"configured":A6(`✓ Installed and configured ${n.name}. Run /reload-plugins to apply.`);break;case"skipped":A6(`✓ Installed ${n.name}. Run /reload-plugins to apply.`);break;case"error":A6(`Installed but failed to save config: ${X6}`);break}}})}if(P)return A1.createElement(k,null,"Loading…");if(q)return A1.createElement(k,{color:"error"},q);if(w==="plugin-details"&&H){let n=H.entry.homepage,l=T56(H),A6=oh6(n,l);return A1.createElement(u,{flexDirection:"column"},A1.createElement(u,{marginBottom:1},A1.createElement(k,{bold:!0},"Plugin details")),A1.createElement(u,{flexDirection:"column",marginBottom:1},A1.createElement(k,{bold:!0},H.entry.name),A1.createElement(k,{dimColor:!0},"from ",H.marketplaceName),H.entry.version&&A1.createElement(k,{dimColor:!0},"Version: ",H.entry.version),H.entry.description&&A1.createElement(u,{marginTop:1},A1.createElement(k,null,H.entry.description)),H.entry.author&&A1.createElement(u,{marginTop:1},A1.createElement(k,{dimColor:!0},"By:"," ",typeof H.entry.author==="string"?H.entry.author:H.entry.author.name))),A1.createElement(JF8,null),e&&A1.createElement(u,{marginBottom:1},A1.createElement(k,{color:"error"},"Error: ",e)),A1.createElement(u,{flexDirection:"column"},A6.map((J6,X6)=>A1.createElement(u,{key:J6.action},c===X6&&A1.createElement(k,null,"> "),c!==X6&&A1.createElement(k,null," "),A1.createElement(k,{bold:c===X6},t&&J6.action.startsWith("install-")?"Installing…":J6.label)))),A1.createElement(u,{marginTop:1},A1.createElement(k,{dimColor:!0},A1.createElement(I1,null,A1.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),A1.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))))}if(M.length===0)return A1.createElement(u,{flexDirection:"column"},A1.createElement(u,{marginBottom:1},A1.createElement(k,{bold:!0},"Discover plugins")),A1.createElement(CMY,{reason:j6}),A1.createElement(u,{marginTop:1},A1.createElement(k,{dimColor:!0,italic:!0},"Esc to go back")));let a=U.getVisibleItems(x);return A1.createElement(u,{flexDirection:"column"},A1.createElement(u,null,A1.createElement(k,{bold:!0},"Discover plugins"),U.needsPagination&&A1.createElement(k,{dimColor:!0}," ","(",U.scrollPosition.current,"/",U.scrollPosition.total,")")),A1.createElement(u,{marginBottom:1},A1.createElement(Tp,{query:v,isFocused:G,isTerminalFocused:S,width:R-4,cursorOffset:E})),$6&&A1.createElement(u,{marginBottom:1},A1.createElement(k,{color:"warning"},t6.warning," ",$6)),x.length===0&&v&&A1.createElement(u,{marginBottom:1},A1.createElement(k,{dimColor:!0},'No plugins match "',v,'"')),U.scrollPosition.canScrollUp&&A1.createElement(u,null,A1.createElement(k,{dimColor:!0}," ",t6.arrowUp," more above")),a.map((n,l)=>{let A6=U.toActualIndex(l),J6=I===A6,X6=p.has(n.pluginId),f6=g.has(n.pluginId),N6=l===a.length-1;return A1.createElement(u,{key:`${U.startIndex}-${n.pluginId}`,flexDirection:"column",marginBottom:N6&&!q?0:1},A1.createElement(u,null,A1.createElement(k,{color:J6&&!G?"suggestion":void 0},J6&&!G?t6.pointer:" "," "),A1.createElement(k,null,f6?t6.ellipsis:X6?t6.radioOn:t6.radioOff," ",n.entry.name,A1.createElement(k,{dimColor:!0}," · ",n.marketplaceName),n.entry.tags?.includes("community-managed")&&A1.createElement(k,{dimColor:!0}," [Community Managed]"),D&&n.marketplaceName===C2&&A1.createElement(k,{dimColor:!0}," · ",OF8(D.get(n.pluginId)??0)," ","installs"))),n.entry.description&&A1.createElement(u,{marginLeft:4},A1.createElement(k,{dimColor:!0},T4(n.entry.description,60))))}),U.scrollPosition.canScrollDown&&A1.createElement(u,null,A1.createElement(k,{dimColor:!0}," ",t6.arrowDown," more below")),q&&A1.createElement(u,{marginTop:1},A1.createElement(k,{color:"error"},t6.cross," ",q)),A1.createElement(SMY,{hasSelection:p.size>0,canToggle:I<x.length&&!x[I]?.isInstalled}))}function SMY(q){let K=z6(10),{hasSelection:_,canToggle:z}=q,Y;if(K[0]!==_)Y=_&&A1.createElement(W1,{action:"plugin:install",context:"Plugin",fallback:"i",description:"install",bold:!0}),K[0]=_,K[1]=Y;else Y=K[1];let $;if(K[2]===Symbol.for("react.memo_cache_sentinel"))$=A1.createElement(k,null,"type to search"),K[2]=$;else $=K[2];let A;if(K[3]!==z)A=z&&A1.createElement(W1,{action:"plugin:toggle",context:"Plugin",fallback:"Space",description:"toggle"}),K[3]=z,K[4]=A;else A=K[4];let O,w;if(K[5]===Symbol.for("react.memo_cache_sentinel"))O=A1.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"details"}),w=A1.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"}),K[5]=O,K[6]=w;else O=K[5],w=K[6];let j;if(K[7]!==Y||K[8]!==A)j=A1.createElement(u,{marginTop:1},A1.createElement(k,{dimColor:!0,italic:!0},A1.createElement(I1,null,Y,$,A,O,w))),K[7]=Y,K[8]=A,K[9]=j;else j=K[9];return j}function CMY(q){let K=z6(6),{reason:_}=q;switch(_){case"git-not-installed":{let z;if(K[0]===Symbol.for("react.memo_cache_sentinel"))z=A1.createElement(A1.Fragment,null,A1.createElement(k,{dimColor:!0},"Git is required to install marketplaces."),A1.createElement(k,{dimColor:!0},"Please install git and restart Claude Code.")),K[0]=z;else z=K[0];return z}case"all-blocked-by-policy":{let z;if(K[1]===Symbol.for("react.memo_cache_sentinel"))z=A1.createElement(A1.Fragment,null,A1.createElement(k,{dimColor:!0},"Your organization policy does not allow any external marketplaces."),A1.createElement(k,{dimColor:!0},"Contact your administrator.")),K[1]=z;else z=K[1];return z}case"policy-restricts-sources":{let z;if(K[2]===Symbol.for("react.memo_cache_sentinel"))z=A1.createElement(A1.Fragment,null,A1.createElement(k,{dimColor:!0},"Your organization restricts which marketplaces can be added."),A1.createElement(k,{dimColor:!0},"Switch to the Marketplaces tab to view allowed sources.")),K[2]=z;else z=K[2];return z}case"all-marketplaces-failed":{let z;if(K[3]===Symbol.for("react.memo_cache_sentinel"))z=A1.createElement(A1.Fragment,null,A1.createElement(k,{dimColor:!0},"Failed to load marketplace data."),A1.createElement(k,{dimColor:!0},"Check your network connection.")),K[3]=z;else z=K[3];return z}case"all-plugins-installed":{let z;if(K[4]===Symbol.for("react.memo_cache_sentinel"))z=A1.createElement(A1.Fragment,null,A1.createElement(k,{dimColor:!0},"All available plugins are already installed."),A1.createElement(k,{dimColor:!0},"Check for new plugins later or add more marketplaces.")),K[4]=z;else z=K[4];return z}case"no-marketplaces-configured":default:{let z;if(K[5]===Symbol.for("react.memo_cache_sentinel"))z=A1.createElement(A1.Fragment,null,A1.createElement(k,{dimColor:!0},"No plugins available."),A1.createElement(k,{dimColor:!0},"Add a marketplace first using the Marketplaces tab.")),K[5]=z;else z=K[5];return z}}}var A1,lH;var HyK=y(()=>{q8();bq();a5();QK();gH6();H56();t4();s6();Oq();hH();_8();y8();Jy();wF8();pX();qd();Nw();oi();_56();Sj6();P98();HF8();B47();g47();MF8();A1=O6(D6(),1),lH=O6(D6(),1)});import{dirname as bMY,join as JyK}from"path";function F47(q){if(!e0.includes(q))throw Error(`Invalid scope "${q}". Must be one of: ${e0.join(", ")}`)}function sh6(q){return e0.includes(q)}function MyK(q){return q==="project"||q==="local"?r1():void 0}function XyK(q){return v1("projectSettings")?.enabledPlugins?.[q]===!0}function xMY(q){let K=q.includes("@"),_=["local","project","user"];for(let z of _){let Y=v1(hF(z))?.enabledPlugins;if(!Y)continue;for(let $ of Object.keys(Y))if(K?$===q:$.startsWith(`${q}@`))return{pluginId:$,scope:z}}return null}function IMY(q,K){let{name:_,marketplace:z}=Z4(q);return K.find((Y)=>{if(Y.name===q||Y.name===_)return!0;if(z&&Y.source)return Y.name===_&&Y.source.includes(`@${z}`);return!1})}function uMY(q){let{name:K}=Z4(q),_=cX();if(_.plugins[q]?.length)return{pluginId:q,pluginName:K};let z=Object.keys(_.plugins).find((Y)=>{let{name:$}=Z4(Y);return $===K&&(_.plugins[Y]?.length??0)>0});if(z)return{pluginId:z,pluginName:K};return null}function XF8(q){let _=cX().plugins[q];if(!_||_.length===0)return{scope:"user"};let z=r1(),Y=_.find((O)=>O.scope==="local"&&O.projectPath===z);if(Y)return{scope:Y.scope,projectPath:Y.projectPath};let $=_.find((O)=>O.scope==="project"&&O.projectPath===z);if($)return{scope:$.scope,projectPath:$.projectPath};let A=_.find((O)=>O.scope==="user");if(A)return{scope:A.scope};return{scope:_[0].scope,projectPath:_[0].projectPath}}async function PyK(q,K="user"){F47(K);let{name:_,marketplace:z}=Z4(q),Y,$,A;if(z){let H=await aG(q);if(H)Y=H.entry,$=z,A=H.marketplaceInstallLocation}else{let H=await r_();for(let[J,M]of Object.entries(H))try{let P=(await r0(J)).plugins.find((W)=>W.name===_);if(P){Y=P,$=J,A=M.installLocation;break}}catch(X){H6(x1(X));continue}}if(!Y||!$){let H=z?`marketplace "${z}"`:"any configured marketplace";return{success:!1,message:`Plugin "${_}" not found in ${H}`}}let O=Y,w=`${O.name}@${$}`,j=await s17({pluginId:w,entry:O,scope:K,marketplaceInstallLocation:A});if(!j.ok)switch(j.reason){case"local-source-no-location":return{success:!1,message:`Cannot install local plugin "${j.pluginName}" without marketplace install location`};case"settings-write-failed":return{success:!1,message:`Failed to update settings: ${j.message}`};case"resolution-failed":return{success:!1,message:a17(j.resolution)};case"blocked-by-policy":return{success:!1,message:`Plugin "${j.pluginName}" is blocked by your organization's policy and cannot be installed`};case"dependency-blocked-by-policy":return{success:!1,message:`Plugin "${j.pluginName}" depends on "${j.blockedDependency}", which is blocked by your organization's policy`}}return{success:!0,message:`Successfully installed plugin: ${w} (scope: ${K})${j.depNote}`,pluginId:w,pluginName:O.name,scope:K}}async function _s(q,K="user",_=!0){F47(K);let{enabled:z,disabled:Y}=await LM(),$=[...z,...Y],A=IMY(q,$),O=hF(K),w=v1(O),j,H;if(A)j=Object.keys(w?.enabledPlugins??{}).find((V)=>V===q||V===A.name||V.startsWith(`${A.name}@`))??(q.includes("@")?q:A.name),H=A.name;else{let V=uMY(q);if(!V)return{success:!1,message:`Plugin "${q}" not found in installed plugins`};j=V.pluginId,H=V.pluginName}let J=MyK(K),X=cX().plugins[j],P=X?.find((V)=>V.scope===K&&V.projectPath===J);if(!P){let{scope:V}=XF8(j);if(V!==K&&X&&X.length>0){if(V==="project")return{success:!1,message:`Plugin "${q}" is enabled at project scope (.claude/settings.json, shared with your team). To disable just for you: claude plugin disable ${q} --scope local`};return{success:!1,message:`Plugin "${q}" is installed in ${V} scope, not ${K}. Use --scope ${V} to uninstall.`}}return{success:!1,message:`Plugin "${q}" is not installed in ${K} scope. Use --scope to specify the correct scope.`}}let W=P.installPath,D={...w?.enabledPlugins};D[j]=void 0,W7(O,{enabledPlugins:D}),Sz(),$0K(j,K,J);let G=cX().plugins[j],Z=!G||G.length===0;if(Z&&W)await wh6(W);if(Z){if(Ak8(j),_)await WT8(j)}let T=Lh1(j,$),v=Rh1(T);return{success:!0,message:`Successfully uninstalled plugin: ${H} (scope: ${K})${v}`,pluginId:j,pluginName:H,scope:K,reverseDependents:T.length>0?T:void 0}}async function U47(q,K,_){let z=K?"enable":"disable";if(jK4(q)){let{error:D}=W7("userSettings",{enabledPlugins:{...v1("userSettings")?.enabledPlugins,[q]:K}});if(D)return{success:!1,message:`Failed to ${z} built-in plugin: ${D.message}`};Sz();let{name:f}=Z4(q);return{success:!0,message:`Successfully ${z}d built-in plugin: ${f}`,pluginId:q,pluginName:f,scope:"user"}}if(_)F47(_);let Y,$,A=xMY(q);if(_)if($=_,A)Y=A.pluginId;else if(q.includes("@"))Y=q;else return{success:!1,message:`Plugin "${q}" not found in settings. Use plugin@marketplace format.`};else if(A)Y=A.pluginId,$=A.scope;else if(q.includes("@"))Y=q,$="user";else return{success:!1,message:`Plugin "${q}" not found in any editable settings scope. Use plugin@marketplace format.`};if(K&&zR(Y))return{success:!1,message:`Plugin "${Y}" is blocked by your organization's policy and cannot be enabled`};let O=hF($),w=v1(O)?.enabledPlugins?.[Y],j={user:0,project:1,local:2},H=_&&A&&j[_]>j[A.scope];if(_&&w===void 0&&A&&A.scope!==_&&!H)return{success:!1,message:`Plugin "${q}" is installed at ${A.scope} scope, not ${_}. Use --scope ${A.scope} or omit --scope to auto-detect.`};let J=_&&!H?w===!0:G56().has(Y);if(K===J)return{success:!1,message:`Plugin "${q}" is already ${K?"enabled":"disabled"}${_?` at ${_} scope`:""}`};let M;if(!K){let{enabled:D,disabled:f}=await LM(),G=Lh1(Y,[...D,...f]);if(G.length>0)M=G}let{error:X}=W7(O,{enabledPlugins:{...v1(O)?.enabledPlugins,[Y]:K}});if(X)return{success:!1,message:`Failed to ${z} plugin: ${X.message}`};Sz();let{name:P}=Z4(Y),W=Rh1(M);return{success:!0,message:`Successfully ${z}d plugin: ${P} (scope: ${$})${W}`,pluginId:Y,pluginName:P,scope:$,reverseDependents:M}}async function v56(q,K){return U47(q,!0,K)}async function th6(q,K){return U47(q,!1,K)}async function WyK(){let q=G56();if(q.size===0)return{success:!0,message:"No enabled plugins to disable"};let K=[],_=[];for(let[z]of q){let Y=await U47(z,!1);if(Y.success)K.push(z);else _.push(`${z}: ${Y.message}`)}if(_.length>0)return{success:!1,message:`Disabled ${K.length} ${A7(K.length,"plugin")}, ${_.length} failed:
6088${_.join(`
6089`)}`};return{success:!0,message:`Disabled ${K.length} ${A7(K.length,"plugin")}`}}async function eh6(q,K){let{name:_,marketplace:z}=Z4(q),Y=z?`${_}@${z}`:q,$=await aG(q);if(!$)return{success:!1,message:`Plugin "${_}" not found`,pluginId:Y,scope:K};let{entry:A,marketplaceInstallLocation:O}=$,j=Mp().plugins[Y];if(!j||j.length===0)return{success:!1,message:`Plugin "${_}" is not installed`,pluginId:Y,scope:K};let H=MyK(K),J=j.find((M)=>M.scope===K&&M.projectPath===H);if(!J){let M=H?`${K} (${H})`:K;return{success:!1,message:`Plugin "${_}" is not installed at scope ${M}`,pluginId:Y,scope:K}}return mMY({pluginId:Y,pluginName:_,entry:A,marketplaceInstallLocation:O,installation:J,scope:K,projectPath:H})}async function mMY({pluginId:q,pluginName:K,entry:_,marketplaceInstallLocation:z,installation:Y,scope:$,projectPath:A}){let O=X8(),w=Y.version,j,H,J=!1,M;if(typeof _.source!=="string"){let X=await Q18(_.source,{manifest:{name:_.name}});j=X.path,J=!0,M=X.gitCommitSha,H=await Fa(q,_.source,X.manifest,X.path,_.version,X.gitCommitSha)}else{let X;try{X=await O.stat(z)}catch(f){if(_7(f))return{success:!1,message:`Marketplace directory not found at ${z}`,pluginId:q,scope:$};throw f}let P=X.isDirectory()?z:bMY(z);j=JyK(P,_.source);try{await O.stat(j)}catch(f){if(_7(f))return{success:!1,message:`Plugin source not found at ${j}`,pluginId:q,scope:$};throw f}let W,D=JyK(j,".claude-plugin","plugin.json");try{W=await EB8(D,_.name,_.source)}catch{}H=await Fa(q,_.source,W,j,_.version)}try{let X=Pp(q,H),P=Ph6(q,H);if(Y.version===H||Y.installPath===X||Y.installPath===P)return{success:!0,message:`${K} is already at the latest version (${H}).`,pluginId:q,newVersion:H,oldVersion:w,alreadyUpToDate:!0,scope:$};X=await yB8(j,q,H,_);let D=Y.installPath;if(A0K(q,$,A,X,H,M),D&&D!==X){let Z=Mp();if(!Object.values(Z.plugins).some((v)=>v.some((V)=>V.installPath===D)))await wh6(D)}let f=A?`${$} (${A})`:$;return{success:!0,message:`Plugin "${K}" updated from ${w||"unknown"} to ${H} for scope ${f}. Restart to apply changes.`,pluginId:q,newVersion:H,oldVersion:w,scope:$}}finally{if(J&&j!==Pp(q,H))await O.rm(j,{recursive:!0,force:!0})}}var e0,rH6;var qS6=y(()=>{v8();vn6();y8();e7();E8();Jy();QG8();pX();Nw();aV();hP();_56();bj();mu();Sj6();nh6();kB8();U1();e0=["user","project","local"],rH6=["user","project","local","managed"]});function DyK(q){if(PF8=q,p78!==null&&p78.length>0)q(p78),p78=null;return()=>{PF8=null}}async function pMY(){let q=await r_(),K=tK6(),_=new Set;for(let[z,Y]of Object.entries(q)){let $=K[z]?.autoUpdate;if($!==void 0?$:fp6(z,Y))_.add(z.toLowerCase())}return _}async function BMY(q,K){let _=!1;for(let{scope:z}of K)try{let Y=await eh6(q,z);if(Y.success&&!Y.alreadyUpToDate)_=!0,N(`Plugin autoupdate: updated ${q} from ${Y.oldVersion} to ${Y.newVersion}`);else if(!Y.alreadyUpToDate)N(`Plugin autoupdate: failed to update ${q}: ${Y.message}`,{level:"warn"})}catch(Y){N(`Plugin autoupdate: error updating ${q}: ${d6(Y)}`,{level:"warn"})}return _?q:null}async function Q47(q){let K=Mp(),_=Object.keys(K.plugins);if(_.length===0)return[];return(await Promise.allSettled(_.map(async(Y)=>{let{marketplace:$}=Z4(Y);if(!$||!q.has($.toLowerCase()))return null;let A=K.plugins[Y];if(!A||A.length===0)return null;let O=A.filter(d17);if(O.length===0)return null;return BMY(Y,O)}))).filter((Y)=>Y.status==="fulfilled"&&Y.value!==null).map((Y)=>Y.value)}async function gMY(q){return Q47(q)}function fyK(){(async()=>{if(aG6()){N("Plugin autoupdate: skipped (auto-updater disabled)");return}try{let q=await pMY();if(q.size===0)return;let _=(await Promise.allSettled(Array.from(q).map(async(Y)=>{try{await q56(Y,void 0,{disableCredentialHelper:!0})}catch($){N(`Plugin autoupdate: failed to refresh marketplace ${Y}: ${d6($)}`,{level:"warn"})}}))).filter((Y)=>Y.status==="rejected");if(_.length>0)N(`Plugin autoupdate: ${_.length} marketplace refresh(es) failed`,{level:"warn"});N("Plugin autoupdate: checking installed plugins");let z=await gMY(q);if(z.length>0)if(PF8)PF8(z);else p78=z}catch(q){H6(q)}})()}var PF8=null,p78=null;var WF8=y(()=>{qS6();V1();_8();y8();E8();pX();Nw();hP();BZ()});function ZyK({setViewState:q,error:K,setError:_,setResult:z,exitState:Y,onManageComplete:$,targetMarketplace:A,action:O}){let[w,j]=jk.useState([]),[H,J]=jk.useState(!0),[M,X]=jk.useState(0),[P,W]=jk.useState(!1),[D,f]=jk.useState(null),[G,Z]=jk.useState(null),[T,v]=jk.useState(null),[V,E]=jk.useState("list"),[S,R]=jk.useState(null),[x,I]=jk.useState(0),B=jk.useRef(!1);jk.useEffect(()=>{async function q6(){try{let e=await r_(),{enabled:i,disabled:$6}=await LM(),M6=[...i,...$6],{marketplaces:j6,failures:G6}=await Xp(e),w6=[];for(let{name:a,config:n,data:l}of j6){let A6=M6.filter((J6)=>J6.source.endsWith(`@${a}`));w6.push({name:a,source:h18(n.source),lastUpdated:n.lastUpdated,pluginCount:l?.plugins.length,installedPlugins:A6,pendingUpdate:!1,pendingRemove:!1,autoUpdate:fp6(a,n)})}w6.sort((a,n)=>{if(a.name==="claude-plugin-directory")return-1;if(n.name==="claude-plugin-directory")return 1;return a.name.localeCompare(n.name)}),j(w6);let o=$7(j6,(a)=>a.data!==null),s=Jh6(G6,o);if(s)if(s.type==="warning")f(s.message);else throw Error(s.message);if(A&&!B.current&&!K){B.current=!0;let a=w6.findIndex((n)=>n.name===A);if(a>=0){let n=w6[a];if(O){X(a+1);let l=[...w6];if(O==="update")l[a].pendingUpdate=!0;else if(O==="remove")l[a].pendingRemove=!0;j(l),setTimeout(g,100,l)}else if(n)X(a+1),R(n),E("details")}else if(_)_(`Marketplace not found: ${A}`)}}catch(e){if(_)_(e instanceof Error?e.message:"Failed to load marketplaces");f(e instanceof Error?e.message:"Failed to load marketplaces")}finally{J(!1)}}q6()},[A,O,K]);let p=()=>{return w.some((q6)=>q6.pendingUpdate||q6.pendingRemove)},C=()=>{let q6=$7(w,(i)=>i.pendingUpdate),e=$7(w,(i)=>i.pendingRemove);return{updateCount:q6,removeCount:e}},g=async(q6)=>{let e=q6||w,i=V==="details";W(!0),f(null),Z(null),v(null);try{let $6=v1("userSettings"),M6=0,j6=0,G6=new Set;for(let X6 of e){if(X6.pendingRemove){if(X6.installedPlugins&&X6.installedPlugins.length>0){let f6={...$6?.enabledPlugins};for(let N6 of X6.installedPlugins){let Z6=eQ(N6.name,X6.name);f6[Z6]=!1}W7("userSettings",{enabledPlugins:f6})}await Mh6(X6.name),j6++,d("tengu_marketplace_removed",{marketplace_name:X6.name,plugins_uninstalled:X6.installedPlugins?.length||0});continue}if(X6.pendingUpdate)await q56(X6.name,(f6)=>{v(f6)}),M6++,G6.add(X6.name.toLowerCase()),d("tengu_marketplace_updated",{marketplace_name:X6.name})}let w6=0;if(G6.size>0)w6=(await Q47(G6)).length;if(Sz(),$)await $();let o=await r_(),{enabled:s,disabled:a}=await LM(),n=[...s,...a],{marketplaces:l}=await Xp(o),A6=[];for(let{name:X6,config:f6,data:N6}of l){let Z6=n.filter((V6)=>V6.source.endsWith(`@${X6}`));A6.push({name:X6,source:h18(f6.source),lastUpdated:f6.lastUpdated,pluginCount:N6?.plugins.length,installedPlugins:Z6,pendingUpdate:!1,pendingRemove:!1,autoUpdate:fp6(X6,f6)})}if(A6.sort((X6,f6)=>{if(X6.name==="claude-plugin-directory")return-1;if(f6.name==="claude-plugin-directory")return 1;return X6.name.localeCompare(f6.name)}),j(A6),i&&S){let X6=A6.find((f6)=>f6.name===S.name);if(X6)R(X6)}let J6=[];if(M6>0){let X6=w6>0?` (${w6} ${A7(w6,"plugin")} bumped)`:"";J6.push(`Updated ${M6} ${A7(M6,"marketplace")}${X6}`)}if(j6>0)J6.push(`Removed ${j6} ${A7(j6,"marketplace")}`);if(J6.length>0){let X6=`${t6.tick} ${J6.join(", ")}`;if(i)Z(X6);else z(X6),setTimeout(q,2000,{type:"menu"})}else if(!i)q({type:"menu"})}catch($6){let M6=d6($6);if(f(M6),_)_(M6)}finally{W(!1),v(null)}},F=async()=>{if(!S)return;let q6=w.map((e)=>e.name===S.name?{...e,pendingRemove:!0}:e);j(q6),await g(q6)},U=(q6)=>{if(!q6)return[];let e=[{label:`Browse plugins (${q6.pluginCount??0})`,value:"browse"},{label:"Update marketplace",secondaryLabel:q6.lastUpdated?`(last updated ${new Date(q6.lastUpdated).toLocaleDateString()})`:void 0,value:"update"}];if(!aG6())e.push({label:q6.autoUpdate?"Disable auto-update":"Enable auto-update",value:"toggle-auto-update"});return e.push({label:"Remove marketplace",value:"remove"}),e},c=async(q6)=>{let e=!q6.autoUpdate;try{await K0K(q6.name,e),j((i)=>i.map(($6)=>$6.name===q6.name?{...$6,autoUpdate:e}:$6)),R((i)=>i?{...i,autoUpdate:e}:i)}catch(i){f(i instanceof Error?i.message:"Failed to update setting")}};if(P1("confirm:no",()=>{E("list"),I(0)},{context:"Confirmation",isActive:!P&&(V==="details"||V==="confirm-remove")}),P1("confirm:no",()=>{j((q6)=>q6.map((e)=>({...e,pendingUpdate:!1,pendingRemove:!1}))),X(0)},{context:"Confirmation",isActive:!P&&V==="list"&&p()}),P1("confirm:no",()=>{q({type:"menu"})},{context:"Confirmation",isActive:!P&&V==="list"&&!p()}),o7({"select:previous":()=>X((q6)=>Math.max(0,q6-1)),"select:next":()=>{let q6=w.length+1;X((e)=>Math.min(q6-1,e+1))},"select:accept":()=>{let q6=M-1;if(M===0)q({type:"add-marketplace"});else if(p())g();else{let e=w[q6];if(e)R(e),E("details"),I(0)}}},{context:"Select",isActive:!P&&V==="list"}),k4((q6)=>{let e=M-1;if((q6==="u"||q6==="U")&&e>=0)j((i)=>i.map(($6,M6)=>M6===e?{...$6,pendingUpdate:!$6.pendingUpdate,pendingRemove:$6.pendingUpdate?$6.pendingRemove:!1}:$6));else if((q6==="r"||q6==="R")&&e>=0){let i=w[e];if(i)R(i),E("confirm-remove")}},{isActive:!P&&V==="list"}),o7({"select:previous":()=>I((q6)=>Math.max(0,q6-1)),"select:next":()=>{let q6=U(S);I((e)=>Math.min(q6.length-1,e+1))},"select:accept":()=>{if(!S)return;let e=U(S)[x];if(e?.value==="browse")q({type:"browse-marketplace",targetMarketplace:S.name});else if(e?.value==="update"){let i=w.map(($6)=>$6.name===S.name?{...$6,pendingUpdate:!0}:$6);j(i),g(i)}else if(e?.value==="toggle-auto-update")c(S);else if(e?.value==="remove")E("confirm-remove")}},{context:"Select",isActive:!P&&V==="details"}),k4((q6)=>{if(q6==="y"||q6==="Y")F();else if(q6==="n"||q6==="N")E("list"),R(null)},{isActive:!P&&V==="confirm-remove"}),H)return d8.createElement(k,null,"Loading marketplaces…");if(w.length===0)return d8.createElement(u,{flexDirection:"column"},d8.createElement(u,{marginBottom:1},d8.createElement(k,{bold:!0},"Manage marketplaces")),d8.createElement(u,{flexDirection:"row",gap:1},d8.createElement(k,{color:"suggestion"},t6.pointer," +"),d8.createElement(k,{bold:!0,color:"suggestion"},"Add Marketplace")),d8.createElement(u,{marginLeft:3},d8.createElement(k,{dimColor:!0,italic:!0},Y.pending?d8.createElement(d8.Fragment,null,"Press ",Y.keyName," again to go back"):d8.createElement(I1,null,d8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),d8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"go back"})))));if(V==="confirm-remove"&&S){let q6=S.installedPlugins?.length||0;return d8.createElement(u,{flexDirection:"column"},d8.createElement(k,{bold:!0,color:"warning"},"Remove marketplace ",d8.createElement(k,{italic:!0},S.name),"?"),d8.createElement(u,{flexDirection:"column"},q6>0&&d8.createElement(u,{marginTop:1},d8.createElement(k,{color:"warning"},"This will also uninstall ",q6," ",A7(q6,"plugin")," from this marketplace:")),S.installedPlugins&&S.installedPlugins.length>0&&d8.createElement(u,{flexDirection:"column",marginTop:1,marginLeft:2},S.installedPlugins.map((e)=>d8.createElement(k,{key:e.name,dimColor:!0},"• ",e.name))),d8.createElement(u,{marginTop:1},d8.createElement(k,null,"Press ",d8.createElement(k,{bold:!0},"y")," to confirm or ",d8.createElement(k,{bold:!0},"n")," to cancel"))))}if(V==="details"&&S){let q6=S.pendingUpdate||P,e=U(S);return d8.createElement(u,{flexDirection:"column"},d8.createElement(k,{bold:!0},S.name),d8.createElement(k,{dimColor:!0},S.source),d8.createElement(u,{marginTop:1},d8.createElement(k,null,S.pluginCount||0," available"," ",A7(S.pluginCount||0,"plugin"))),S.installedPlugins&&S.installedPlugins.length>0&&d8.createElement(u,{flexDirection:"column",marginTop:1},d8.createElement(k,{bold:!0},"Installed plugins (",S.installedPlugins.length,"):"),d8.createElement(u,{flexDirection:"column",marginLeft:1},S.installedPlugins.map((i)=>d8.createElement(u,{key:i.name,flexDirection:"row",gap:1},d8.createElement(k,null,t6.bullet),d8.createElement(u,{flexDirection:"column"},d8.createElement(k,null,i.name),d8.createElement(k,{dimColor:!0},i.manifest.description)))))),q6&&d8.createElement(u,{marginTop:1,flexDirection:"column"},d8.createElement(k,{color:"claude"},"Updating marketplace…"),T&&d8.createElement(k,{dimColor:!0},T)),!q6&&G&&d8.createElement(u,{marginTop:1},d8.createElement(k,{color:"claude"},G)),!q6&&D&&d8.createElement(u,{marginTop:1},d8.createElement(k,{color:"error"},D)),!q6&&d8.createElement(u,{flexDirection:"column",marginTop:1},e.map((i,$6)=>{if(!i)return null;let M6=$6===x;return d8.createElement(u,{key:i.value},d8.createElement(k,{color:M6?"suggestion":void 0},M6?t6.pointer:" "," ",i.label),i.secondaryLabel&&d8.createElement(k,{dimColor:!0}," ",i.secondaryLabel))})),!q6&&!aG6()&&S.autoUpdate&&d8.createElement(u,{marginTop:1},d8.createElement(k,{dimColor:!0},"Auto-update enabled. Claude Code will automatically update this marketplace and its installed plugins.")),d8.createElement(u,{marginLeft:3},d8.createElement(k,{dimColor:!0,italic:!0},q6?d8.createElement(d8.Fragment,null,"Please wait…"):d8.createElement(I1,null,d8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),d8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"go back"})))))}let{updateCount:K6,removeCount:t}=C();return d8.createElement(u,{flexDirection:"column"},d8.createElement(u,{marginBottom:1},d8.createElement(k,{bold:!0},"Manage marketplaces")),d8.createElement(u,{flexDirection:"row",gap:1,marginBottom:1},d8.createElement(k,{color:M===0?"suggestion":void 0},M===0?t6.pointer:" "," +"),d8.createElement(k,{bold:!0,color:M===0?"suggestion":void 0},"Add Marketplace")),d8.createElement(u,{flexDirection:"column"},w.map((q6,e)=>{let i=e+1===M,$6=[];if(q6.pendingUpdate)$6.push("UPDATE");if(q6.pendingRemove)$6.push("REMOVE");return d8.createElement(u,{key:q6.name,flexDirection:"row",gap:1,marginBottom:1},d8.createElement(k,{color:i?"suggestion":void 0},i?t6.pointer:" "," ",q6.pendingRemove?t6.cross:t6.bullet),d8.createElement(u,{flexDirection:"column",flexGrow:1},d8.createElement(u,{flexDirection:"row",gap:1},d8.createElement(k,{bold:!0,strikethrough:q6.pendingRemove,dimColor:q6.pendingRemove},q6.name==="claude-plugins-official"&&d8.createElement(k,{color:"claude"},"✻ "),q6.name,q6.name==="claude-plugins-official"&&d8.createElement(k,{color:"claude"}," ✻")),$6.length>0&&d8.createElement(k,{color:"warning"},"[",$6.join(", "),"]")),d8.createElement(k,{dimColor:!0},q6.source),d8.createElement(k,{dimColor:!0},q6.pluginCount!==void 0&&d8.createElement(d8.Fragment,null,q6.pluginCount," available"),q6.installedPlugins&&q6.installedPlugins.length>0&&d8.createElement(d8.Fragment,null," • ",q6.installedPlugins.length," installed"),q6.lastUpdated&&d8.createElement(d8.Fragment,null," ","• Updated"," ",new Date(q6.lastUpdated).toLocaleDateString()))))})),p()&&d8.createElement(u,{marginTop:1,flexDirection:"column"},d8.createElement(k,null,d8.createElement(k,{bold:!0},"Pending changes:")," ",d8.createElement(k,{dimColor:!0},"Enter to apply")),K6>0&&d8.createElement(k,null,"• Update ",K6," ",A7(K6,"marketplace")),t>0&&d8.createElement(k,{color:"warning"},"• Remove ",t," ",A7(t,"marketplace"))),P&&d8.createElement(u,{marginTop:1},d8.createElement(k,{color:"claude"},"Processing changes…")),D&&d8.createElement(u,{marginTop:1},d8.createElement(k,{color:"error"},D)),d8.createElement(FMY,{exitState:Y,hasPendingActions:p()}))}function FMY(q){let K=z6(18),{exitState:_,hasPendingActions:z}=q;if(_.pending){let J;if(K[0]!==_.keyName)J=d8.createElement(u,{marginTop:1},d8.createElement(k,{dimColor:!0,italic:!0},"Press ",_.keyName," again to go back")),K[0]=_.keyName,K[1]=J;else J=K[1];return J}let Y;if(K[2]!==z)Y=z&&d8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"apply changes"}),K[2]=z,K[3]=Y;else Y=K[3];let $;if(K[4]!==z)$=!z&&d8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),K[4]=z,K[5]=$;else $=K[5];let A;if(K[6]!==z)A=!z&&d8.createElement(t8,{shortcut:"u",action:"update"}),K[6]=z,K[7]=A;else A=K[7];let O;if(K[8]!==z)O=!z&&d8.createElement(t8,{shortcut:"r",action:"remove"}),K[8]=z,K[9]=O;else O=K[9];let w=z?"cancel":"go back",j;if(K[10]!==w)j=d8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:w}),K[10]=w,K[11]=j;else j=K[11];let H;if(K[12]!==Y||K[13]!==$||K[14]!==A||K[15]!==O||K[16]!==j)H=d8.createElement(u,{marginTop:1},d8.createElement(k,{dimColor:!0,italic:!0},d8.createElement(I1,null,Y,$,A,O,j))),K[12]=Y,K[13]=$,K[14]=A,K[15]=O,K[16]=j,K[17]=H;else H=K[17];return H}var d8,jk;var GyK=y(()=>{q8();bq();k8();a5();QK();rK();s6();Oq();V1();y8();Jy();qd();Nw();WF8();bj();BZ();U1();d8=O6(D6(),1),jk=O6(D6(),1)});import{randomBytes as UMY}from"crypto";import{readFile as QMY,rename as dMY,unlink as cMY,writeFile as lMY}from"fs/promises";import{join as nMY}from"path";function TyK(){return nMY(GX(),iMY)}function oMY(q){let K=r8(q);if(typeof K!=="object"||K===null||!("plugins"in K)||typeof K.plugins!=="object"||K.plugins===null)return{};let _=K.plugins,z={};for(let[Y,$]of Object.entries(_))if($&&typeof $==="object"&&"flaggedAt"in $&&typeof $.flaggedAt==="string"){let A={flaggedAt:$.flaggedAt};if("seenAt"in $&&typeof $.seenAt==="string")A.seenAt=$.seenAt;z[Y]=A}return z}async function DF8(){try{let q=await QMY(TyK(),{encoding:"utf-8"});return oMY(q)}catch{return{}}}async function fF8(q){let K=TyK(),_=`${K}.${UMY(8).toString("hex")}.tmp`;try{await X8().mkdir(GX());let z=g6({plugins:q},null,2);await lMY(_,z,{encoding:"utf-8",mode:384}),await dMY(_,K),fy=q}catch(z){H6(z);try{await cMY(_)}catch{}}}async function vyK(){let q=await DF8(),K=Date.now(),_=!1;for(let[z,Y]of Object.entries(q))if(Y.seenAt&&K-new Date(Y.seenAt).getTime()>=rMY)delete q[z],_=!0;if(fy=q,_)await fF8(q)}function KS6(){return fy??{}}async function kyK(q){if(fy===null)fy=await DF8();let K={...fy,[q]:{flaggedAt:new Date().toISOString()}};await fF8(K),N(`Flagged plugin: ${q}`)}async function VyK(q){if(fy===null)fy=await DF8();let K=new Date().toISOString(),_=!1,z={...fy};for(let Y of q){let $=z[Y];if($&&!$.seenAt)z[Y]={...$,seenAt:K},_=!0}if(_)await fF8(z)}async function NyK(q){if(fy===null)fy=await DF8();if(!(q in fy))return;let{[q]:K,..._}=fy;fy=_,await fF8(_)}var iMY="flagged-plugins.json",rMY=172800000,fy=null;var ZF8=y(()=>{_8();e7();E8();l8();aV()});function k56(q){switch(q.type){case"path-not-found":return`${q.component} path not found: ${q.path}`;case"git-auth-failed":return`Git ${q.authType.toUpperCase()} authentication failed for ${q.gitUrl}`;case"git-timeout":return`Git ${q.operation} timed out for ${q.gitUrl}`;case"network-error":return`Network error accessing ${q.url}${q.details?`: ${q.details}`:""}`;case"manifest-parse-error":return`Failed to parse manifest at ${q.manifestPath}: ${q.parseError}`;case"manifest-validation-error":return`Invalid manifest at ${q.manifestPath}: ${q.validationErrors.join(", ")}`;case"plugin-not-found":return`Plugin "${q.pluginId}" not found in marketplace "${q.marketplace}"`;case"marketplace-not-found":return`Marketplace "${q.marketplace}" not found`;case"marketplace-load-failed":return`Failed to load marketplace "${q.marketplace}": ${q.reason}`;case"mcp-config-invalid":return`Invalid MCP server config for "${q.serverName}": ${q.validationError}`;case"mcp-server-suppressed-duplicate":{let _=q.duplicateOf.startsWith("plugin:")?`server provided by plugin "${q.duplicateOf.split(":")[1]??"?"}"`:`already-configured "${q.duplicateOf}"`;return`MCP server "${q.serverName}" skipped — same command/URL as ${_}`}case"hook-load-failed":return`Failed to load hooks from ${q.hookPath}: ${q.reason}`;case"component-load-failed":return`Failed to load ${q.component} from ${q.path}: ${q.reason}`;case"mcpb-download-failed":return`Failed to download MCPB from ${q.url}: ${q.reason}`;case"mcpb-extract-failed":return`Failed to extract MCPB ${q.mcpbPath}: ${q.reason}`;case"mcpb-invalid-manifest":return`MCPB manifest invalid at ${q.mcpbPath}: ${q.validationError}`;case"marketplace-blocked-by-policy":return q.blockedByBlocklist?`Marketplace "${q.marketplace}" is blocked by enterprise policy`:`Marketplace "${q.marketplace}" is not in the allowed marketplace list`;case"dependency-unsatisfied":return q.reason==="not-enabled"?`Dependency "${q.dependency}" is disabled`:`Dependency "${q.dependency}" is not installed`;case"lsp-config-invalid":return`Invalid LSP server config for "${q.serverName}": ${q.validationError}`;case"lsp-server-start-failed":return`LSP server "${q.serverName}" failed to start: ${q.reason}`;case"lsp-server-crashed":return q.signal?`LSP server "${q.serverName}" crashed with signal ${q.signal}`:`LSP server "${q.serverName}" crashed with exit code ${q.exitCode??"unknown"}`;case"lsp-request-timeout":return`LSP server "${q.serverName}" timed out on ${q.method} after ${q.timeoutMs}ms`;case"lsp-request-failed":return`LSP server "${q.serverName}" ${q.method} failed: ${q.error}`;case"plugin-cache-miss":return`Plugin "${q.plugin}" not cached at ${q.installPath}`;case"generic-error":return q.error}return $M(q)}function _S6(q){switch(q.type){case"path-not-found":return"Check that the path in your manifest or marketplace config is correct";case"git-auth-failed":return q.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 "${q.marketplace}"`;case"marketplace-not-found":return q.availableMarketplaces.length>0?`Available marketplaces: ${q.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":{if(q.duplicateOf.startsWith("plugin:"))return`Disable plugin "${q.duplicateOf.split(":")[1]??"the other plugin"}" if you want this plugin's version instead`;return`Remove "${q.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 ${q.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":if(q.blockedByBlocklist)return"This marketplace source is explicitly blocked by your administrator";return q.allowedSources.length>0?`Allowed sources: ${q.allowedSources.join(", ")}`:"Contact your administrator to configure allowed marketplace sources";case"dependency-unsatisfied":return q.reason==="not-enabled"?`Enable "${q.dependency}" or uninstall "${q.plugin}"`:`Install "${q.dependency}" or uninstall "${q.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}let K=q;return null}var d47=()=>{};function yyK(q){let K=z6(142),{item:_,isSelected:z}=q,[Y]=Aq();if(_.type==="plugin"){let T,v;if(_.pendingToggle){let t;if(K[0]!==Y)t=h7("suggestion",Y)(t6.arrowRight),K[0]=Y,K[1]=t;else t=K[1];T=t,v=_.pendingToggle==="will-enable"?"will enable":"will disable"}else if(_.errorCount>0){let t;if(K[2]!==Y)t=h7("error",Y)(t6.cross),K[2]=Y,K[3]=t;else t=K[3];T=t;let q6=_.errorCount,e;if(K[4]!==_.errorCount)e=A7(_.errorCount,"error"),K[4]=_.errorCount,K[5]=e;else e=K[5];v=`${q6} ${e}`}else if(!_.isEnabled){let t;if(K[6]!==Y)t=h7("inactive",Y)(t6.radioOff),K[6]=Y,K[7]=t;else t=K[7];T=t,v="disabled"}else{let t;if(K[8]!==Y)t=h7("success",Y)(t6.tick),K[8]=Y,K[9]=t;else t=K[9];T=t,v="enabled"}let V=z?"suggestion":void 0,E=z?`${t6.pointer} `:" ",S;if(K[10]!==V||K[11]!==E)S=_4.createElement(k,{color:V},E),K[10]=V,K[11]=E,K[12]=S;else S=K[12];let R=z?"suggestion":void 0,x;if(K[13]!==_.name||K[14]!==R)x=_4.createElement(k,{color:R},_.name),K[13]=_.name,K[14]=R,K[15]=x;else x=K[15];let I=!z,B;if(K[16]===Symbol.for("react.memo_cache_sentinel"))B=_4.createElement(k,{backgroundColor:"userMessageBackground"},"Plugin"),K[16]=B;else B=K[16];let p;if(K[17]!==I)p=_4.createElement(k,{dimColor:I}," ",B),K[17]=I,K[18]=p;else p=K[18];let C;if(K[19]!==_.marketplace)C=_4.createElement(k,{dimColor:!0}," · ",_.marketplace),K[19]=_.marketplace,K[20]=C;else C=K[20];let g=!z,F;if(K[21]!==T||K[22]!==g)F=_4.createElement(k,{dimColor:g}," · ",T," "),K[21]=T,K[22]=g,K[23]=F;else F=K[23];let U=!z,c;if(K[24]!==v||K[25]!==U)c=_4.createElement(k,{dimColor:U},v),K[24]=v,K[25]=U,K[26]=c;else c=K[26];let K6;if(K[27]!==F||K[28]!==c||K[29]!==S||K[30]!==x||K[31]!==p||K[32]!==C)K6=_4.createElement(u,null,S,x,p,C,F,c),K[27]=F,K[28]=c,K[29]=S,K[30]=x,K[31]=p,K[32]=C,K[33]=K6;else K6=K[33];return K6}if(_.type==="flagged-plugin"){let T;if(K[34]!==Y)T=h7("warning",Y)(t6.warning),K[34]=Y,K[35]=T;else T=K[35];let v=T,V=z?"suggestion":void 0,E=z?`${t6.pointer} `:" ",S;if(K[36]!==V||K[37]!==E)S=_4.createElement(k,{color:V},E),K[36]=V,K[37]=E,K[38]=S;else S=K[38];let R=z?"suggestion":void 0,x;if(K[39]!==_.name||K[40]!==R)x=_4.createElement(k,{color:R},_.name),K[39]=_.name,K[40]=R,K[41]=x;else x=K[41];let I=!z,B;if(K[42]===Symbol.for("react.memo_cache_sentinel"))B=_4.createElement(k,{backgroundColor:"userMessageBackground"},"Plugin"),K[42]=B;else B=K[42];let p;if(K[43]!==I)p=_4.createElement(k,{dimColor:I}," ",B),K[43]=I,K[44]=p;else p=K[44];let C;if(K[45]!==_.marketplace)C=_4.createElement(k,{dimColor:!0}," · ",_.marketplace),K[45]=_.marketplace,K[46]=C;else C=K[46];let g=!z,F;if(K[47]!==v||K[48]!==g)F=_4.createElement(k,{dimColor:g}," · ",v," "),K[47]=v,K[48]=g,K[49]=F;else F=K[49];let U=!z,c;if(K[50]!==U)c=_4.createElement(k,{dimColor:U},"removed"),K[50]=U,K[51]=c;else c=K[51];let K6;if(K[52]!==C||K[53]!==F||K[54]!==c||K[55]!==S||K[56]!==x||K[57]!==p)K6=_4.createElement(u,null,S,x,p,C,F,c),K[52]=C,K[53]=F,K[54]=c,K[55]=S,K[56]=x,K[57]=p,K[58]=K6;else K6=K[58];return K6}if(_.type==="failed-plugin"){let T;if(K[59]!==Y)T=h7("error",Y)(t6.cross),K[59]=Y,K[60]=T;else T=K[60];let v=T,V=_.errorCount,E;if(K[61]!==_.errorCount)E=A7(_.errorCount,"error"),K[61]=_.errorCount,K[62]=E;else E=K[62];let S=`failed to load · ${V} ${E}`,R=z?"suggestion":void 0,x=z?`${t6.pointer} `:" ",I;if(K[63]!==R||K[64]!==x)I=_4.createElement(k,{color:R},x),K[63]=R,K[64]=x,K[65]=I;else I=K[65];let B=z?"suggestion":void 0,p;if(K[66]!==_.name||K[67]!==B)p=_4.createElement(k,{color:B},_.name),K[66]=_.name,K[67]=B,K[68]=p;else p=K[68];let C=!z,g;if(K[69]===Symbol.for("react.memo_cache_sentinel"))g=_4.createElement(k,{backgroundColor:"userMessageBackground"},"Plugin"),K[69]=g;else g=K[69];let F;if(K[70]!==C)F=_4.createElement(k,{dimColor:C}," ",g),K[70]=C,K[71]=F;else F=K[71];let U;if(K[72]!==_.marketplace)U=_4.createElement(k,{dimColor:!0}," · ",_.marketplace),K[72]=_.marketplace,K[73]=U;else U=K[73];let c=!z,K6;if(K[74]!==v||K[75]!==c)K6=_4.createElement(k,{dimColor:c}," · ",v," "),K[74]=v,K[75]=c,K[76]=K6;else K6=K[76];let t=!z,q6;if(K[77]!==S||K[78]!==t)q6=_4.createElement(k,{dimColor:t},S),K[77]=S,K[78]=t,K[79]=q6;else q6=K[79];let e;if(K[80]!==F||K[81]!==U||K[82]!==K6||K[83]!==q6||K[84]!==I||K[85]!==p)e=_4.createElement(u,null,I,p,F,U,K6,q6),K[80]=F,K[81]=U,K[82]=K6,K[83]=q6,K[84]=I,K[85]=p,K[86]=e;else e=K[86];return e}let $,A;if(_.status==="connected"){let T;if(K[87]!==Y)T=h7("success",Y)(t6.tick),K[87]=Y,K[88]=T;else T=K[88];$=T,A="connected"}else if(_.status==="disabled"){let T;if(K[89]!==Y)T=h7("inactive",Y)(t6.radioOff),K[89]=Y,K[90]=T;else T=K[90];$=T,A="disabled"}else if(_.status==="pending"){let T;if(K[91]!==Y)T=h7("inactive",Y)(t6.radioOff),K[91]=Y,K[92]=T;else T=K[92];$=T,A="connecting…"}else if(_.status==="needs-auth"){let T;if(K[93]!==Y)T=h7("warning",Y)(t6.triangleUpOutline),K[93]=Y,K[94]=T;else T=K[94];$=T,A="Enter to auth"}else{let T;if(K[95]!==Y)T=h7("error",Y)(t6.cross),K[95]=Y,K[96]=T;else T=K[96];$=T,A="failed"}if(_.indented){let T=z?"suggestion":void 0,v=z?`${t6.pointer} `:" ",V;if(K[97]!==T||K[98]!==v)V=_4.createElement(k,{color:T},v),K[97]=T,K[98]=v,K[99]=V;else V=K[99];let E=!z,S;if(K[100]!==E)S=_4.createElement(k,{dimColor:E},"└ "),K[100]=E,K[101]=S;else S=K[101];let R=z?"suggestion":void 0,x;if(K[102]!==_.name||K[103]!==R)x=_4.createElement(k,{color:R},_.name),K[102]=_.name,K[103]=R,K[104]=x;else x=K[104];let I=!z,B;if(K[105]===Symbol.for("react.memo_cache_sentinel"))B=_4.createElement(k,{backgroundColor:"userMessageBackground"},"MCP"),K[105]=B;else B=K[105];let p;if(K[106]!==I)p=_4.createElement(k,{dimColor:I}," ",B),K[106]=I,K[107]=p;else p=K[107];let C=!z,g;if(K[108]!==$||K[109]!==C)g=_4.createElement(k,{dimColor:C}," · ",$," "),K[108]=$,K[109]=C,K[110]=g;else g=K[110];let F=!z,U;if(K[111]!==A||K[112]!==F)U=_4.createElement(k,{dimColor:F},A),K[111]=A,K[112]=F,K[113]=U;else U=K[113];let c;if(K[114]!==p||K[115]!==g||K[116]!==U||K[117]!==V||K[118]!==S||K[119]!==x)c=_4.createElement(u,null,V,S,x,p,g,U),K[114]=p,K[115]=g,K[116]=U,K[117]=V,K[118]=S,K[119]=x,K[120]=c;else c=K[120];return c}let O=z?"suggestion":void 0,w=z?`${t6.pointer} `:" ",j;if(K[121]!==O||K[122]!==w)j=_4.createElement(k,{color:O},w),K[121]=O,K[122]=w,K[123]=j;else j=K[123];let H=z?"suggestion":void 0,J;if(K[124]!==_.name||K[125]!==H)J=_4.createElement(k,{color:H},_.name),K[124]=_.name,K[125]=H,K[126]=J;else J=K[126];let M=!z,X;if(K[127]===Symbol.for("react.memo_cache_sentinel"))X=_4.createElement(k,{backgroundColor:"userMessageBackground"},"MCP"),K[127]=X;else X=K[127];let P;if(K[128]!==M)P=_4.createElement(k,{dimColor:M}," ",X),K[128]=M,K[129]=P;else P=K[129];let W=!z,D;if(K[130]!==$||K[131]!==W)D=_4.createElement(k,{dimColor:W}," · ",$," "),K[130]=$,K[131]=W,K[132]=D;else D=K[132];let f=!z,G;if(K[133]!==A||K[134]!==f)G=_4.createElement(k,{dimColor:f},A),K[133]=A,K[134]=f,K[135]=G;else G=K[135];let Z;if(K[136]!==D||K[137]!==G||K[138]!==j||K[139]!==J||K[140]!==P)Z=_4.createElement(u,null,j,J,P,D,G),K[136]=D,K[137]=G,K[138]=j,K[139]=J,K[140]=P,K[141]=Z;else Z=K[141];return Z}var _4;var EyK=y(()=>{q8();bq();s6();_4=O6(D6(),1)});import*as oH6 from"fs/promises";import*as zS6 from"path";async function LyK(q){try{return(await oH6.readdir(q,{withFileTypes:!0})).filter((_)=>_.isFile()&&_.name.endsWith(".md")).map((_)=>{return zS6.basename(_.name,".md")})}catch(K){let _=d6(K);return N(`Failed to read plugin components from ${q}: ${_}`,{level:"error"}),H6(x1(K)),[]}}async function aMY(q){try{let K=await oH6.readdir(q,{withFileTypes:!0}),_=[];for(let z of K)if(z.isDirectory()||z.isSymbolicLink()){let Y=zS6.join(q,z.name,"SKILL.md");try{if((await oH6.stat(Y)).isFile())_.push(z.name)}catch{}}return _}catch(K){let _=d6(K);return N(`Failed to read skill directories from ${q}: ${_}`,{level:"error"}),H6(x1(K)),[]}}function sMY({plugin:q,marketplace:K}){let[_,z]=DY.useState(null),[Y,$]=DY.useState(!0),[A,O]=DY.useState(null);if(DY.useEffect(()=>{async function j(){try{if(K==="builtin"){let M=HK4(q.name);if(M){let X=M.skills?.map((D)=>D.name)??[],P=M.hooks?Object.keys(M.hooks):[],W=M.mcpServers?Object.keys(M.mcpServers):[];z({commands:null,agents:null,skills:X.length>0?X:null,hooks:P.length>0?P:null,mcpServers:W.length>0?W:null})}else O(`Built-in plugin ${q.name} not found`);$(!1);return}let J=(await r0(K)).plugins.find((M)=>M.name===q.name);if(J){let M=[];if(q.commandsPath)M.push(q.commandsPath);if(q.commandsPaths)M.push(...q.commandsPaths);let X=[];for(let T of M)if(typeof T==="string"){let v=await LyK(T);X.push(...v)}let P=[];if(q.agentsPath)P.push(q.agentsPath);if(q.agentsPaths)P.push(...q.agentsPaths);let W=[];for(let T of P)if(typeof T==="string"){let v=await LyK(T);W.push(...v)}let D=[];if(q.skillsPath)D.push(q.skillsPath);if(q.skillsPaths)D.push(...q.skillsPaths);let f=[];for(let T of D)if(typeof T==="string"){let v=await aMY(T);f.push(...v)}let G=[];if(q.hooksConfig)G.push(Object.keys(q.hooksConfig));if(J.hooks)G.push(J.hooks);let Z=[];if(q.mcpServers)Z.push(Object.keys(q.mcpServers));if(J.mcpServers)Z.push(J.mcpServers);z({commands:X.length>0?X:null,agents:W.length>0?W:null,skills:f.length>0?f:null,hooks:G.length>0?G:null,mcpServers:Z.length>0?Z:null})}else O(`Plugin ${q.name} not found in marketplace`)}catch(H){O(H instanceof Error?H.message:"Failed to load components")}finally{$(!1)}}j()},[q.name,q.commandsPath,q.commandsPaths,q.agentsPath,q.agentsPaths,q.skillsPath,q.skillsPaths,q.hooksConfig,q.mcpServers,K]),Y)return null;if(A)return W8.createElement(u,{flexDirection:"column",marginBottom:1},W8.createElement(k,{bold:!0},"Components:"),W8.createElement(k,{dimColor:!0},"Error: ",A));if(!_)return null;if(!(_.commands||_.agents||_.skills||_.hooks||_.mcpServers))return null;return W8.createElement(u,{flexDirection:"column",marginBottom:1},W8.createElement(k,{bold:!0},"Installed components:"),_.commands?W8.createElement(k,{dimColor:!0},"• Commands:"," ",typeof _.commands==="string"?_.commands:Array.isArray(_.commands)?_.commands.join(", "):Object.keys(_.commands).join(", ")):null,_.agents?W8.createElement(k,{dimColor:!0},"• Agents:"," ",typeof _.agents==="string"?_.agents:Array.isArray(_.agents)?_.agents.join(", "):Object.keys(_.agents).join(", ")):null,_.skills?W8.createElement(k,{dimColor:!0},"• Skills:"," ",typeof _.skills==="string"?_.skills:Array.isArray(_.skills)?_.skills.join(", "):Object.keys(_.skills).join(", ")):null,_.hooks?W8.createElement(k,{dimColor:!0},"• Hooks:"," ",typeof _.hooks==="string"?_.hooks:Array.isArray(_.hooks)?_.hooks.map(String).join(", "):typeof _.hooks==="object"&&_.hooks!==null?Object.keys(_.hooks).join(", "):String(_.hooks)):null,_.mcpServers?W8.createElement(k,{dimColor:!0},"• MCP Servers:"," ",typeof _.mcpServers==="string"?_.mcpServers:Array.isArray(_.mcpServers)?_.mcpServers.map(String).join(", "):typeof _.mcpServers==="object"&&_.mcpServers!==null?Object.keys(_.mcpServers).join(", "):String(_.mcpServers)):null)}async function tMY(q,K){let z=(await r0(K))?.plugins.find((Y)=>Y.name===q);if(z&&typeof z.source==="string")return`Local plugins cannot be updated remotely. To update, modify the source at: ${z.source}`;return null}function eMY(q){return q.filter((K)=>{let _=K.source.split("@")[1]||"local";return!zR(`${K.name}@${_}`)})}function RyK({setViewState:q,setResult:K,onManageComplete:_,onSearchModeChange:z,targetPlugin:Y,targetMarketplace:$,action:A}){let O=P8((I6)=>I6.mcp.clients),w=P8((I6)=>I6.mcp.tools),j=P8((I6)=>I6.plugins.errors),H=KS6(),[J,M]=DY.useState(!1),X=DY.useCallback((I6)=>{M(I6),z?.(I6)},[z]),P=CO(),{columns:W}=t1(),[D,f]=DY.useState("plugin-list"),{query:G,setQuery:Z,cursorOffset:T}=XR({isActive:D==="plugin-list"&&J,onExit:()=>{X(!1)}}),[v,V]=DY.useState(null),[E,S]=DY.useState([]),[R,x]=DY.useState([]),[I,B]=DY.useState(!0),[p,C]=DY.useState(new Map),g=DY.useRef(!1),F=DY.useRef(void 0),U=f56(),c=W8.useCallback(()=>{if(D==="plugin-details")f("plugin-list"),V(null),a(null);else if(typeof D==="object"&&D.type==="failed-plugin-details")f("plugin-list"),a(null);else if(D==="configuring")f("plugin-details"),l(null);else if(typeof D==="object"&&(D.type==="plugin-options"||D.type==="configuring-options")){if(f("plugin-list"),V(null),K("Plugin enabled. Configuration skipped — run /reload-plugins to apply."),_)_()}else if(typeof D==="object"&&D.type==="flagged-detail")f("plugin-list"),a(null);else if(typeof D==="object"&&D.type==="mcp-detail")f("plugin-list"),a(null);else if(typeof D==="object"&&D.type==="mcp-tools")f({type:"mcp-detail",client:D.client});else if(typeof D==="object"&&D.type==="mcp-tool-detail")f({type:"mcp-tools",client:D.client});else{if(p.size>0){K("Run /reload-plugins to apply plugin changes.");return}q({type:"menu"})}},[D,q,p,K]);P1("confirm:no",c,{context:"Confirmation",isActive:(D!=="plugin-list"||!J)&&D!=="confirm-project-uninstall"&&!(typeof D==="object"&&D.type==="confirm-data-cleanup")});let K6=(I6)=>{if(I6.type==="connected")return"connected";if(I6.type==="disabled")return"disabled";if(I6.type==="pending")return"pending";if(I6.type==="needs-auth")return"needs-auth";return"failed"},t=DY.useMemo(()=>{let I6=Z7(),C6=new Map;for(let W6 of O)if(W6.name.startsWith("plugin:")){let v6=W6.name.split(":");if(v6.length>=3){let m6=v6[1],K8=v6.slice(2).join(":"),H8=C6.get(m6)||[];H8.push({displayName:K8,client:W6}),C6.set(m6,H8)}}let l6=[];for(let W6 of R){let v6=`${W6.plugin.name}@${W6.marketplace}`,m6=I6?.enabledPlugins?.[v6]!==!1,K8=j.filter((M8)=>("plugin"in M8)&&M8.plugin===W6.plugin.name||M8.source===v6||M8.source.startsWith(`${W6.plugin.name}@`)),H8=W6.plugin.isBuiltin?"builtin":W6.scope||"user";l6.push({item:{type:"plugin",id:v6,name:W6.plugin.name,description:W6.plugin.manifest.description,marketplace:W6.marketplace,scope:H8,isEnabled:m6,errorCount:K8.length,errors:K8,plugin:W6.plugin,pendingEnable:W6.pendingEnable,pendingUpdate:W6.pendingUpdate,pendingToggle:p.get(v6)},originalScope:H8,childMcps:C6.get(W6.plugin.name)||[]})}let S6=new Set(l6.map(({item:W6})=>W6.id)),E6=new Set(l6.map(({item:W6})=>W6.name)),R6=new Map;for(let W6 of j){if(S6.has(W6.source)||"plugin"in W6&&typeof W6.plugin==="string"&&E6.has(W6.plugin))continue;let v6=R6.get(W6.source)||[];v6.push(W6),R6.set(W6.source,v6)}let h6=G56(),x6=[];for(let[W6,v6]of R6){if(W6 in H)continue;let m6=Z4(W6),K8=m6.name||W6,H8=m6.marketplace||"unknown",M8=h6.get(W6),X1=M8==="flag"||M8===void 0?"user":M8;x6.push({type:"failed-plugin",id:W6,name:K8,marketplace:H8,scope:X1,errorCount:v6.length,errors:v6})}let b6=[];for(let W6 of O){if(W6.name==="ide")continue;if(W6.name.startsWith("plugin:"))continue;b6.push({type:"mcp",id:`mcp:${W6.name}`,name:W6.name,description:void 0,scope:W6.config.scope,status:K6(W6),client:W6})}let Q6={flagged:-1,project:0,local:1,user:2,enterprise:3,managed:4,dynamic:5,builtin:6},Y6=[],_6=new Map;for(let{item:W6,originalScope:v6,childMcps:m6}of l6){let K8=W6.scope;if(!_6.has(K8))_6.set(K8,[]);_6.get(K8).push(W6);for(let{displayName:H8,client:M8}of m6){let X1=v6==="builtin"?"user":v6;if(!_6.has(X1))_6.set(X1,[]);_6.get(X1).push({type:"mcp",id:`mcp:${M8.name}`,name:H8,description:void 0,scope:X1,status:K6(M8),client:M8,indented:!0})}}for(let W6 of b6){let v6=W6.scope;if(!_6.has(v6))_6.set(v6,[]);_6.get(v6).push(W6)}for(let W6 of x6){let v6=W6.scope;if(!_6.has(v6))_6.set(v6,[]);_6.get(v6).push(W6)}for(let[W6,v6]of Object.entries(H)){let m6=Z4(W6),K8=m6.name||W6,H8=m6.marketplace||"unknown";if(!_6.has("flagged"))_6.set("flagged",[]);_6.get("flagged").push({type:"flagged-plugin",id:W6,name:K8,marketplace:H8,scope:"flagged",reason:"delisted",text:"Removed from marketplace",flaggedAt:v6.flaggedAt})}let F6=[..._6.keys()].sort((W6,v6)=>(Q6[W6]??99)-(Q6[v6]??99));for(let W6 of F6){let v6=_6.get(W6),m6=[],K8=[],H8=0;while(H8<v6.length){let M8=v6[H8];if(M8.type==="plugin"||M8.type==="failed-plugin"||M8.type==="flagged-plugin"){let X1=[M8];H8++;let j1=v6[H8];while(j1?.type==="mcp"&&j1.indented)X1.push(j1),H8++,j1=v6[H8];m6.push(X1)}else if(M8.type==="mcp"&&!M8.indented)K8.push(M8),H8++;else H8++}m6.sort((M8,X1)=>M8[0].name.localeCompare(X1[0].name)),K8.sort((M8,X1)=>M8.name.localeCompare(X1.name));for(let M8 of m6)Y6.push(...M8);Y6.push(...K8)}return Y6},[R,O,j,p,H]),q6=DY.useMemo(()=>t.filter((I6)=>I6.type==="flagged-plugin").map((I6)=>I6.id),[t]);DY.useEffect(()=>{if(q6.length>0)VyK(q6)},[q6]);let e=DY.useMemo(()=>{if(!G)return t;let I6=G.toLowerCase();return t.filter((C6)=>C6.name.toLowerCase().includes(I6)||("description"in C6)&&C6.description?.toLowerCase().includes(I6))},[t,G]),[i,$6]=DY.useState(0),M6=ah6({totalItems:e.length,selectedIndex:i,maxVisible:8}),[j6,G6]=DY.useState(0),[w6,o]=DY.useState(!1),[s,a]=DY.useState(null),[n,l]=DY.useState(null),[A6,J6]=DY.useState(!1),[X6,f6]=DY.useState(!1);DY.useEffect(()=>{if(!v){f6(!1);return}async function I6(){let C6=v.plugin.manifest.mcpServers,l6=!1;if(C6)l6=typeof C6==="string"&&kC(C6)||Array.isArray(C6)&&C6.some((S6)=>typeof S6==="string"&&kC(S6));if(!l6)try{let S6=zS6.join(v.plugin.path,".."),E6=zS6.join(S6,".claude-plugin","marketplace.json"),R6=await oH6.readFile(E6,"utf-8"),x6=r8(R6).plugins?.find((b6)=>b6.name===v.plugin.name);if(x6?.mcpServers){let b6=x6.mcpServers;l6=typeof b6==="string"&&kC(b6)||Array.isArray(b6)&&b6.some((Q6)=>typeof Q6==="string"&&kC(Q6))}}catch(S6){N(`Failed to read raw marketplace.json: ${S6}`)}f6(l6)}I6()},[v]),DY.useEffect(()=>{async function I6(){B(!0);try{let{enabled:C6,disabled:l6}=await LM(),S6=Z7(),E6=eMY([...C6,...l6]),R6={};for(let b6 of E6){let Q6=b6.source.split("@")[1]||"local";if(!R6[Q6])R6[Q6]=[];R6[Q6].push(b6)}let h6=[];for(let[b6,Q6]of Object.entries(R6)){let Y6=$7(Q6,(F6)=>{let W6=`${F6.name}@${b6}`;return S6?.enabledPlugins?.[W6]!==!1}),_6=Q6.length-Y6;h6.push({name:b6,installedPlugins:Q6,enabledCount:Y6,disabledCount:_6})}h6.sort((b6,Q6)=>{if(b6.name==="claude-plugin-directory")return-1;if(Q6.name==="claude-plugin-directory")return 1;return b6.name.localeCompare(Q6.name)}),S(h6);let x6=[];for(let b6 of h6)for(let Q6 of b6.installedPlugins){let Y6=`${Q6.name}@${b6.name}`,_6=Q6.isBuiltin?"builtin":XF8(Y6).scope;x6.push({plugin:Q6,marketplace:b6.name,scope:_6,pendingEnable:void 0,pendingUpdate:!1})}x(x6),$6(0)}finally{B(!1)}}I6()},[]),DY.useEffect(()=>{if(g.current)return;if(Y&&E.length>0&&!I){let{name:I6,marketplace:C6}=Z4(Y),l6=$??C6,S6=l6?E.filter((R6)=>R6.name===l6):E;for(let R6 of S6){let h6=R6.installedPlugins.find((x6)=>x6.name===I6);if(h6){let x6=`${h6.name}@${R6.name}`,{scope:b6}=XF8(x6),Q6={plugin:h6,marketplace:R6.name,scope:b6,pendingEnable:void 0,pendingUpdate:!1};V(Q6),f("plugin-details"),F.current=A,g.current=!0;return}}let E6=t.find((R6)=>R6.type==="failed-plugin"&&R6.name===I6);if(E6&&E6.type==="failed-plugin")f({type:"failed-plugin-details",plugin:{id:E6.id,name:E6.name,marketplace:E6.marketplace,errors:E6.errors,scope:E6.scope}}),g.current=!0;if(!g.current&&A)g.current=!0,K(`Plugin "${Y}" is not installed in this project`)}},[Y,$,E,I,t,A,K]);let N6=async(I6)=>{if(!v)return;let C6=v.scope||"user",l6=C6==="builtin";if(l6&&(I6==="update"||I6==="uninstall")){a("Built-in plugins cannot be updated or uninstalled.");return}if(!l6&&!sh6(C6)&&I6!=="update"){a("This plugin is managed by your organization. Contact your admin to disable it.");return}o(!0),a(null);try{let S6=`${v.plugin.name}@${v.marketplace}`,E6;switch(I6){case"enable":{let _6=await v56(S6);if(!_6.success)throw Error(_6.message);break}case"disable":{let _6=await th6(S6);if(!_6.success)throw Error(_6.message);E6=_6.reverseDependents;break}case"uninstall":{if(l6)break;if(!sh6(C6))break;if(XyK(S6)){o(!1),f("confirm-project-uninstall");return}let _6=cX().plugins[S6],W6=!_6||_6.length<=1?await r54(S6):null;if(W6){o(!1),f({type:"confirm-data-cleanup",size:W6});return}let v6=await _s(S6,C6);if(!v6.success)throw Error(v6.message);E6=v6.reverseDependents;break}case"update":{if(l6)break;let _6=await eh6(S6,C6);if(!_6.success)throw Error(_6.message);if(_6.alreadyUpToDate){if(K(`${v.plugin.name} is already at the latest version (${_6.newVersion}).`),_)await _();q({type:"menu"});return}break}}Sz();let R6=`${v.plugin.name}@${v.marketplace}`;if(Z7()?.enabledPlugins?.[R6]!==!1){o(!1),f({type:"plugin-options"});return}let b6=I6==="enable"?"Enabled":I6==="disable"?"Disabled":I6==="update"?"Updated":"Uninstalled",Q6=E6&&E6.length>0?` · required by ${E6.join(", ")}`:"",Y6=`✓ ${b6} ${v.plugin.name}${Q6}. Run /reload-plugins to apply.`;if(K(Y6),_)await _();q({type:"menu"})}catch(S6){o(!1);let E6=S6 instanceof Error?S6.message:String(S6);a(`Failed to ${I6}: ${E6}`),H6(x1(S6))}},Z6=DY.useRef(N6);Z6.current=N6,DY.useEffect(()=>{if(D==="plugin-details"&&v&&F.current){let I6=F.current;F.current=void 0,Z6.current(I6)}},[D,v]);let V6=W8.useCallback(()=>{if(i>=e.length)return;let I6=e[i];if(I6?.type==="flagged-plugin")return;if(I6?.type==="plugin"){let C6=`${I6.plugin.name}@${I6.marketplace}`,l6=Z7(),S6=p.get(C6),E6=l6?.enabledPlugins?.[C6]!==!1,R6=I6.scope;if(R6==="builtin"||sh6(R6)){let x6=new Map(p);if(S6)x6.delete(C6),(async()=>{try{if(S6==="will-disable")await v56(C6);else await th6(C6);Sz()}catch(b6){H6(b6)}})();else x6.set(C6,E6?"will-disable":"will-enable"),(async()=>{try{if(E6)await th6(C6);else await v56(C6);Sz()}catch(b6){H6(b6)}})();C(x6)}}else if(I6?.type==="mcp")U(I6.client.name)},[i,e,p,R,U]),y6=W8.useCallback(()=>{if(i>=e.length)return;let I6=e[i];if(I6?.type==="plugin"){let C6=R.find((l6)=>l6.plugin.name===I6.plugin.name&&l6.marketplace===I6.marketplace);if(C6)V(C6),f("plugin-details"),G6(0),a(null)}else if(I6?.type==="flagged-plugin")f({type:"flagged-detail",plugin:{id:I6.id,name:I6.name,marketplace:I6.marketplace,reason:I6.reason,text:I6.text,flaggedAt:I6.flaggedAt}}),a(null);else if(I6?.type==="failed-plugin")f({type:"failed-plugin-details",plugin:{id:I6.id,name:I6.name,marketplace:I6.marketplace,errors:I6.errors,scope:I6.scope}}),G6(0),a(null);else if(I6?.type==="mcp")f({type:"mcp-detail",client:I6.client}),a(null)},[i,e,R]);o7({"select:previous":()=>{if(i===0)X(!0);else M6.handleSelectionChange(i-1,$6)},"select:next":()=>{if(i<e.length-1)M6.handleSelectionChange(i+1,$6)},"select:accept":y6},{context:"Select",isActive:D==="plugin-list"&&!J}),o7({"plugin:toggle":V6},{context:"Plugin",isActive:D==="plugin-list"&&!J});let T6=W8.useCallback(()=>{if(typeof D!=="object"||D.type!=="flagged-detail")return;NyK(D.plugin.id),f("plugin-list")},[D]);o7({"select:accept":T6},{context:"Select",isActive:typeof D==="object"&&D.type==="flagged-detail"});let n6=W8.useMemo(()=>{if(D!=="plugin-details"||!v)return[];let I6=Z7(),C6=`${v.plugin.name}@${v.marketplace}`,l6=I6?.enabledPlugins?.[C6]!==!1,S6=v.marketplace==="builtin",E6=[];if(E6.push({label:l6?"Disable plugin":"Enable plugin",action:()=>void N6(l6?"disable":"enable")}),!S6){if(E6.push({label:v.pendingUpdate?"Unmark for update":"Mark for update",action:async()=>{try{let R6=await tMY(v.plugin.name,v.marketplace);if(R6){a(R6);return}let h6=[...R],x6=h6.findIndex((b6)=>b6.plugin.name===v.plugin.name&&b6.marketplace===v.marketplace);if(x6!==-1)h6[x6].pendingUpdate=!v.pendingUpdate,x(h6),V({...v,pendingUpdate:!v.pendingUpdate})}catch(R6){a(R6 instanceof Error?R6.message:"Failed to check plugin update availability")}}}),X6)E6.push({label:"Configure",action:async()=>{J6(!0);try{let R6=v.plugin.manifest.mcpServers,h6=null;if(typeof R6==="string"&&kC(R6))h6=R6;else if(Array.isArray(R6)){for(let Q6 of R6)if(typeof Q6==="string"&&kC(Q6)){h6=Q6;break}}if(!h6){a("No MCPB file found in plugin"),J6(!1);return}let x6=`${v.plugin.name}@${v.marketplace}`,b6=await Bi6(h6,v.plugin.path,x6,void 0,void 0,!0);if("status"in b6&&b6.status==="needs-config")l(b6),f("configuring");else a("Failed to load MCPB for configuration")}catch(R6){let h6=d6(R6);a(`Failed to load configuration: ${h6}`)}finally{J6(!1)}}});if(v.plugin.manifest.userConfig&&Object.keys(v.plugin.manifest.userConfig).length>0)E6.push({label:"Configure options",action:()=>{f({type:"configuring-options",schema:v.plugin.manifest.userConfig})}});E6.push({label:"Update now",action:()=>void N6("update")}),E6.push({label:"Uninstall",action:()=>void N6("uninstall")})}if(v.plugin.manifest.homepage)E6.push({label:"Open homepage",action:()=>void m3(v.plugin.manifest.homepage)});if(v.plugin.manifest.repository)E6.push({label:"View repository",action:()=>void m3(v.plugin.manifest.repository)});return E6.push({label:"Back to plugin list",action:()=>{f("plugin-list"),V(null),a(null)}}),E6},[D,v,X6,R]);if(o7({"select:previous":()=>{if(j6>0)G6(j6-1)},"select:next":()=>{if(j6<n6.length-1)G6(j6+1)},"select:accept":()=>{if(n6[j6])n6[j6].action()}},{context:"Select",isActive:D==="plugin-details"&&!!v}),o7({"select:accept":()=>{if(typeof D==="object"&&D.type==="failed-plugin-details")(async()=>{o(!0),a(null);let I6=D.plugin.id,C6=D.plugin.scope,l6=sh6(C6)?await _s(I6,C6,!1):await _s(I6,"user",!1),S6=l6.success;if(!S6){let E6=["userSettings","projectSettings","localSettings"];for(let R6 of E6){let h6=v1(R6);if(h6?.enabledPlugins?.[I6]!==void 0)W7(R6,{enabledPlugins:{...h6.enabledPlugins,[I6]:void 0}}),S6=!0}Sz()}if(S6){if(_)await _();o(!1),f("plugin-list")}else o(!1),a(l6.message)})()}},{context:"Select",isActive:typeof D==="object"&&D.type==="failed-plugin-details"&&D.plugin.scope!=="managed"}),o7({"confirm:yes":()=>{if(!v)return;o(!0),a(null);let I6=`${v.plugin.name}@${v.marketplace}`,{error:C6}=W7("localSettings",{enabledPlugins:{...v1("localSettings")?.enabledPlugins,[I6]:!1}});if(C6){o(!1),a(`Failed to write settings: ${C6.message}`);return}if(Sz(),K(`✓ Disabled ${v.plugin.name} in .claude/settings.local.json. Run /reload-plugins to apply.`),_)_();q({type:"menu"})},"confirm:no":()=>{f("plugin-details"),a(null)}},{context:"Confirmation",isActive:D==="confirm-project-uninstall"&&!!v&&!w6}),k4((I6,C6)=>{if(!v)return;let l6=`${v.plugin.name}@${v.marketplace}`,S6=v.scope;if(!S6||S6==="builtin"||!sh6(S6))return;let E6=async(R6)=>{o(!0),a(null);try{let h6=await _s(l6,S6,R6);if(!h6.success)throw Error(h6.message);Sz();let x6=R6?"":" · data preserved";if(K(`${t6.tick} ${h6.message}${x6}`),_)_();q({type:"menu"})}catch(h6){o(!1),a(h6 instanceof Error?h6.message:String(h6))}};if(I6==="y"||I6==="Y")E6(!0);else if(I6==="n"||I6==="N")E6(!1);else if(C6.escape)f("plugin-details"),a(null)},{isActive:typeof D==="object"&&D.type==="confirm-data-cleanup"&&!!v&&!w6}),W8.useEffect(()=>{$6(0)},[G]),k4((I6,C6)=>{let l6=!C6.ctrl&&!C6.meta;if(J)return;if(I6==="/"&&l6)X(!0),Z(""),$6(0);else if(l6&&I6.length>0&&!/^\s+$/.test(I6)&&I6!=="j"&&I6!=="k"&&I6!==" ")X(!0),Z(I6),$6(0)},{isActive:D==="plugin-list"}),I)return W8.createElement(k,null,"Loading installed plugins…");if(t.length===0)return W8.createElement(u,{flexDirection:"column"},W8.createElement(u,{marginBottom:1},W8.createElement(k,{bold:!0},"Manage plugins")),W8.createElement(k,null,"No plugins or MCP servers installed."),W8.createElement(u,{marginTop:1},W8.createElement(k,{dimColor:!0},"Esc to go back")));if(typeof D==="object"&&D.type==="plugin-options"&&v){let C6=function(l6){if(K(l6),_)_();q({type:"menu"})},I6=`${v.plugin.name}@${v.marketplace}`;return W8.createElement(rh6,{plugin:v.plugin,pluginId:I6,onDone:(l6,S6)=>{switch(l6){case"configured":C6(`✓ Enabled and configured ${v.plugin.name}. Run /reload-plugins to apply.`);break;case"skipped":C6(`✓ Enabled ${v.plugin.name}. Run /reload-plugins to apply.`);break;case"error":C6(`Failed to save configuration: ${S6}`);break}}})}if(typeof D==="object"&&D.type==="configuring-options"&&v){let I6=`${v.plugin.name}@${v.marketplace}`;return W8.createElement(m78,{title:`Configure ${v.plugin.name}`,subtitle:"Plugin options",configSchema:D.schema,initialValues:VG(I6),onSave:(C6)=>{try{$k8(I6,C6,D.schema),Sz(),K("Configuration saved. Run /reload-plugins for changes to take effect.")}catch(l6){a(`Failed to save configuration: ${d6(l6)}`)}f("plugin-details")},onCancel:()=>f("plugin-details")})}if(D==="configuring"&&n&&v){let l6=function(){l(null),f("plugin-details")},I6=`${v.plugin.name}@${v.marketplace}`;async function C6(S6){if(!n||!v)return;try{let E6=v.plugin.manifest.mcpServers,R6=null;if(typeof E6==="string"&&kC(E6))R6=E6;else if(Array.isArray(E6)){for(let h6 of E6)if(typeof h6==="string"&&kC(h6)){R6=h6;break}}if(!R6){a("No MCPB file found"),f("plugin-details");return}await Bi6(R6,v.plugin.path,I6,void 0,S6),a(null),l(null),f("plugin-details"),K("Configuration saved. Run /reload-plugins for changes to take effect.")}catch(E6){let R6=d6(E6);a(`Failed to save configuration: ${R6}`),f("plugin-details")}}return W8.createElement(m78,{title:`Configure ${n.manifest.name}`,subtitle:`Plugin: ${v.plugin.name}`,configSchema:n.configSchema,initialValues:n.existingConfig,onSave:C6,onCancel:l6})}if(typeof D==="object"&&D.type==="flagged-detail"){let I6=D.plugin;return W8.createElement(u,{flexDirection:"column"},W8.createElement(u,null,W8.createElement(k,{bold:!0},I6.name," @ ",I6.marketplace)),W8.createElement(u,{marginBottom:1},W8.createElement(k,{dimColor:!0},"Status: "),W8.createElement(k,{color:"error"},"Removed")),W8.createElement(u,{marginBottom:1,flexDirection:"column"},W8.createElement(k,{color:"error"},"Removed from marketplace · reason: ",I6.reason),W8.createElement(k,null,I6.text),W8.createElement(k,{dimColor:!0},"Flagged on ",new Date(I6.flaggedAt).toLocaleDateString())),W8.createElement(u,{marginTop:1,flexDirection:"column"},W8.createElement(u,null,W8.createElement(k,null,t6.pointer," "),W8.createElement(k,{color:"suggestion"},"Dismiss"))),W8.createElement(I1,null,W8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"dismiss"}),W8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))}if(D==="confirm-project-uninstall"&&v)return W8.createElement(u,{flexDirection:"column"},W8.createElement(k,{bold:!0,color:"warning"},v.plugin.name," is enabled in .claude/settings.json (shared with your team)"),W8.createElement(u,{marginTop:1,flexDirection:"column"},W8.createElement(k,null,"Disable it just for you in .claude/settings.local.json?"),W8.createElement(k,{dimColor:!0},"This has the same effect as uninstalling, without affecting other contributors.")),s&&W8.createElement(u,{marginTop:1},W8.createElement(k,{color:"error"},s)),W8.createElement(u,{marginTop:1},w6?W8.createElement(k,{dimColor:!0},"Disabling…"):W8.createElement(I1,null,W8.createElement(W1,{action:"confirm:yes",context:"Confirmation",fallback:"y",description:"disable"}),W8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancel"}))));if(typeof D==="object"&&D.type==="confirm-data-cleanup"&&v)return W8.createElement(u,{flexDirection:"column"},W8.createElement(k,{bold:!0},v.plugin.name," has ",D.size.human," of persistent data"),W8.createElement(u,{marginTop:1,flexDirection:"column"},W8.createElement(k,null,"Delete it along with the plugin?"),W8.createElement(k,{dimColor:!0},pn6(`${v.plugin.name}@${v.marketplace}`))),s&&W8.createElement(u,{marginTop:1},W8.createElement(k,{color:"error"},s)),W8.createElement(u,{marginTop:1},w6?W8.createElement(k,{dimColor:!0},"Uninstalling…"):W8.createElement(k,null,W8.createElement(k,{bold:!0},"y")," to delete · ",W8.createElement(k,{bold:!0},"n")," to keep ·"," ",W8.createElement(k,{bold:!0},"esc")," to cancel")));if(D==="plugin-details"&&v){let I6=Z7(),C6=`${v.plugin.name}@${v.marketplace}`,l6=I6?.enabledPlugins?.[C6]!==!1,S6=j.filter((R6)=>("plugin"in R6)&&R6.plugin===v.plugin.name||R6.source===C6||R6.source.startsWith(`${v.plugin.name}@`)),E6=S6.length===0?null:W8.createElement(u,{flexDirection:"column",marginBottom:1},W8.createElement(k,{bold:!0,color:"error"},S6.length," ",A7(S6.length,"error"),":"),S6.map((R6,h6)=>{let x6=_S6(R6);return W8.createElement(u,{key:h6,flexDirection:"column",marginLeft:2},W8.createElement(k,{color:"error"},k56(R6)),x6&&W8.createElement(k,{dimColor:!0,italic:!0},t6.arrowRight," ",x6))}));return W8.createElement(u,{flexDirection:"column"},W8.createElement(u,null,W8.createElement(k,{bold:!0},v.plugin.name," @ ",v.marketplace)),W8.createElement(u,null,W8.createElement(k,{dimColor:!0},"Scope: "),W8.createElement(k,null,v.scope||"user")),v.plugin.manifest.version&&W8.createElement(u,null,W8.createElement(k,{dimColor:!0},"Version: "),W8.createElement(k,null,v.plugin.manifest.version)),v.plugin.manifest.description&&W8.createElement(u,{marginBottom:1},W8.createElement(k,null,v.plugin.manifest.description)),v.plugin.manifest.author&&W8.createElement(u,null,W8.createElement(k,{dimColor:!0},"Author: "),W8.createElement(k,null,v.plugin.manifest.author.name)),W8.createElement(u,{marginBottom:1},W8.createElement(k,{dimColor:!0},"Status: "),W8.createElement(k,{color:l6?"success":"warning"},l6?"Enabled":"Disabled"),v.pendingUpdate&&W8.createElement(k,{color:"suggestion"}," · Marked for update")),W8.createElement(sMY,{plugin:v.plugin,marketplace:v.marketplace}),E6,W8.createElement(u,{marginTop:1,flexDirection:"column"},n6.map((R6,h6)=>{let x6=h6===j6;return W8.createElement(u,{key:h6},x6&&W8.createElement(k,null,t6.pointer," "),!x6&&W8.createElement(k,null," "),W8.createElement(k,{bold:x6,color:R6.label.includes("Uninstall")?"error":R6.label.includes("Update")?"suggestion":void 0},R6.label))})),w6&&W8.createElement(u,{marginTop:1},W8.createElement(k,null,"Processing…")),s&&W8.createElement(u,{marginTop:1},W8.createElement(k,{color:"error"},s)),W8.createElement(u,{marginTop:1},W8.createElement(k,{dimColor:!0,italic:!0},W8.createElement(I1,null,W8.createElement(W1,{action:"select:previous",context:"Select",fallback:"↑",description:"navigate"}),W8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"select"}),W8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))))}if(typeof D==="object"&&D.type==="failed-plugin-details"){let I6=D.plugin,C6=I6.errors[0],l6=C6?k56(C6):"Failed to load";return W8.createElement(u,{flexDirection:"column"},W8.createElement(k,null,W8.createElement(k,{bold:!0},I6.name),W8.createElement(k,{dimColor:!0}," @ ",I6.marketplace),W8.createElement(k,{dimColor:!0}," (",I6.scope,")")),W8.createElement(k,{color:"error"},l6),I6.scope==="managed"?W8.createElement(u,{marginTop:1},W8.createElement(k,{dimColor:!0},"Managed by your organization — contact your admin")):W8.createElement(u,{marginTop:1},W8.createElement(k,{color:"suggestion"},t6.pointer," "),W8.createElement(k,{bold:!0},"Remove")),w6&&W8.createElement(k,null,"Processing…"),s&&W8.createElement(k,{color:"error"},s),W8.createElement(u,{marginTop:1},W8.createElement(k,{dimColor:!0,italic:!0},W8.createElement(I1,null,I6.scope!=="managed"&&W8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"remove"}),W8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))))}if(typeof D==="object"&&D.type==="mcp-detail"){let I6=D.client,C6=EU(w,I6.name).length,l6=()=>{f({type:"mcp-tools",client:I6})},S6=()=>{f("plugin-list")},E6=(x6)=>{if(x6)K(x6);f("plugin-list")},R6=I6.config.scope,h6=I6.config.type;if(h6==="stdio"){let x6={name:I6.name,client:I6,scope:R6,transport:"stdio",config:I6.config};return W8.createElement(b78,{server:x6,serverToolsCount:C6,onViewTools:l6,onCancel:S6,onComplete:E6,borderless:!0})}else if(h6==="sse"){let x6={name:I6.name,client:I6,scope:R6,transport:"sse",isAuthenticated:void 0,config:I6.config};return W8.createElement(lH6,{server:x6,serverToolsCount:C6,onViewTools:l6,onCancel:S6,onComplete:E6,borderless:!0})}else if(h6==="http"){let x6={name:I6.name,client:I6,scope:R6,transport:"http",isAuthenticated:void 0,config:I6.config};return W8.createElement(lH6,{server:x6,serverToolsCount:C6,onViewTools:l6,onCancel:S6,onComplete:E6,borderless:!0})}else if(h6==="claudeai-proxy"){let x6={name:I6.name,client:I6,scope:R6,transport:"claudeai-proxy",isAuthenticated:void 0,config:I6.config};return W8.createElement(lH6,{server:x6,serverToolsCount:C6,onViewTools:l6,onCancel:S6,onComplete:E6,borderless:!0})}return f("plugin-list"),null}if(typeof D==="object"&&D.type==="mcp-tools"){let I6=D.client,C6=I6.config.scope,l6=I6.config.type,S6;if(l6==="stdio")S6={name:I6.name,client:I6,scope:C6,transport:"stdio",config:I6.config};else if(l6==="sse")S6={name:I6.name,client:I6,scope:C6,transport:"sse",isAuthenticated:void 0,config:I6.config};else if(l6==="http")S6={name:I6.name,client:I6,scope:C6,transport:"http",isAuthenticated:void 0,config:I6.config};else S6={name:I6.name,client:I6,scope:C6,transport:"claudeai-proxy",isAuthenticated:void 0,config:I6.config};return W8.createElement(I78,{server:S6,onSelectTool:(E6)=>{f({type:"mcp-tool-detail",client:I6,tool:E6})},onBack:()=>f({type:"mcp-detail",client:I6})})}if(typeof D==="object"&&D.type==="mcp-tool-detail"){let{client:I6,tool:C6}=D,l6=I6.config.scope,S6=I6.config.type,E6;if(S6==="stdio")E6={name:I6.name,client:I6,scope:l6,transport:"stdio",config:I6.config};else if(S6==="sse")E6={name:I6.name,client:I6,scope:l6,transport:"sse",isAuthenticated:void 0,config:I6.config};else if(S6==="http")E6={name:I6.name,client:I6,scope:l6,transport:"http",isAuthenticated:void 0,config:I6.config};else E6={name:I6.name,client:I6,scope:l6,transport:"claudeai-proxy",isAuthenticated:void 0,config:I6.config};return W8.createElement(x78,{tool:C6,server:E6,onBack:()=>f({type:"mcp-tools",client:I6})})}let o6=M6.getVisibleItems(e);return W8.createElement(u,{flexDirection:"column"},W8.createElement(u,{marginBottom:1},W8.createElement(Tp,{query:G,isFocused:J,isTerminalFocused:P,width:W-4,cursorOffset:T})),e.length===0&&G&&W8.createElement(u,{marginBottom:1},W8.createElement(k,{dimColor:!0},'No items match "',G,'"')),M6.scrollPosition.canScrollUp&&W8.createElement(u,null,W8.createElement(k,{dimColor:!0}," ",t6.arrowUp," more above")),o6.map((I6,C6)=>{let S6=M6.toActualIndex(C6)===i&&!J,E6=C6>0?o6[C6-1]:null,R6=!E6||E6.scope!==I6.scope,h6=(x6)=>{switch(x6){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 x6}};return W8.createElement(W8.Fragment,{key:I6.id},R6&&W8.createElement(u,{marginTop:C6>0?1:0,paddingLeft:2},W8.createElement(k,{dimColor:I6.scope!=="flagged",color:I6.scope==="flagged"?"warning":void 0,bold:I6.scope==="flagged"},h6(I6.scope))),W8.createElement(yyK,{item:I6,isSelected:S6}))}),M6.scrollPosition.canScrollDown&&W8.createElement(u,null,W8.createElement(k,{dimColor:!0}," ",t6.arrowDown," more below")),W8.createElement(u,{marginTop:1,marginLeft:1},W8.createElement(k,{dimColor:!0,italic:!0},W8.createElement(I1,null,W8.createElement(k,null,"type to search"),W8.createElement(W1,{action:"plugin:toggle",context:"Plugin",fallback:"Space",description:"toggle"}),W8.createElement(W1,{action:"select:accept",context:"Select",fallback:"Enter",description:"details"}),W8.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"back"})))),p.size>0&&W8.createElement(u,{marginLeft:1},W8.createElement(k,{dimColor:!0,italic:!0},"Run /reload-plugins to apply changes")))}var W8,DY;var hyK=y(()=>{bq();a5();QK();KF8();_F8();zF8();YF8();gH6();H56();t4();s6();Oq();vn6();Z56();NJ();qS6();C7();hH();_8();y8();E8();Jy();pX();Nw();gi6();aV();ZF8();hP();bj();mu();Sj6();nh6();U1();l8();d47();p47();HF8();EyK();MF8();W8=O6(D6(),1),DY=O6(D6(),1)});function SyK(q){if(!q)return{type:"menu"};let K=q.trim().split(/\s+/);switch(K[0]?.toLowerCase()){case"help":case"--help":case"-h":return{type:"help"};case"install":case"i":{let z=K[1];if(!z)return{type:"install"};if(z.includes("@")){let[$,A]=z.split("@");return{type:"install",plugin:$,marketplace:A}}if(z.startsWith("http://")||z.startsWith("https://")||z.startsWith("file://")||z.includes("/")||z.includes("\\"))return{type:"install",marketplace:z};return{type:"install",plugin:z}}case"manage":return{type:"manage"};case"uninstall":return{type:"uninstall",plugin:K[1]};case"enable":return{type:"enable",plugin:K[1]};case"disable":return{type:"disable",plugin:K[1]};case"validate":return{type:"validate",path:K.slice(1).join(" ").trim()||void 0};case"marketplace":case"market":{let z=K[1]?.toLowerCase(),Y=K.slice(2).join(" ");switch(z){case"add":return{type:"marketplace",action:"add",target:Y};case"remove":case"rm":return{type:"marketplace",action:"remove",target:Y};case"update":return{type:"marketplace",action:"update",target:Y};case"list":return{type:"marketplace",action:"list"};default:return{type:"marketplace"}}}default:return{type:"menu"}}}import{readdir as qXY,readFile as YS6,stat as KXY}from"fs/promises";import*as mJ from"path";function zXY(q){let K=mJ.basename(q),_=mJ.basename(mJ.dirname(q));if(K==="plugin.json")return"plugin";if(K==="marketplace.json")return"marketplace";if(_===".claude-plugin")return"plugin";return"unknown"}function n47(q){return q.issues.map((K)=>({path:K.path.join(".")||"root",message:K.message,code:K.code}))}function B78(q,K,_,z){if(q.includes(".."))_.push({path:K,message:z?`Path contains "..": ${q}. ${z}`:`Path contains ".." which could be a path traversal attempt: ${q}`})}function YXY(q){let K=q.replace(/^(\.\.\/)+/,"");return`Plugin source paths are resolved relative to the marketplace root (the directory containing .claude-plugin/), not relative to marketplace.json. Use "${K!==q?`./${K}`:"./plugins/my-plugin"}" instead of "${q}".`}async function c47(q){let K=[],_=[],z=mJ.resolve(q),Y;try{Y=await YS6(z,{encoding:"utf-8"})}catch(w){let j=s1(w),H;if(j==="ENOENT")H=`File not found: ${z}`;else if(j==="EISDIR")H=`Path is not a file: ${z}`;else H=`Failed to read file: ${d6(w)}`;return{success:!1,errors:[{path:"file",message:H,code:j}],warnings:[],filePath:z,fileType:"plugin"}}let $;try{$=r8(Y)}catch(w){return{success:!1,errors:[{path:"json",message:`Invalid JSON syntax: ${d6(w)}`}],warnings:[],filePath:z,fileType:"plugin"}}if($&&typeof $==="object"){let w=$;if(w.commands)(Array.isArray(w.commands)?w.commands:[w.commands]).forEach((H,J)=>{if(typeof H==="string")B78(H,`commands[${J}]`,K)});if(w.agents)(Array.isArray(w.agents)?w.agents:[w.agents]).forEach((H,J)=>{if(typeof H==="string")B78(H,`agents[${J}]`,K)});if(w.skills)(Array.isArray(w.skills)?w.skills:[w.skills]).forEach((H,J)=>{if(typeof H==="string")B78(H,`skills[${J}]`,K)})}let A=$;if(typeof $==="object"&&$!==null){let w=$,j=Object.keys(w).filter((H)=>_XY.has(H));if(j.length>0){let H={...w};for(let J of j)delete H[J],_.push({path:J,message:`Field '${J}' belongs in the marketplace entry (marketplace.json), `+"not plugin.json. It's harmless here but unused — Claude Code "+"ignores it at load time."});A=H}}let O=Z_6().strict().safeParse(A);if(!O.success)K.push(...n47(O.error));if(O.success){let w=O.data;if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(w.name))_.push({path:"name",message:`Plugin name "${w.name}" is not kebab-case. Claude Code accepts it, but the Claude.ai marketplace sync requires kebab-case (lowercase letters, digits, and hyphens only, e.g., "my-plugin").`});if(!w.version)_.push({path:"version",message:'No version specified. Consider adding a version following semver (e.g., "1.0.0")'});if(!w.description)_.push({path:"description",message:"No description provided. Adding a description helps users understand what your plugin does"});if(!w.author)_.push({path:"author",message:"No author information provided. Consider adding author details for plugin attribution"})}return{success:K.length===0,errors:K,warnings:_,filePath:z,fileType:"plugin"}}async function l47(q){let K=[],_=[],z=mJ.resolve(q),Y;try{Y=await YS6(z,{encoding:"utf-8"})}catch(w){let j=s1(w),H;if(j==="ENOENT")H=`File not found: ${z}`;else if(j==="EISDIR")H=`Path is not a file: ${z}`;else H=`Failed to read file: ${d6(w)}`;return{success:!1,errors:[{path:"file",message:H,code:j}],warnings:[],filePath:z,fileType:"marketplace"}}let $;try{$=r8(Y)}catch(w){return{success:!1,errors:[{path:"json",message:`Invalid JSON syntax: ${d6(w)}`}],warnings:[],filePath:z,fileType:"marketplace"}}if($&&typeof $==="object"){let w=$;if(Array.isArray(w.plugins))w.plugins.forEach((j,H)=>{if(j&&typeof j==="object"&&"source"in j){let J=j.source;if(typeof J==="string")B78(J,`plugins[${H}].source`,K,YXY(J));if(J&&typeof J==="object"&&"path"in J&&typeof J.path==="string")B78(J.path,`plugins[${H}].source.path`,K)}})}let O=de().extend({plugins:L.array(OK1().strict())}).strict().safeParse($);if(!O.success)K.push(...n47(O.error));if(O.success){let w=O.data;if(!w.plugins||w.plugins.length===0)_.push({path:"plugins",message:"Marketplace has no plugins defined"});if(w.plugins){w.plugins.forEach((J,M)=>{if(w.plugins.filter((P)=>P.name===J.name).length>1)K.push({path:`plugins[${M}].name`,message:`Duplicate plugin name "${J.name}" found in marketplace`})});let j=mJ.dirname(z),H=mJ.basename(j)===".claude-plugin"?mJ.dirname(j):j;for(let[J,M]of w.plugins.entries()){if(!M.version||typeof M.source!=="string"||!M.source.startsWith("./"))continue;let X=mJ.join(H,M.source,".claude-plugin","plugin.json"),P;try{let W=await YS6(X,{encoding:"utf-8"}),D=r8(W);if(typeof D.version==="string")P=D.version}catch{continue}if(P&&P!==M.version)_.push({path:`plugins[${J}].version`,message:`Entry declares version "${M.version}" but ${M.source}/.claude-plugin/plugin.json says "${P}". `+"At install time, plugin.json wins (calculatePluginVersion precedence) — the entry version is silently ignored. "+`Update this entry to "${P}" to match.`})}}if(!w.metadata?.description)_.push({path:"metadata.description",message:"No marketplace description provided. Adding a description helps users understand what this marketplace offers"})}return{success:K.length===0,errors:K,warnings:_,filePath:z,fileType:"marketplace"}}function $XY(q,K,_){let z=[],Y=[],$=K.match(Th1);if(!$)return Y.push({path:"frontmatter",message:"No frontmatter block found. Add YAML frontmatter between --- delimiters at the top of the file to set description and other metadata."}),{success:!0,errors:z,warnings:Y,filePath:q,fileType:_};let A=$[1]||"",O;try{O=Dn6(A)}catch(J){return z.push({path:"frontmatter",message:`YAML frontmatter failed to parse: ${d6(J)}. At runtime this ${_} loads with empty metadata (all frontmatter fields silently dropped).`}),{success:!1,errors:z,warnings:Y,filePath:q,fileType:_}}if(O===null||typeof O!=="object"||Array.isArray(O))return z.push({path:"frontmatter",message:`Frontmatter must be a YAML mapping (key: value pairs), got ${Array.isArray(O)?"an array":O===null?"null":typeof O}.`}),{success:!1,errors:z,warnings:Y,filePath:q,fileType:_};let w=O;if(w.description!==void 0){let J=w.description;if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean"&&J!==null)z.push({path:"description",message:`description must be a string, got ${Array.isArray(J)?"array":typeof J}. At runtime this value is dropped.`})}else Y.push({path:"description",message:`No description in frontmatter. A description helps users and Claude understand when to use this ${_}.`});if(w.name!==void 0&&w.name!==null&&typeof w.name!=="string")z.push({path:"name",message:`name must be a string, got ${typeof w.name}.`});let j=w["allowed-tools"];if(j!==void 0&&j!==null){if(typeof j!=="string"&&!Array.isArray(j))z.push({path:"allowed-tools",message:`allowed-tools must be a string or array of strings, got ${typeof j}.`});else if(Array.isArray(j)&&j.some((J)=>typeof J!=="string"))z.push({path:"allowed-tools",message:"allowed-tools array must contain only strings."})}let H=w.shell;if(H!==void 0&&H!==null)if(typeof H!=="string")z.push({path:"shell",message:`shell must be a string, got ${typeof H}.`});else{let J=H.trim().toLowerCase();if(J!=="bash"&&J!=="powershell")z.push({path:"shell",message:`shell must be 'bash' or 'powershell', got '${H}'.`})}return{success:z.length===0,errors:z,warnings:Y,filePath:q,fileType:_}}async function AXY(q){let K;try{K=await YS6(q,{encoding:"utf-8"})}catch(Y){if(s1(Y)==="ENOENT")return{success:!0,errors:[],warnings:[],filePath:q,fileType:"hooks"};return{success:!1,errors:[{path:"file",message:`Failed to read file: ${d6(Y)}`}],warnings:[],filePath:q,fileType:"hooks"}}let _;try{_=r8(K)}catch(Y){return{success:!1,errors:[{path:"json",message:`Invalid JSON syntax: ${d6(Y)}. At runtime this breaks the entire plugin load.`}],warnings:[],filePath:q,fileType:"hooks"}}let z=ZA8().safeParse(_);if(!z.success)return{success:!1,errors:n47(z.error),warnings:[],filePath:q,fileType:"hooks"};return{success:!0,errors:[],warnings:[],filePath:q,fileType:"hooks"}}async function CyK(q,K){let _;try{_=await qXY(q,{withFileTypes:!0})}catch(Y){let $=s1(Y);if($==="ENOENT"||$==="ENOTDIR")return[];throw Y}if(K)return _.filter((Y)=>Y.isDirectory()).map((Y)=>mJ.join(q,Y.name,"SKILL.md"));let z=[];for(let Y of _){let $=mJ.join(q,Y.name);if(Y.isDirectory())z.push(...await CyK($,!1));else if(Y.isFile()&&Y.name.toLowerCase().endsWith(".md"))z.push($)}return z}async function byK(q){let K=[],_=[["skill",mJ.join(q,"skills")],["agent",mJ.join(q,"agents")],["command",mJ.join(q,"commands")]];for(let[Y,$]of _){let A=await CyK($,Y==="skill");for(let O of A){let w;try{w=await YS6(O,{encoding:"utf-8"})}catch(H){if(_7(H))continue;K.push({success:!1,errors:[{path:"file",message:`Failed to read: ${d6(H)}`}],warnings:[],filePath:O,fileType:Y});continue}let j=$XY(O,w,Y);if(j.errors.length>0||j.warnings.length>0)K.push(j)}}let z=await AXY(mJ.join(q,"hooks","hooks.json"));if(z.errors.length>0||z.warnings.length>0)K.push(z);return K}async function GF8(q){let K=mJ.resolve(q),_=null;try{_=await KXY(K)}catch(Y){if(!_7(Y))throw Y}if(_?.isDirectory()){let Y=mJ.join(K,".claude-plugin","marketplace.json"),$=await l47(Y);if($.errors[0]?.code!=="ENOENT")return $;let A=mJ.join(K,".claude-plugin","plugin.json"),O=await c47(A);if(O.errors[0]?.code!=="ENOENT")return O;return{success:!1,errors:[{path:"directory",message:"No manifest found in directory. Expected .claude-plugin/marketplace.json or .claude-plugin/plugin.json"}],warnings:[],filePath:K,fileType:"plugin"}}switch(zXY(q)){case"plugin":return c47(q);case"marketplace":return l47(q);case"unknown":{try{let Y=await YS6(K,{encoding:"utf-8"}),$=r8(Y);if(Array.isArray($.plugins))return l47(q)}catch(Y){if(s1(Y)==="ENOENT")return{success:!1,errors:[{path:"file",message:`File not found: ${K}`}],warnings:[],filePath:K,fileType:"plugin"}}return c47(q)}}}var _XY;var i47=y(()=>{x7();y8();rV();l8();BZ();_XY=new Set(["category","source","tags","strict","id"])});function IyK(q){let K=z6(5),{onComplete:_,path:z}=q,Y,$;if(K[0]!==_||K[1]!==z)Y=()=>{(async function(){if(!z){_(`Usage: /plugin validate <path>
6090
6091Validate a plugin or marketplace manifest file or directory.

Callers 3

RyKFunction · 0.85
Lc8Function · 0.85
Rc8Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected