claude-code-session-manager 0.130.0 → 0.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentLibrary-ctvNes4y.js → AgentLibrary-Dlhtc8Ty.js} +1 -1
- package/dist/assets/{AppSettings-C03qTDSi.js → AppSettings-A3KoPcmL.js} +1 -1
- package/dist/assets/{Button-fOCJry21.js → Button-DvTXa_-4.js} +1 -1
- package/dist/assets/{Extensions-BWiDwigT.js → Extensions-Ddb4sQpO.js} +3 -3
- package/dist/assets/{History-BIQFPXM8.js → History-DcnZxMoU.js} +1 -1
- package/dist/assets/{Library-BGmD-xZN.js → Library-LftcMs6C.js} +1 -1
- package/dist/assets/{ListDetail-BeO3lY8t.js → ListDetail-CnL1azR0.js} +1 -1
- package/dist/assets/{Memory-BeXuYIcE.js → Memory-smN9-Yoo.js} +1 -1
- package/dist/assets/{Panel-OUbLHNsS.js → Panel-CA6TdCHv.js} +1 -1
- package/dist/assets/{ProvenanceBadge-kr7arZqu.js → ProvenanceBadge-Y3DhyiJo.js} +1 -1
- package/dist/assets/{Scheduler-DycegnjH.js → Scheduler-Ca1qo_kp.js} +1 -1
- package/dist/assets/{Settings-BSq6VASG.js → Settings-BFwlV-as.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-CvPdxg56.js → SkillReferenceGraph-2WMsKdmr.js} +1 -1
- package/dist/assets/{SourceChip-C2YMnlV8.js → SourceChip-CeprSxwb.js} +1 -1
- package/dist/assets/{SystemPrompt-fpXEK_Rm.js → SystemPrompt-B8TXIGXo.js} +1 -1
- package/dist/assets/{TiptapBody-DusJg0je.js → TiptapBody-BvxcQ_tS.js} +1 -1
- package/dist/assets/{Toggle-BnJF4V6k.js → Toggle-keTV_HDb.js} +1 -1
- package/dist/assets/{ViewTabs-BYrRSHb6.js → ViewTabs-fupn9keJ.js} +1 -1
- package/dist/assets/{VoiceButton-Bk66E-fP.js → VoiceButton-5ETBv9eI.js} +1 -1
- package/dist/assets/{historyTotals-DnuVADtI.js → historyTotals-NAZqiuzd.js} +1 -1
- package/dist/assets/{index-DfWJO7nP.js → index-QJxszEhM.js} +304 -304
- package/dist/index.html +1 -1
- package/dist-web/app.js +339 -339
- package/package.json +1 -1
- package/src/main/build-info.json +4 -4
- package/src/main/lib/activeSessions.cjs +6 -2
- package/src/main/promptSessionsIpc.cjs +39 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-
|
|
2
|
-
import{at as e,F as Le,aJ as o,b9 as ie,b0 as ke,au as we,a$ as G,b3 as J,b4 as de,l as O,b as re,bm as Ne,be as De,H as Oe}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-2WMsKdmr.js","./index-QJxszEhM.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-Bp8XE9A6.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{at as e,F as Le,aJ as o,b9 as ie,b0 as ke,au as we,a$ as G,b3 as J,b4 as de,l as O,b as re,bm as Ne,be as De,H as Oe}from"./index-QJxszEhM.js";import{V as Fe}from"./ViewTabs-fupn9keJ.js";import{S as le}from"./SourceChip-CeprSxwb.js";import{P as ae}from"./Panel-CA6TdCHv.js";import{L as ue}from"./ListDetail-CnL1azR0.js";import{S as Se,f as he,m as _e,e as Ie,M as Be,d as We}from"./Library-LftcMs6C.js";import{T as Je}from"./Toggle-keTV_HDb.js";import{P as te}from"./ProvenanceBadge-Y3DhyiJo.js";import{_ as He}from"./monaco-editor-BsIlgG7c.js";import"./Button-DvTXa_-4.js";function $e({value:s,onChange:t,path:n,readOnly:a}){return e.jsx(Le,{path:`file://${n}`,defaultLanguage:"markdown",value:s,onChange:l=>t(l??""),theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,wordWrap:"on",readOnly:a,automaticLayout:!0}})}const me=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,oe="disable-model-invocation",Ce=/^\s*disable-model-invocation\s*:/;function Ve(s){const t=s.match(me);if(!t)return!1;for(const n of t[1].split(/\r?\n/)){if(!Ce.test(n))continue;const a=n.slice(n.indexOf(":")+1).trim().toLowerCase();return a==="true"||a==="yes"}return!1}function Ke(s){const t=s.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function xe(s){return s.length-s.trimStart().length}function pe(s){const t=s.match(me);if(!t)return{name:null,description:null,body:s};const n=t[1].split(/\r?\n/),a=t[2]??"";let l=null,c=null;for(let r=0;r<n.length;r++){const x=n[r],u=x.match(/^(\s*)(name|description)\s*:(.*)$/);if(!u)continue;const[,,f,v]=u,p=v.trim(),A=xe(x);let $;if(p===""||p===">-"||p===">"||p==="|-"||p==="|"){const P=[];let M=r+1;for(;M<n.length&&n[M].trim()!==""&&xe(n[M])>A;)P.push(n[M].trim()),M++;$=P.join(" ")}else $=Ke(p);f==="name"?l=$:c=$}return{name:l,description:c,body:a}}function Ue(s,t){const n=s.match(me);if(!n){if(!t)return s;const r=s.startsWith(`
|
|
3
3
|
`)?"":`
|
|
4
4
|
`;return`---
|
|
5
5
|
${oe}: true
|
|
@@ -10,4 +10,4 @@ ${l.join(`
|
|
|
10
10
|
---
|
|
11
11
|
${a}`}const qe=250,ze=2e3;function Ge(s,t){return{user:{skills:`${s}/.claude/skills`,commands:`${s}/.claude/commands`},project:t?{skills:`${t}/.claude/skills`,commands:`${t}/.claude/commands`}:null}}function Ye({onAdd:s,scope:t="user"}={}){const n=ie(),a=ke(),l=(a==null?void 0:a.cwd)??null,[c,r]=o.useState([]),[x,u]=o.useState(null),[f,v]=o.useState(""),[p,A]=o.useState([]),[$,P]=o.useState(null),M=o.useMemo(()=>n?Ge(n,l):null,[n,l]),j=o.useMemo(()=>M?t==="user"?M.user:M.project:null,[t,M]),k=o.useRef(0),y=o.useCallback(async()=>{const d=++k.current;if(!j){r([]),A([]);return}const S=[],E=[];try{const m=await we(j.skills);E.push(...m.errors);for(const N of m.entries)S.push({kind:"skills",scope:t,name:N.name,path:N.path,dir:N.dir,disabled:Ve(N.text),description:pe(N.text).description??void 0})}catch(m){E.push({path:j.skills,error:m instanceof Error?m.message:String(m)})}try{const m=await window.api.config.listDir(j.commands,{filesOnly:!0});m.ok||E.push({path:j.commands,error:m.error??"failed to list directory"});for(const N of m.entries)N.name.endsWith(".md")&&S.push({kind:"commands",scope:t,name:N.name.replace(/\.md$/,""),path:N.path,dir:null,disabled:!1})}catch(m){E.push({path:j.commands,error:m instanceof Error?m.message:String(m)})}if(k.current===d){for(const m of E)G.error(`Could not read ${m.path}: ${m.error}`);A(E),S.sort((m,N)=>m.kind===N.kind?m.name.localeCompare(N.name):m.kind==="skills"?-1:1),r(S),u(m=>{var N;return S.find(V=>V.path===m)?m:((N=S[0])==null?void 0:N.path)??null})}},[j,t]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>()=>{k.current+=1},[]);const C=o.useRef(y);C.current=y;const R=o.useRef(c);R.current=c;const F=o.useRef(x);F.current=x;const I=o.useRef(null),B=o.useRef(!1),W=o.useRef(!1),D=o.useCallback(async()=>{if(B.current){W.current=!0;return}B.current=!0;try{await C.current()}finally{B.current=!1}W.current&&(W.current=!1,D())},[]);o.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]);const i=o.useCallback(d=>{var N;const S=F.current,E=S?R.current.find(V=>V.path===S):null,m=S?(N=J.getState().files[S])==null?void 0:N.lastSavedAt:null;E!=null&&E.dir&&m&&Date.now()-m<ze&&(d===E.dir||E.dir.startsWith(`${d}/`))||(I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,D()},qe))},[D]);de(j?[j.skills,j.commands]:[],i);const g=J(d=>d.files),K=J(d=>d.loadText),_=J(d=>d.setDraft),H=J(d=>d.saveText),q=J(d=>d.revert),L=J(d=>d.watchFile),z=J(d=>d.unwatchFile);async function X(d,S){const E=await window.api.config.readText(d.path);if(!E.exists)return;const m=Ue(E.text,S);if(m===E.text)return;const N=await window.api.config.writeText(d.path,m);if(!N.ok){G.error(N.error??"failed to update skill");return}r(V=>V.map(Q=>Q.path===d.path?{...Q,disabled:S}:Q)),J.getState().files[d.path]&&J.getState().loadText(d.path,!0)}async function Z(d){if(!d.dir)return;P(null);const S=await window.api.files.delete(d.dir);if(!S.ok){G.error(S.error??"failed to remove skill");return}G.info(`Removed "${d.name}" — moved to trash`),z(d.path),r(E=>{const m=E.filter(N=>N.path!==d.path);return u(N=>{var V;return N!==d.path?N:((V=m[0])==null?void 0:V.path)??null}),m})}o.useEffect(()=>{if(x)return g[x]||K(x),L(x),()=>z(x)},[x]);const[h,b]=o.useState(null);if(!n)return e.jsx(O,{title:"loading…"});if(t==="project"&&!l)return e.jsx(ae,{toolbar:e.jsx(e.Fragment,{}),children:e.jsx(O,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const w=c.find(d=>d.path===x)??null,T=x?g[x]:null;return e.jsx(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ml-3 text-fg-faint",children:[c.length," ",c.length===1?"item":"items"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Add…"}),w&&e.jsx(te,{scope:w.scope,input:{type:w.kind==="commands"?"command":"skill",name:w.name}}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:(w==null?void 0:w.path)??""})]}),footer:x&&T?e.jsx(Se,{dirty:T.dirty,busy:T.busy,parseError:h,lastSavedAt:T.lastSavedAt,onSave:async()=>{b(null);const d=await H(x);d.ok||b(d.error??"save failed")},onRevert:()=>{b(null),q(x)}}):null,children:e.jsx(ue,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:f,onChange:d=>v(d.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),["skills","commands"].map(d=>{const S=f.toLowerCase(),E=c.filter(m=>m.kind===d&&(!S||m.name.toLowerCase().includes(S)));return e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"px-3 py-1 text-xs uppercase tracking-wider text-fg-faint",children:d==="skills"?"Skills":"Slash Commands"}),E.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"none"}):E.map(m=>{var V,Q,se;const N=m.kind==="skills";return e.jsxs("div",{className:`w-full px-3 py-1 text-xs flex items-center justify-between gap-2 ${x===m.path?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("button",{onClick:()=>u(m.path),className:"flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:`truncate ${m.disabled?"line-through opacity-50":""}`,title:m.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,children:[m.kind==="commands"?"/":"",m.name]}),m.description&&e.jsx("div",{className:"truncate text-fg-faint",children:m.description})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(te,{interactive:!1,scope:m.scope,input:{type:m.kind==="commands"?"command":"skill",name:m.name}}),((V=g[m.path])==null?void 0:V.dirty)&&e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent"}),N&&e.jsx("span",{title:(Q=g[m.path])!=null&&Q.dirty?"This skill has unsaved edits — save or revert before toggling":void 0,children:e.jsx(Je,{checked:!m.disabled,disabled:!!((se=g[m.path])!=null&&se.dirty),onChange:U=>void X(m,!U)})}),m.kind==="skills"&&$===m.path&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>void Z(m),title:`Remove ${m.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>P(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}),m.kind==="skills"&&$!==m.path&&e.jsx("button",{onClick:U=>{U.stopPropagation(),P(m.path)},title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${m.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]},m.path)})]},d)})]}),detail:x&&T?e.jsx("div",{className:"h-full",children:e.jsx($e,{path:x,value:T.draftRaw,onChange:d=>{b(null),_(x,d)}})}):c.length===0&&p.length>0?e.jsx("div",{"data-testid":"skills-list-error",children:e.jsx(O,{title:"could not list skills or commands",hint:p.map(d=>`${d.path}: ${d.error}`).join(`
|
|
12
12
|
`)})}):e.jsx(O,{title:c.length===0?"no skills or commands":"select an item"})})})}const Xe=o.memo(Ye),Ze={live:"bg-emerald-400",idle:"bg-amber-400",offline:"bg-fg-faint",attention:"bg-accent",paused:"bg-zinc-500"},Qe={sm:"w-1.5 h-1.5",md:"w-2 h-2"},et={on:"live",off:"offline",warn:"attention",live:"live",idle:"idle"};function Ee({state:s,kind:t,pulse:n=!1,size:a="sm",className:l="",title:c,"aria-label":r}){const x=s??(t?et[t]:"idle"),u=Ze[x],f=Qe[a],v=n?"animate-pulse":"",p=r??c??x;return e.jsx("span",{role:"img","aria-label":p,className:`inline-block rounded-full ${f} ${u} ${v} ${l}`.trim(),title:c})}const tt={failed:"Failed","needs-auth":"Needs auth",pending:"Pending approval"};function ge(s,t){const n=t!=null&&t.ok?t.servers.find(a=>a.name===s):void 0;return!n||n.status==="unknown"?{state:"unprobed",label:"Not checked",probeStatus:(n==null?void 0:n.status)??null,badgeTone:"dim",dotState:"offline"}:n.status==="connected"?{state:"ready",label:"Ready",probeStatus:n.status,badgeTone:"good",dotState:"live"}:{state:"not-ready",label:tt[n.status],probeStatus:n.status,badgeTone:"warn",dotState:"attention"}}const be=(s,t)=>({type:"mcp",name:s,command:t.command,args:t.args,url:t.url}),st=["stdio","http","streamable-http","sse","ws"],nt=new Set(["workspace"]),at=new Set(["ide","tasks"]);function lt(s,t,n){return s==="user"?`${t}/.claude.json`:n?`${n}/.mcp.json`:null}function rt(s){if(s.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(s),n=t.mcpServers??{};return{full:t,servers:n,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function it(s,t){const n={};for(const[a,l]of Object.entries(t)){const{enabled:c,...r}=l;n[a]=r}return JSON.stringify({...s,mcpServers:n},null,2)+`
|
|
13
|
-
`}function ot(s,t){const n=[];for(const[a,l]of Object.entries(t)){if(JSON.stringify(l)===JSON.stringify(s[a]))continue;const{enabled:c,...r}=l;n.push({name:a,value:r})}for(const a of Object.keys(s))a in t||n.push({name:a,value:void 0});return n}function ct(s){let t=Object.keys(s).length+1,n=`server-${t}`;for(;s[n];)t+=1,n=`server-${t}`;return n}function dt({onAdd:s,scope:t="user"}={}){const n=ie(),a=ke(),l=(a==null?void 0:a.cwd)??null,[c,r]=o.useState(null),[x,u]=o.useState(""),f=o.useMemo(()=>n?lt(t,n,l):null,[n,t,l]),v=J(h=>h.files),p=J(h=>h.loadJson),A=J(h=>h.setDraft),$=J(h=>h.revert),P=J(h=>h.watchFile),M=J(h=>h.unwatchFile);o.useEffect(()=>{if(f)return v[f]||p(f),P(f),()=>M(f)},[f]);const[j,k]=o.useState(null),[y,C]=o.useState(null),[R,F]=o.useState(!1),I=o.useRef(0),B=o.useRef(!0);o.useEffect(()=>()=>{B.current=!1},[]);const W=async()=>{const h=++I.current;F(!0);try{const b=await window.api.mcp.status();if(!B.current||h!==I.current)return;C(b),b.ok||G.error(b.error??"MCP status probe failed")}catch(b){if(!B.current||h!==I.current)return;C(null),G.error(b.message||"MCP status probe failed")}finally{B.current&&h===I.current&&F(!1)}};if(o.useEffect(()=>{W()},[]),!n)return e.jsx(O,{title:"loading…"});if(t==="project"&&!l)return e.jsx(ae,{toolbar:e.jsx(e.Fragment,{}),children:e.jsx(O,{title:"no active project"})});if(!f)return e.jsx(O,{title:"loading…"});const D=v[f],{full:i,servers:g,err:K}=D?rt(D.draftRaw):{full:{},servers:{},err:null},_=Object.keys(g).sort(),H=c?g[c]:null,q=h=>{k(null),A(f,it(i,h))},L=()=>{const h=ct(g);q({...g,[h]:{type:"stdio",command:"",args:[]}}),r(h)},z=h=>{const b={...g};delete b[h],q(b),c===h&&r(null)},X=(h,b)=>{if(!b||b===h||g[b])return;const w={};for(const T of Object.keys(g))w[T===h?b:T]=g[T];q(w),r(b)},Z=(h,b)=>{q({...g,[h]:b})};return e.jsxs(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ml-3 px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-faint",children:[_.length," server",_.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:f}),e.jsx("div",{className:"flex-1"}),c&&H&&e.jsx(te,{scope:t,input:be(c,H),className:"mr-2"}),e.jsx("button",{onClick:W,disabled:R,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50 mr-2",children:R?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:()=>s==null?void 0:s({scope:t,cwd:l}),className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi mr-2",children:"Add…"}),e.jsx("button",{onClick:L,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ new server"})]}),footer:D?e.jsx(Se,{dirty:D.dirty,busy:D.busy,parseError:j||K||D.parseError,lastSavedAt:D.lastSavedAt,onSave:async()=>{var b;k(null);const h=((b=D.diskData)==null?void 0:b.mcpServers)??{};for(const[w,T]of Object.entries(g)){if(JSON.stringify(T)===JSON.stringify(h[w]))continue;const d=he(T);if(d.length>0){Ne.getState().show("error",`Not saved: "${w}" still contains placeholder ${d.map(S=>S.token).join(", ")} — replace it with a real value`);return}}try{for(const w of ot(h,g))await window.api.claudeConfig.patch({..._e(t,l),keyPath:["mcpServers",w.name],value:w.value});await p(f)}catch(w){k(w.message||"save failed")}},onRevert:()=>{k(null),$(f)}}):null,children:[t==="project"&&l&&e.jsx(pt,{cwd:l,names:_}),e.jsx(ue,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:x,onChange:h=>u(h.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),_.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):_.filter(h=>!x||h.toLowerCase().includes(x.toLowerCase())).map(h=>{var T;const b=ge(h,y),w=(T=g[h].description)==null?void 0:T.trim();return e.jsxs("button",{onClick:()=>r(h),className:`w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 ${c===h?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ee,{state:b.dotState,title:b.label}),e.jsx("span",{className:"truncate",children:h})]}),e.jsxs("span",{className:"ml-2 flex items-center gap-2 shrink-0",children:[(()=>{const d=he(g[h]);return d.length>0?e.jsxs(re,{tone:"warn",title:`${t} scope · ${f}`,children:["unconfigured placeholder: ",d.map(S=>S.token).join(", ")]}):null})(),e.jsx(re,{tone:b.badgeTone,children:b.label}),e.jsx(te,{interactive:!1,scope:t,input:be(h,g[h])}),e.jsx("span",{className:"text-fg-faint",children:g[h].type??"stdio"})]})]}),w?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:w,children:w}):null]},h)})]}),detail:c&&H?e.jsx(mt,{name:c,server:H,connection:ge(c,y),onTestConnection:W,testing:R,onRename:h=>X(c,h),onChange:h=>Z(c,h),onRemove:()=>z(c)}):e.jsx(O,{title:"select a server or click + new"})})]})}const ut=o.memo(dt);function mt({name:s,server:t,connection:n,onTestConnection:a,testing:l,onRename:c,onChange:r,onRemove:x}){var M;const u=t.type??"stdio",f=nt.has(s),v=at.has(s),p=(M=t.permissions)==null?void 0:M.tools,A=p===void 0?"inherit":p==="allow"?"allow":p==="deny"?"deny":"list",$=Array.isArray(p)?p:[],P=(t.disabledTools??[]).join(", ");return e.jsxs("div",{className:"p-4 space-y-4 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{state:n.dotState,size:"md",title:n.label}),e.jsx(re,{tone:n.badgeTone,children:n.label}),e.jsx("button",{onClick:a,disabled:l,className:"ml-auto px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50",children:l?"checking…":"test connection"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),e.jsx("input",{defaultValue:s,onBlur:j=>c(j.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("button",{onClick:x,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),e.jsx(ne,{label:"description",value:t.description??"",onChange:j=>r({...t,description:j||void 0}),placeholder:"what this server does…"}),f?e.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:s})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):v?e.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:s})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),e.jsx("select",{value:u,onChange:j=>r({...t,type:j.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:st.map(j=>e.jsx("option",{value:j,children:j},j))}),u==="sse"?e.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),u==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"command",value:t.command??"",onChange:j=>r({...t,command:j}),placeholder:"npx / node / python …"}),e.jsx(ne,{label:"args",value:(t.args??[]).join(" "),onChange:j=>r({...t,args:j.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(je,{label:"env",value:t.env??{},onChange:j=>r({...t,env:j})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"url",value:t.url??"",onChange:j=>r({...t,url:j}),placeholder:"https://…"}),e.jsx(je,{label:"headers",value:t.headers??{},onChange:j=>r({...t,headers:j})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:j=>r({...t,alwaysLoad:j.target.checked||void 0})}),e.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),e.jsx(ne,{label:"disabledTools",value:P,onChange:j=>{const k=j.split(",").map(y=>y.trim()).filter(Boolean);r({...t,disabledTools:k.length?k:void 0})},placeholder:"comma-separated tool names to hide"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("select",{value:A,onChange:j=>{const k=j.target.value,y={...t};if(k==="inherit"){if(y.permissions){const{tools:C,...R}=y.permissions;y.permissions=Object.keys(R).length?R:void 0}}else k==="list"?y.permissions={...y.permissions??{},tools:[]}:y.permissions={...y.permissions??{},tools:k};r(y)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"inherit",children:"inherit (default)"}),e.jsx("option",{value:"allow",children:"allow all tools"}),e.jsx("option",{value:"deny",children:"deny all tools"}),e.jsx("option",{value:"list",children:"allowlist…"})]}),A==="list"?e.jsx("input",{value:$.join(", "),onChange:j=>{const k=j.target.value.split(",").map(y=>y.trim()).filter(Boolean);r({...t,permissions:{...t.permissions??{},tools:k}})},placeholder:"comma-separated tool names",className:"w-full bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}):null]})]})]})}function ne({label:s,value:t,onChange:n,placeholder:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:s}),e.jsx("input",{value:t,onChange:l=>n(l.target.value),placeholder:a,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function je({label:s,value:t,onChange:n}){const[a,l]=o.useState(""),[c,r]=o.useState(""),x=Object.entries(t);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:s}),e.jsxs("div",{className:"flex-1 space-y-1",children:[x.map(([u,f])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:u,onChange:v=>{const p={...t};delete p[u],p[v.target.value]=f,n(p)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("input",{value:f,onChange:v=>n({...t,[u]:v.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:()=>{const v={...t};delete v[u],n(v)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},u)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:a,onChange:u=>l(u.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("input",{value:c,onChange:u=>r(u.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("button",{onClick:()=>{a.trim()&&(n({...t,[a.trim()]:c}),l(""),r(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}function pt({cwd:s,names:t}){const n={fileId:"settings",scope:"project",cwd:s},[a,l]=o.useState([]),[c,r]=o.useState(!1),[x,u]=o.useState(!1);o.useEffect(()=>{var P,M;let p=!0;const A=()=>window.api.claudeConfig.read(n).then(j=>{if(!p)return;const k=j.data;l(Array.isArray(k==null?void 0:k.disabledMcpjsonServers)?k.disabledMcpjsonServers:[]),r((k==null?void 0:k.enableAllProjectMcpServers)===!0)}).catch(()=>{});A();const $=(M=(P=window.api.config)==null?void 0:P.onChanged)==null?void 0:M.call(P,()=>{A()});return()=>{p=!1,$==null||$()}},[s]);const f=async(p,A)=>{u(!0);try{await window.api.claudeConfig.patch({...n,keyPath:[p],value:A})}catch($){G.error($.message||"save failed")}finally{u(!1)}},v=async(p,A)=>{const $=A?a.filter(P=>P!==p):[...new Set([...a,p])];l($),await f("disabledMcpjsonServers",$.length?$:void 0)};return e.jsxs("div",{className:"px-3 py-1 text-xs text-fg-faint border-b border-line flex flex-wrap items-center gap-x-4 gap-y-1","data-testid":"mcp-gating",children:[e.jsxs("span",{children:["Gating · ",s,"/.claude/settings.json"]}),e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox","data-testid":"mcp-enable-all",checked:c,disabled:x,onChange:p=>{r(p.target.checked),f("enableAllProjectMcpServers",p.target.checked?!0:void 0)}}),"enableAllProjectMcpServers"]}),t.map(p=>e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox","data-testid":`mcp-gate-${p}`,checked:!a.includes(p),disabled:x,onChange:A=>v(p,A.target.checked)}),p]},p))]})}function ft({columns:s,rows:t,getKey:n,onRowClick:a,activeKey:l,empty:c}){return t.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:c??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:s.map(r=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${r.className??""}`,style:r.width?{width:r.width}:void 0,children:r.header},r.key))})}),e.jsx("tbody",{children:t.map(r=>{const x=n(r),u=l===x;return e.jsx("tr",{"data-row-key":x,onClick:()=>a==null?void 0:a(r),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${u?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:s.map(f=>e.jsx("td",{className:`px-3 py-1 ${f.className??""}`,children:f.render(r)},f.key))},x)})})]})}async function Pe(s){const t=`${s}/skills`;return await window.api.config.exists(t)?t:null}async function Me(s){const{entries:t}=await we(s,{nested:!1});return t.map(n=>{const a=pe(n.text);return{id:n.name,name:a.name,description:a.description,dir:n.dir,path:n.path,body:a.body}})}function ht(s){const t=[],n=new Set;for(const a of s)for(const l of s){if(a.id===l.id)continue;const c=l.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=[`/${c}\\b`,`\`${c}\``];if(l.id.length>=4&&r.push(`\\b${c}\\b`),!r.some(f=>new RegExp(f,"i").test(a.body)))continue;const u=`${a.id}->${l.id}`;n.has(u)||(n.add(u),t.push({from:a.id,to:l.id}))}return t}const xt=o.lazy(()=>He(()=>import("./SkillReferenceGraph-CvPdxg56.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(s=>({default:s.SkillReferenceGraph})));function gt({pluginName:s,skills:t,onBack:n,initialSelectedId:a}){var v;const[l,c]=o.useState(a??((v=t[0])==null?void 0:v.id)??null),r=l?t.find(p=>p.id===l)??null:null,x=o.useMemo(()=>ht(t),[t]),[u,f]=o.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:n,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",s]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(r==null?void 0:r.name)??(r==null?void 0:r.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>f("list"),className:`px-2 py-0.5 text-xs ${u==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>f("graph"),className:`px-2 py-0.5 text-xs ${u==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[r!=null&&r.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:r.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[t.length," ",t.length===1?"skill":"skills"," · ",x.length," ",x.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.length===0?e.jsx(O,{title:"no skills in this plugin"}):u==="graph"?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(xt,{skills:t,edges:x,selectedId:l,onSelect:c})}):e.jsx(ue,{sidebar:e.jsx("div",{className:"py-1",children:t.map(p=>e.jsxs("button",{onClick:()=>c(p.id),className:`w-full px-3 py-1 text-xs text-left ${l===p.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:p.name??p.id}),p.description?e.jsx("div",{className:"truncate text-fg-faint",children:p.description}):null]},p.id))}),detail:r?e.jsx("div",{className:"h-full min-h-0",children:e.jsx($e,{path:r.path,value:r.body,onChange:()=>{},readOnly:!0})}):e.jsx(O,{title:"select a skill"})})})]})}const Ae=s=>{var t,n;return{type:"plugin",name:s.name,repository:(t=s.manifest)==null?void 0:t.repository,homepage:(n=s.manifest)==null?void 0:n.homepage}};function bt({onAdd:s}={}){const t=ie(),[n,a]=o.useState([]),[l,c]=o.useState(!0),[r,x]=o.useState(null),[u,f]=o.useState(null),[v,p]=o.useState(null),[A,$]=o.useState(new Set),P=Ne(i=>i.show),[M,j]=o.useState(null);o.useEffect(()=>{var g,K;let i=!1;return(K=(g=window.api.app).seedStatus)==null||K.call(g).then(_=>{i||p(_)}).catch(()=>{}),()=>{i=!0}},[]);const k=o.useRef(0),y=o.useRef(!1),C=o.useCallback(async()=>{var H,q;const i=++k.current;if(!t)return;y.current||c(!0);const g=`${t}/.claude/plugins/installed_plugins.json`;let K=[],_=null;try{const L=await window.api.config.readJson(g);if(L.exists&&L.parseError)_=`could not parse installed_plugins.json${L.error?`: ${L.error}`:""}`;else if(L.exists&&L.data&&typeof L.data=="object"){const z=L.data,X=[];for(const[h,b]of Object.entries(z.plugins??{})){if(!Array.isArray(b))continue;const[w,T]=h.split("@");for(const d of b)d!=null&&d.installPath&&X.push({name:w,marketplace:T,entry:d})}let Z=new Map;try{const h=await((q=(H=window.api.plugins)==null?void 0:H.list)==null?void 0:q.call(H))??[];Z=new Map(h.map(b=>[b.key,b.enabled]))}catch{}K=await $t(X,St,async({name:h,marketplace:b,entry:w})=>{var S;const T={name:h,path:w.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let d;try{d=await Et(T)}catch(E){d=Ct(T,E instanceof Error?E.message:String(E))}return(S=d.manifest)!=null&&S.version||(d.manifest={...d.manifest??{},version:w.version}),d.marketplace=b,d.scope=w.scope,d.key=b?`${h}@${b}`:h,d.enabled=Z.get(d.key)===!0,d})}}catch(L){_=`could not read installed_plugins.json: ${L instanceof Error?L.message:String(L)}`}k.current===i&&(x(_),_?G.error(`Plugins: ${_}`):(K.sort((L,z)=>L.name.localeCompare(z.name)),y.current=K.length>0,a(K)),c(!1))},[t]);o.useEffect(()=>{C()},[C]),o.useEffect(()=>()=>{k.current+=1},[]),de(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],C);const R=async i=>{if(i.key){j(i.key);try{const g=await window.api.plugins.setEnabled({key:i.key,enabled:!i.enabled});g.ok||P("error",`Could not ${i.enabled?"disable":"enable"} ${i.name}: ${g.error??"unknown error"}`)}catch(g){P("error",`Could not update ${i.name}: ${g instanceof Error?g.message:String(g)}`)}finally{j(null),await C()}}},F=async i=>{if(i.marketplace&&window.confirm(`Uninstall plugin "${i.name}"?`)){j(i.key??i.name);try{const g=await window.api.plugins.uninstall({slug:i.name,marketplaceName:i.marketplace});g.ok||P("error",`Uninstall ${i.name} failed: ${g.error??`exit ${g.exitCode}`}`)}catch(g){P("error",`Uninstall ${i.name} failed: ${g instanceof Error?g.message:String(g)}`)}finally{j(null),await C()}}},I=[{key:"enabled",header:"on",render:i=>e.jsx("button",{type:"button",role:"switch","aria-checked":i.enabled===!0,"aria-label":`${i.enabled?"Disable":"Enable"} ${i.name}`,"data-testid":"plugin-enabled-switch",disabled:!i.key||M===i.key,onClick:g=>{g.stopPropagation(),R(i)},className:`w-8 h-4 rounded-full relative transition-colors ${i.enabled?"bg-accent":"bg-bg-hi border border-line"}`,children:e.jsx("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-fg transition-all ${i.enabled?"left-4":"left-0.5"}`})}),width:"3.5rem"},{key:"name",header:"name",render:i=>{var g;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:i.name}),(g=i.manifest)!=null&&g.description?e.jsx("div",{className:"truncate text-fg-faint",title:i.manifest.description,children:i.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:i=>e.jsx(te,{interactive:!1,input:Ae(i)}),width:"7rem"},{key:"scope",header:"scope",render:i=>i.scope?e.jsx("span",{"data-testid":"plugin-scope",children:i.scope}):e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:i=>{var g;return((g=i.manifest)==null?void 0:g.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:i=>i.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:i=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[i.agents>0?`${i.agents} agents`:null,i.commands>0?`${i.commands} commands`:null,i.skills>0?`${i.skills} skills`:null,i.hooks>0?`${i.hooks} hooks`:null,i.monitors>0?`${i.monitors} monitors`:null,i.binCount>0?`${i.binCount} bin`:null,i.hasLsp?"lsp":null,i.hasMcp?"mcp":null,i.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:i=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:i.path})},{key:"actions",header:"",render:i=>e.jsx("button",{type:"button","data-testid":"plugin-uninstall",disabled:!i.marketplace||M===(i.key??i.name),onClick:g=>{g.stopPropagation(),F(i)},className:"text-xs text-red-300 hover:underline disabled:opacity-40",children:"Uninstall"}),width:"5rem"}],B=o.useMemo(()=>v?Object.keys(v).filter(i=>(v[i].status==="exhausted"||v[i].status==="failed")&&!A.has(i)):[],[v,A]),W=B.length>0?e.jsx(vt,{seeders:B,seedStatus:v,onDismiss:i=>$(g=>new Set(g).add(i)),onOpenLibrary:()=>s==null?void 0:s()}):null,D=u?n.find(i=>i.path===u)??null:null;return e.jsxs(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Add…"})]}),children:[W,r?e.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[r,n.length>0?" — showing the last known list":null]}):null,l&&n.length===0?e.jsx(O,{title:"scanning plugins…"}):r&&n.length===0?null:D?e.jsx(wt,{row:D,home:t,onBack:()=>f(null)},D.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ft,{columns:I,rows:n,getKey:i=>i.path,activeKey:u,onRowClick:i=>f(i.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["use Add… or run ",e.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const jt=o.memo(bt),ce={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function vt({seeders:s,seedStatus:t,onDismiss:n,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:s.map(l=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:t[l].status==="failed"?`${ce[l]} setup failed — it will retry on next launch. To fix it now:`:`${ce[l]} setup failed after retrying — manual fix needed`}),l==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:t[l].fix})]}),e.jsx("button",{onClick:()=>n(l),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${ce[l]} warning`,children:"✕"})]},l))})}const yt=250,kt=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function wt({row:s,home:t,onBack:n}){var L,z,X,Z,h;const[a,l]=o.useState([]),[c,r]=o.useState([]),[x,u]=o.useState([]),[f,v]=o.useState([]),[p,A]=o.useState([]),[$,P]=o.useState("skills"),[M,j]=o.useState(null),[k,y]=o.useState(!0),[C,R]=o.useState([]),F=o.useRef(0),I=o.useRef(!1),B=o.useCallback(async()=>{if(!t)return;const b=++F.current;try{const{manifest:w}=await Te(s.path),[T,d,S]=await Promise.all([Pe(s.path),Re(s.path,w),fe(`${s.path}/bin`,{filesOnly:!0})]),E=T?await Me(T):[],[m,N]=await Promise.all([ye(d.agentFiles),ye(d.commandFiles)]),V=d.mcpServers,Q=await Promise.all([...new Set([...kt.map(U=>`${s.path}/${U}`),...d.sourcePaths])].map(async U=>await window.api.config.exists(U)?U:null));if(b!==F.current)return;l(E),r(m),u(N),v(V),A(S);const se=Q.filter(U=>U!==null);R(U=>U.join("\0")===se.join("\0")?U:se),I.current||(I.current=!0,P(E.length>0?"skills":m.length>0?"agents":N.length>0?"commands":V.length>0?"mcp":s.hooks>0?"hooks":s.monitors>0?"monitors":s.hasLsp?"lsp":"files"))}catch(w){if(b!==F.current)return;G.error(`Failed to load plugin contents: ${w instanceof Error?w.message:String(w)}`)}finally{b===F.current&&y(!1)}},[s.path,s.name,s.hooks,s.monitors,s.hasLsp,t]);o.useEffect(()=>(y(!0),B(),()=>{F.current+=1}),[B]);const W=o.useRef(null),D=o.useRef(!1),i=o.useRef(!1),g=o.useCallback(async()=>{if(D.current){i.current=!0;return}D.current=!0;try{do i.current=!1,await B();while(i.current)}finally{D.current=!1}},[B]),K=o.useCallback(()=>{W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{W.current=null,g()},yt)},[g]);o.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]),de(C,K,{depth:0});const _=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:c.length},{key:"commands",label:"Commands",count:x.length},{key:"mcp",label:"MCP server",count:f.length},{key:"hooks",label:"Hooks",count:s.hooks},{key:"monitors",label:"Monitors",count:s.monitors},{key:"lsp",label:"LSP",count:s.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],H=(L=s.manifest)!=null&&L.author?typeof s.manifest.author=="string"?s.manifest.author:s.manifest.author.name??null:null,q=async b=>{const w=await window.api.shell.open({as:"external",url:b});w.ok||G.error(w.error??`Failed to open ${b}`)};return M?e.jsx(gt,{pluginName:((z=s.manifest)==null?void 0:z.name)??s.name,skills:a,initialSelectedId:M.id,onBack:()=>j(null)},M.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:n,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((X=s.manifest)==null?void 0:X.name)??s.name}),(Z=s.manifest)!=null&&Z.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",s.manifest.version]}):null,(h=s.manifest)!=null&&h.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:s.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(te,{input:Ae(s)}),s.hasMcp?e.jsx(re,{tone:"accent",children:"MCP"}):null]})]}),s.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[H?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),H]}):null,s.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),s.manifest.license]}):null,s.manifest.homepage?e.jsxs("button",{onClick:()=>q(s.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:s.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),s.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:s.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:s.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:_.map(b=>e.jsxs("button",{type:"button",disabled:b.count===0,onClick:()=>P(b.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${b.count===0?"text-fg-faint opacity-50 cursor-default":$===b.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:b.label}),b.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:b.count}):null]},b.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:k?e.jsx(O,{title:"scanning…"}):e.jsx(Nt,{active:$,row:s,skills:a,agents:c,commands:x,mcpServers:f,files:p,onOpenSkill:j})})]})]})}function Nt({active:s,row:t,skills:n,agents:a,commands:l,mcpServers:c,files:r,onOpenSkill:x}){return s==="skills"?n.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:n.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description,onClick:()=>x(u)},u.id))}):s==="agents"?a.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:a.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description},u.id))}):s==="commands"?l.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:l.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description},u.id))}):s==="mcp"?c.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:c.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name,description:u.description},u.id))}):s==="hooks"?t.hooks===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:e.jsx(ee,{n:1,name:`${t.hooks} ${t.hooks===1?"hook":"hooks"} configured`,description:`${t.path}/hooks/hooks.json`})}):s==="monitors"?t.monitors===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:e.jsx(ee,{n:1,name:`${t.monitors} ${t.monitors===1?"monitor":"monitors"} configured`,description:`${t.path}/monitors/monitors.json`})}):s==="lsp"?t.hasLsp?e.jsx("div",{children:e.jsx(ee,{n:1,name:"LSP server enabled",description:`${t.path}/.lsp.json`})}):e.jsx(O,{title:"no components"}):r.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:r.map((u,f)=>e.jsx(ee,{n:f+1,name:u,description:null},u))})}function ee({n:s,name:t,description:n,onClick:a}){const l=a?"button":"div";return e.jsxs(l,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(s).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:t}),n?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:n}):null]})]})}const St=4;async function $t(s,t,n){const a=new Array(s.length);let l=0;const c=Array.from({length:Math.min(t,s.length)},async()=>{for(;l<s.length;){const r=l++;a[r]=await n(s[r])}});return await Promise.all(c),a}function Ct(s,t){return{name:s.name,path:s.path,mtimeMs:s.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,error:t}}async function Et(s){const{hasManifest:t,manifest:n}=await Te(s.path),[a,l]=await Promise.all([window.api.config.exists(`${s.path}/.lsp.json`),window.api.config.exists(`${s.path}/monitors/monitors.json`)]);let c=0;if(l){const p=await window.api.config.readJson(`${s.path}/monitors/monitors.json`);Array.isArray(p.data)?c=p.data.length:p.data&&typeof p.data=="object"&&Array.isArray(p.data.monitors)&&(c=p.data.monitors.length)}const[r,x,u]=await Promise.all([Re(s.path,n),fe(`${s.path}/bin`,{filesOnly:!0}),Pe(s.path)]),f=x.length,v=u?(await Me(u)).length:0;return{name:s.name,path:s.path,mtimeMs:s.mtimeMs,hasManifest:t,manifest:n,hasLsp:a,monitors:c,hooks:r.hooks,agents:r.agentFiles.length,commands:r.commandFiles.length,skills:v,binCount:f,hasMcp:r.mcpServers.length>0}}async function Te(s){let t=`${s}/.claude-plugin/plugin.json`,n=await window.api.config.exists(t);if(n||(t=`${s}/plugin.json`,n=await window.api.config.exists(t)),!n)return{hasManifest:n,manifest:null};const a=await window.api.config.readJson(t),l=a.exists&&!a.parseError&&a.data&&typeof a.data=="object"&&!Array.isArray(a.data);return{hasManifest:n,manifest:l?a.data:null}}const Y=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Pt(s,t){const n=t.startsWith("/")?t.startsWith(`${s}/`)?t.slice(s.length+1):null:t;if(n===null)return ve(t);const a=[];for(const l of n.split("/"))if(!(l===""||l===".")){if(l!=="..")a.push(l);else if(a.pop()===void 0)return ve(t)}return a.length>0?`${s}/${a.join("/")}`:s}function ve(s){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${s}`),null}function Mt(s){return typeof s=="string"?[s]:Array.isArray(s)?s.filter(t=>typeof t=="string"):[]}function At(s){if(!Y(s))return null;if(Y(s.mcpServers))return s.mcpServers;const t=Object.values(s);return t.length>0&&t.every(a=>Y(a)&&(typeof a.command=="string"||typeof a.url=="string"))?s:null}function Tt(s){if(!Y(s))return 0;const t=Y(s.hooks)?s.hooks:s;return Object.values(t).reduce((n,a)=>Array.isArray(a)?n+a.reduce((l,c)=>l+(Y(c)&&Array.isArray(c.hooks)?c.hooks.length:0),0):n,0)}async function Re(s,t){const n=(k,y)=>{const C=new Set;for(const R of Mt(k)){const F=Pt(s,R);F&&C.add(F)}return C.add(`${s}/${y}`),[...C]},a=async k=>{const y=new Set;for(const C of k)if(C.endsWith(".md"))y.add(C);else for(const R of await fe(C,{filesOnly:!0}))R.endsWith(".md")&&y.add(`${C}/${R}`);return[...y]},l=async k=>{try{const y=await window.api.config.readJson(k);return y.exists&&!y.parseError?y.data:null}catch{return null}},c=n(t==null?void 0:t.commands,"commands"),r=n(t==null?void 0:t.agents,"agents"),x=t==null?void 0:t.hooks,u=n(typeof x=="string"||Array.isArray(x)?x:void 0,"hooks/hooks.json"),f=t==null?void 0:t.mcpServers,v=n(typeof f=="string"||Array.isArray(f)?f:void 0,".mcp.json"),[p,A,$,P]=await Promise.all([a(c),a(r),Promise.all(u.map(l)),Promise.all(v.map(l))]),M=[...Y(x)?[x]:[],...$].reduce((k,y)=>k+Tt(y),0),j=new Map;for(const k of[...Y(f)?[f]:[],...P])for(const[y,C]of Object.entries(At(k)??{})){if(j.has(y))continue;const R=Y(C)?C.command:void 0,F=Y(C)?C.url:void 0;j.set(y,{id:y,name:y,description:typeof R=="string"?R:typeof F=="string"?F:null})}return{commandFiles:p,agentFiles:A,hooks:M,mcpServers:[...j.values()],sourcePaths:[...c,...r,...u,...v]}}async function ye(s){const t=await Promise.all(s.map(a=>window.api.config.readText(a))),n=[];return s.forEach((a,l)=>{if(!t[l].exists)return;const c=a.slice(a.lastIndexOf("/")+1),r=pe(t[l].text);n.push({id:a,name:r.name??c.replace(/\.md$/,""),description:r.description})}),n}async function fe(s,t){try{return(await window.api.config.listDir(s,t)).entries.map(a=>a.name)}catch{return[]}}const Rt=[{key:"skills",label:"Skills"},{key:"mcp",label:"MCP Servers"},{key:"plugins",label:"Plugins"}],Lt={skills:"Add skill",mcp:"Add MCP server",plugins:"Add plugin"};function Dt(){const s=ie(),[t,n]=o.useState("skills");De("extensions",v=>{(v==="skills"||v==="mcp"||v==="plugins")&&(n(v),l(!1))});const[a,l]=o.useState(!1),[c,r]=o.useState({scope:"user",cwd:null}),x=o.useCallback(()=>l(!1),[]),u=o.useCallback(v=>{r(v),l(!0)},[]),f=o.useCallback(()=>l(!0),[]);return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"extensions",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-1.5 border-b border-line",children:[e.jsx(Fe,{options:Rt,active:t,onChange:v=>{n(v),l(!1)}}),s&&t==="skills"&&e.jsx(le,{path:`${s}/.claude/skills`,note:"Open ~/.claude/skills/"}),s&&t==="mcp"&&e.jsx(le,{path:`${s}/.claude.json`,keyPath:["mcpServers"]}),s&&t==="plugins"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{path:`${s}/.claude/plugins/installed_plugins.json`}),e.jsx(le,{path:`${s}/.claude/settings.json`,keyPath:["enabledPlugins"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[t==="skills"&&e.jsx(Xe,{onAdd:f,scope:"user"}),t==="mcp"&&e.jsx(ut,{onAdd:u,scope:"user"}),t==="plugins"&&e.jsx(jt,{onAdd:f})]}),e.jsxs(Oe,{open:a,onClose:x,title:Lt[t],keyVals:[],children:[t==="skills"&&e.jsx(Ie,{}),t==="mcp"&&e.jsx(Be,{scope:c.scope,cwd:c.cwd}),t==="plugins"&&e.jsx(We,{})]})]})}const Ut=o.memo(Dt);export{Ut as Extensions};
|
|
13
|
+
`}function ot(s,t){const n=[];for(const[a,l]of Object.entries(t)){if(JSON.stringify(l)===JSON.stringify(s[a]))continue;const{enabled:c,...r}=l;n.push({name:a,value:r})}for(const a of Object.keys(s))a in t||n.push({name:a,value:void 0});return n}function ct(s){let t=Object.keys(s).length+1,n=`server-${t}`;for(;s[n];)t+=1,n=`server-${t}`;return n}function dt({onAdd:s,scope:t="user"}={}){const n=ie(),a=ke(),l=(a==null?void 0:a.cwd)??null,[c,r]=o.useState(null),[x,u]=o.useState(""),f=o.useMemo(()=>n?lt(t,n,l):null,[n,t,l]),v=J(h=>h.files),p=J(h=>h.loadJson),A=J(h=>h.setDraft),$=J(h=>h.revert),P=J(h=>h.watchFile),M=J(h=>h.unwatchFile);o.useEffect(()=>{if(f)return v[f]||p(f),P(f),()=>M(f)},[f]);const[j,k]=o.useState(null),[y,C]=o.useState(null),[R,F]=o.useState(!1),I=o.useRef(0),B=o.useRef(!0);o.useEffect(()=>()=>{B.current=!1},[]);const W=async()=>{const h=++I.current;F(!0);try{const b=await window.api.mcp.status();if(!B.current||h!==I.current)return;C(b),b.ok||G.error(b.error??"MCP status probe failed")}catch(b){if(!B.current||h!==I.current)return;C(null),G.error(b.message||"MCP status probe failed")}finally{B.current&&h===I.current&&F(!1)}};if(o.useEffect(()=>{W()},[]),!n)return e.jsx(O,{title:"loading…"});if(t==="project"&&!l)return e.jsx(ae,{toolbar:e.jsx(e.Fragment,{}),children:e.jsx(O,{title:"no active project"})});if(!f)return e.jsx(O,{title:"loading…"});const D=v[f],{full:i,servers:g,err:K}=D?rt(D.draftRaw):{full:{},servers:{},err:null},_=Object.keys(g).sort(),H=c?g[c]:null,q=h=>{k(null),A(f,it(i,h))},L=()=>{const h=ct(g);q({...g,[h]:{type:"stdio",command:"",args:[]}}),r(h)},z=h=>{const b={...g};delete b[h],q(b),c===h&&r(null)},X=(h,b)=>{if(!b||b===h||g[b])return;const w={};for(const T of Object.keys(g))w[T===h?b:T]=g[T];q(w),r(b)},Z=(h,b)=>{q({...g,[h]:b})};return e.jsxs(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ml-3 px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-faint",children:[_.length," server",_.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:f}),e.jsx("div",{className:"flex-1"}),c&&H&&e.jsx(te,{scope:t,input:be(c,H),className:"mr-2"}),e.jsx("button",{onClick:W,disabled:R,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50 mr-2",children:R?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:()=>s==null?void 0:s({scope:t,cwd:l}),className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi mr-2",children:"Add…"}),e.jsx("button",{onClick:L,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ new server"})]}),footer:D?e.jsx(Se,{dirty:D.dirty,busy:D.busy,parseError:j||K||D.parseError,lastSavedAt:D.lastSavedAt,onSave:async()=>{var b;k(null);const h=((b=D.diskData)==null?void 0:b.mcpServers)??{};for(const[w,T]of Object.entries(g)){if(JSON.stringify(T)===JSON.stringify(h[w]))continue;const d=he(T);if(d.length>0){Ne.getState().show("error",`Not saved: "${w}" still contains placeholder ${d.map(S=>S.token).join(", ")} — replace it with a real value`);return}}try{for(const w of ot(h,g))await window.api.claudeConfig.patch({..._e(t,l),keyPath:["mcpServers",w.name],value:w.value});await p(f)}catch(w){k(w.message||"save failed")}},onRevert:()=>{k(null),$(f)}}):null,children:[t==="project"&&l&&e.jsx(pt,{cwd:l,names:_}),e.jsx(ue,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:x,onChange:h=>u(h.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),_.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):_.filter(h=>!x||h.toLowerCase().includes(x.toLowerCase())).map(h=>{var T;const b=ge(h,y),w=(T=g[h].description)==null?void 0:T.trim();return e.jsxs("button",{onClick:()=>r(h),className:`w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 ${c===h?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ee,{state:b.dotState,title:b.label}),e.jsx("span",{className:"truncate",children:h})]}),e.jsxs("span",{className:"ml-2 flex items-center gap-2 shrink-0",children:[(()=>{const d=he(g[h]);return d.length>0?e.jsxs(re,{tone:"warn",title:`${t} scope · ${f}`,children:["unconfigured placeholder: ",d.map(S=>S.token).join(", ")]}):null})(),e.jsx(re,{tone:b.badgeTone,children:b.label}),e.jsx(te,{interactive:!1,scope:t,input:be(h,g[h])}),e.jsx("span",{className:"text-fg-faint",children:g[h].type??"stdio"})]})]}),w?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:w,children:w}):null]},h)})]}),detail:c&&H?e.jsx(mt,{name:c,server:H,connection:ge(c,y),onTestConnection:W,testing:R,onRename:h=>X(c,h),onChange:h=>Z(c,h),onRemove:()=>z(c)}):e.jsx(O,{title:"select a server or click + new"})})]})}const ut=o.memo(dt);function mt({name:s,server:t,connection:n,onTestConnection:a,testing:l,onRename:c,onChange:r,onRemove:x}){var M;const u=t.type??"stdio",f=nt.has(s),v=at.has(s),p=(M=t.permissions)==null?void 0:M.tools,A=p===void 0?"inherit":p==="allow"?"allow":p==="deny"?"deny":"list",$=Array.isArray(p)?p:[],P=(t.disabledTools??[]).join(", ");return e.jsxs("div",{className:"p-4 space-y-4 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{state:n.dotState,size:"md",title:n.label}),e.jsx(re,{tone:n.badgeTone,children:n.label}),e.jsx("button",{onClick:a,disabled:l,className:"ml-auto px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50",children:l?"checking…":"test connection"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),e.jsx("input",{defaultValue:s,onBlur:j=>c(j.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("button",{onClick:x,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),e.jsx(ne,{label:"description",value:t.description??"",onChange:j=>r({...t,description:j||void 0}),placeholder:"what this server does…"}),f?e.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:s})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):v?e.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:s})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),e.jsx("select",{value:u,onChange:j=>r({...t,type:j.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:st.map(j=>e.jsx("option",{value:j,children:j},j))}),u==="sse"?e.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),u==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"command",value:t.command??"",onChange:j=>r({...t,command:j}),placeholder:"npx / node / python …"}),e.jsx(ne,{label:"args",value:(t.args??[]).join(" "),onChange:j=>r({...t,args:j.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(je,{label:"env",value:t.env??{},onChange:j=>r({...t,env:j})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"url",value:t.url??"",onChange:j=>r({...t,url:j}),placeholder:"https://…"}),e.jsx(je,{label:"headers",value:t.headers??{},onChange:j=>r({...t,headers:j})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:j=>r({...t,alwaysLoad:j.target.checked||void 0})}),e.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),e.jsx(ne,{label:"disabledTools",value:P,onChange:j=>{const k=j.split(",").map(y=>y.trim()).filter(Boolean);r({...t,disabledTools:k.length?k:void 0})},placeholder:"comma-separated tool names to hide"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("select",{value:A,onChange:j=>{const k=j.target.value,y={...t};if(k==="inherit"){if(y.permissions){const{tools:C,...R}=y.permissions;y.permissions=Object.keys(R).length?R:void 0}}else k==="list"?y.permissions={...y.permissions??{},tools:[]}:y.permissions={...y.permissions??{},tools:k};r(y)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"inherit",children:"inherit (default)"}),e.jsx("option",{value:"allow",children:"allow all tools"}),e.jsx("option",{value:"deny",children:"deny all tools"}),e.jsx("option",{value:"list",children:"allowlist…"})]}),A==="list"?e.jsx("input",{value:$.join(", "),onChange:j=>{const k=j.target.value.split(",").map(y=>y.trim()).filter(Boolean);r({...t,permissions:{...t.permissions??{},tools:k}})},placeholder:"comma-separated tool names",className:"w-full bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}):null]})]})]})}function ne({label:s,value:t,onChange:n,placeholder:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:s}),e.jsx("input",{value:t,onChange:l=>n(l.target.value),placeholder:a,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function je({label:s,value:t,onChange:n}){const[a,l]=o.useState(""),[c,r]=o.useState(""),x=Object.entries(t);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:s}),e.jsxs("div",{className:"flex-1 space-y-1",children:[x.map(([u,f])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:u,onChange:v=>{const p={...t};delete p[u],p[v.target.value]=f,n(p)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("input",{value:f,onChange:v=>n({...t,[u]:v.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:()=>{const v={...t};delete v[u],n(v)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},u)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:a,onChange:u=>l(u.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("input",{value:c,onChange:u=>r(u.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("button",{onClick:()=>{a.trim()&&(n({...t,[a.trim()]:c}),l(""),r(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}function pt({cwd:s,names:t}){const n={fileId:"settings",scope:"project",cwd:s},[a,l]=o.useState([]),[c,r]=o.useState(!1),[x,u]=o.useState(!1);o.useEffect(()=>{var P,M;let p=!0;const A=()=>window.api.claudeConfig.read(n).then(j=>{if(!p)return;const k=j.data;l(Array.isArray(k==null?void 0:k.disabledMcpjsonServers)?k.disabledMcpjsonServers:[]),r((k==null?void 0:k.enableAllProjectMcpServers)===!0)}).catch(()=>{});A();const $=(M=(P=window.api.config)==null?void 0:P.onChanged)==null?void 0:M.call(P,()=>{A()});return()=>{p=!1,$==null||$()}},[s]);const f=async(p,A)=>{u(!0);try{await window.api.claudeConfig.patch({...n,keyPath:[p],value:A})}catch($){G.error($.message||"save failed")}finally{u(!1)}},v=async(p,A)=>{const $=A?a.filter(P=>P!==p):[...new Set([...a,p])];l($),await f("disabledMcpjsonServers",$.length?$:void 0)};return e.jsxs("div",{className:"px-3 py-1 text-xs text-fg-faint border-b border-line flex flex-wrap items-center gap-x-4 gap-y-1","data-testid":"mcp-gating",children:[e.jsxs("span",{children:["Gating · ",s,"/.claude/settings.json"]}),e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox","data-testid":"mcp-enable-all",checked:c,disabled:x,onChange:p=>{r(p.target.checked),f("enableAllProjectMcpServers",p.target.checked?!0:void 0)}}),"enableAllProjectMcpServers"]}),t.map(p=>e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox","data-testid":`mcp-gate-${p}`,checked:!a.includes(p),disabled:x,onChange:A=>v(p,A.target.checked)}),p]},p))]})}function ft({columns:s,rows:t,getKey:n,onRowClick:a,activeKey:l,empty:c}){return t.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:c??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:s.map(r=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${r.className??""}`,style:r.width?{width:r.width}:void 0,children:r.header},r.key))})}),e.jsx("tbody",{children:t.map(r=>{const x=n(r),u=l===x;return e.jsx("tr",{"data-row-key":x,onClick:()=>a==null?void 0:a(r),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${u?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:s.map(f=>e.jsx("td",{className:`px-3 py-1 ${f.className??""}`,children:f.render(r)},f.key))},x)})})]})}async function Pe(s){const t=`${s}/skills`;return await window.api.config.exists(t)?t:null}async function Me(s){const{entries:t}=await we(s,{nested:!1});return t.map(n=>{const a=pe(n.text);return{id:n.name,name:a.name,description:a.description,dir:n.dir,path:n.path,body:a.body}})}function ht(s){const t=[],n=new Set;for(const a of s)for(const l of s){if(a.id===l.id)continue;const c=l.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=[`/${c}\\b`,`\`${c}\``];if(l.id.length>=4&&r.push(`\\b${c}\\b`),!r.some(f=>new RegExp(f,"i").test(a.body)))continue;const u=`${a.id}->${l.id}`;n.has(u)||(n.add(u),t.push({from:a.id,to:l.id}))}return t}const xt=o.lazy(()=>He(()=>import("./SkillReferenceGraph-2WMsKdmr.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(s=>({default:s.SkillReferenceGraph})));function gt({pluginName:s,skills:t,onBack:n,initialSelectedId:a}){var v;const[l,c]=o.useState(a??((v=t[0])==null?void 0:v.id)??null),r=l?t.find(p=>p.id===l)??null:null,x=o.useMemo(()=>ht(t),[t]),[u,f]=o.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:n,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",s]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(r==null?void 0:r.name)??(r==null?void 0:r.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>f("list"),className:`px-2 py-0.5 text-xs ${u==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>f("graph"),className:`px-2 py-0.5 text-xs ${u==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[r!=null&&r.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:r.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[t.length," ",t.length===1?"skill":"skills"," · ",x.length," ",x.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.length===0?e.jsx(O,{title:"no skills in this plugin"}):u==="graph"?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(xt,{skills:t,edges:x,selectedId:l,onSelect:c})}):e.jsx(ue,{sidebar:e.jsx("div",{className:"py-1",children:t.map(p=>e.jsxs("button",{onClick:()=>c(p.id),className:`w-full px-3 py-1 text-xs text-left ${l===p.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:p.name??p.id}),p.description?e.jsx("div",{className:"truncate text-fg-faint",children:p.description}):null]},p.id))}),detail:r?e.jsx("div",{className:"h-full min-h-0",children:e.jsx($e,{path:r.path,value:r.body,onChange:()=>{},readOnly:!0})}):e.jsx(O,{title:"select a skill"})})})]})}const Ae=s=>{var t,n;return{type:"plugin",name:s.name,repository:(t=s.manifest)==null?void 0:t.repository,homepage:(n=s.manifest)==null?void 0:n.homepage}};function bt({onAdd:s}={}){const t=ie(),[n,a]=o.useState([]),[l,c]=o.useState(!0),[r,x]=o.useState(null),[u,f]=o.useState(null),[v,p]=o.useState(null),[A,$]=o.useState(new Set),P=Ne(i=>i.show),[M,j]=o.useState(null);o.useEffect(()=>{var g,K;let i=!1;return(K=(g=window.api.app).seedStatus)==null||K.call(g).then(_=>{i||p(_)}).catch(()=>{}),()=>{i=!0}},[]);const k=o.useRef(0),y=o.useRef(!1),C=o.useCallback(async()=>{var H,q;const i=++k.current;if(!t)return;y.current||c(!0);const g=`${t}/.claude/plugins/installed_plugins.json`;let K=[],_=null;try{const L=await window.api.config.readJson(g);if(L.exists&&L.parseError)_=`could not parse installed_plugins.json${L.error?`: ${L.error}`:""}`;else if(L.exists&&L.data&&typeof L.data=="object"){const z=L.data,X=[];for(const[h,b]of Object.entries(z.plugins??{})){if(!Array.isArray(b))continue;const[w,T]=h.split("@");for(const d of b)d!=null&&d.installPath&&X.push({name:w,marketplace:T,entry:d})}let Z=new Map;try{const h=await((q=(H=window.api.plugins)==null?void 0:H.list)==null?void 0:q.call(H))??[];Z=new Map(h.map(b=>[b.key,b.enabled]))}catch{}K=await $t(X,St,async({name:h,marketplace:b,entry:w})=>{var S;const T={name:h,path:w.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let d;try{d=await Et(T)}catch(E){d=Ct(T,E instanceof Error?E.message:String(E))}return(S=d.manifest)!=null&&S.version||(d.manifest={...d.manifest??{},version:w.version}),d.marketplace=b,d.scope=w.scope,d.key=b?`${h}@${b}`:h,d.enabled=Z.get(d.key)===!0,d})}}catch(L){_=`could not read installed_plugins.json: ${L instanceof Error?L.message:String(L)}`}k.current===i&&(x(_),_?G.error(`Plugins: ${_}`):(K.sort((L,z)=>L.name.localeCompare(z.name)),y.current=K.length>0,a(K)),c(!1))},[t]);o.useEffect(()=>{C()},[C]),o.useEffect(()=>()=>{k.current+=1},[]),de(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],C);const R=async i=>{if(i.key){j(i.key);try{const g=await window.api.plugins.setEnabled({key:i.key,enabled:!i.enabled});g.ok||P("error",`Could not ${i.enabled?"disable":"enable"} ${i.name}: ${g.error??"unknown error"}`)}catch(g){P("error",`Could not update ${i.name}: ${g instanceof Error?g.message:String(g)}`)}finally{j(null),await C()}}},F=async i=>{if(i.marketplace&&window.confirm(`Uninstall plugin "${i.name}"?`)){j(i.key??i.name);try{const g=await window.api.plugins.uninstall({slug:i.name,marketplaceName:i.marketplace});g.ok||P("error",`Uninstall ${i.name} failed: ${g.error??`exit ${g.exitCode}`}`)}catch(g){P("error",`Uninstall ${i.name} failed: ${g instanceof Error?g.message:String(g)}`)}finally{j(null),await C()}}},I=[{key:"enabled",header:"on",render:i=>e.jsx("button",{type:"button",role:"switch","aria-checked":i.enabled===!0,"aria-label":`${i.enabled?"Disable":"Enable"} ${i.name}`,"data-testid":"plugin-enabled-switch",disabled:!i.key||M===i.key,onClick:g=>{g.stopPropagation(),R(i)},className:`w-8 h-4 rounded-full relative transition-colors ${i.enabled?"bg-accent":"bg-bg-hi border border-line"}`,children:e.jsx("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-fg transition-all ${i.enabled?"left-4":"left-0.5"}`})}),width:"3.5rem"},{key:"name",header:"name",render:i=>{var g;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:i.name}),(g=i.manifest)!=null&&g.description?e.jsx("div",{className:"truncate text-fg-faint",title:i.manifest.description,children:i.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:i=>e.jsx(te,{interactive:!1,input:Ae(i)}),width:"7rem"},{key:"scope",header:"scope",render:i=>i.scope?e.jsx("span",{"data-testid":"plugin-scope",children:i.scope}):e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:i=>{var g;return((g=i.manifest)==null?void 0:g.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:i=>i.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:i=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[i.agents>0?`${i.agents} agents`:null,i.commands>0?`${i.commands} commands`:null,i.skills>0?`${i.skills} skills`:null,i.hooks>0?`${i.hooks} hooks`:null,i.monitors>0?`${i.monitors} monitors`:null,i.binCount>0?`${i.binCount} bin`:null,i.hasLsp?"lsp":null,i.hasMcp?"mcp":null,i.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:i=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:i.path})},{key:"actions",header:"",render:i=>e.jsx("button",{type:"button","data-testid":"plugin-uninstall",disabled:!i.marketplace||M===(i.key??i.name),onClick:g=>{g.stopPropagation(),F(i)},className:"text-xs text-red-300 hover:underline disabled:opacity-40",children:"Uninstall"}),width:"5rem"}],B=o.useMemo(()=>v?Object.keys(v).filter(i=>(v[i].status==="exhausted"||v[i].status==="failed")&&!A.has(i)):[],[v,A]),W=B.length>0?e.jsx(vt,{seeders:B,seedStatus:v,onDismiss:i=>$(g=>new Set(g).add(i)),onOpenLibrary:()=>s==null?void 0:s()}):null,D=u?n.find(i=>i.path===u)??null:null;return e.jsxs(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Add…"})]}),children:[W,r?e.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[r,n.length>0?" — showing the last known list":null]}):null,l&&n.length===0?e.jsx(O,{title:"scanning plugins…"}):r&&n.length===0?null:D?e.jsx(wt,{row:D,home:t,onBack:()=>f(null)},D.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ft,{columns:I,rows:n,getKey:i=>i.path,activeKey:u,onRowClick:i=>f(i.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["use Add… or run ",e.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const jt=o.memo(bt),ce={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function vt({seeders:s,seedStatus:t,onDismiss:n,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:s.map(l=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:t[l].status==="failed"?`${ce[l]} setup failed — it will retry on next launch. To fix it now:`:`${ce[l]} setup failed after retrying — manual fix needed`}),l==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:t[l].fix})]}),e.jsx("button",{onClick:()=>n(l),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${ce[l]} warning`,children:"✕"})]},l))})}const yt=250,kt=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function wt({row:s,home:t,onBack:n}){var L,z,X,Z,h;const[a,l]=o.useState([]),[c,r]=o.useState([]),[x,u]=o.useState([]),[f,v]=o.useState([]),[p,A]=o.useState([]),[$,P]=o.useState("skills"),[M,j]=o.useState(null),[k,y]=o.useState(!0),[C,R]=o.useState([]),F=o.useRef(0),I=o.useRef(!1),B=o.useCallback(async()=>{if(!t)return;const b=++F.current;try{const{manifest:w}=await Te(s.path),[T,d,S]=await Promise.all([Pe(s.path),Re(s.path,w),fe(`${s.path}/bin`,{filesOnly:!0})]),E=T?await Me(T):[],[m,N]=await Promise.all([ye(d.agentFiles),ye(d.commandFiles)]),V=d.mcpServers,Q=await Promise.all([...new Set([...kt.map(U=>`${s.path}/${U}`),...d.sourcePaths])].map(async U=>await window.api.config.exists(U)?U:null));if(b!==F.current)return;l(E),r(m),u(N),v(V),A(S);const se=Q.filter(U=>U!==null);R(U=>U.join("\0")===se.join("\0")?U:se),I.current||(I.current=!0,P(E.length>0?"skills":m.length>0?"agents":N.length>0?"commands":V.length>0?"mcp":s.hooks>0?"hooks":s.monitors>0?"monitors":s.hasLsp?"lsp":"files"))}catch(w){if(b!==F.current)return;G.error(`Failed to load plugin contents: ${w instanceof Error?w.message:String(w)}`)}finally{b===F.current&&y(!1)}},[s.path,s.name,s.hooks,s.monitors,s.hasLsp,t]);o.useEffect(()=>(y(!0),B(),()=>{F.current+=1}),[B]);const W=o.useRef(null),D=o.useRef(!1),i=o.useRef(!1),g=o.useCallback(async()=>{if(D.current){i.current=!0;return}D.current=!0;try{do i.current=!1,await B();while(i.current)}finally{D.current=!1}},[B]),K=o.useCallback(()=>{W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{W.current=null,g()},yt)},[g]);o.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]),de(C,K,{depth:0});const _=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:c.length},{key:"commands",label:"Commands",count:x.length},{key:"mcp",label:"MCP server",count:f.length},{key:"hooks",label:"Hooks",count:s.hooks},{key:"monitors",label:"Monitors",count:s.monitors},{key:"lsp",label:"LSP",count:s.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],H=(L=s.manifest)!=null&&L.author?typeof s.manifest.author=="string"?s.manifest.author:s.manifest.author.name??null:null,q=async b=>{const w=await window.api.shell.open({as:"external",url:b});w.ok||G.error(w.error??`Failed to open ${b}`)};return M?e.jsx(gt,{pluginName:((z=s.manifest)==null?void 0:z.name)??s.name,skills:a,initialSelectedId:M.id,onBack:()=>j(null)},M.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:n,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((X=s.manifest)==null?void 0:X.name)??s.name}),(Z=s.manifest)!=null&&Z.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",s.manifest.version]}):null,(h=s.manifest)!=null&&h.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:s.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(te,{input:Ae(s)}),s.hasMcp?e.jsx(re,{tone:"accent",children:"MCP"}):null]})]}),s.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[H?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),H]}):null,s.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),s.manifest.license]}):null,s.manifest.homepage?e.jsxs("button",{onClick:()=>q(s.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:s.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),s.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:s.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:s.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:_.map(b=>e.jsxs("button",{type:"button",disabled:b.count===0,onClick:()=>P(b.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${b.count===0?"text-fg-faint opacity-50 cursor-default":$===b.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:b.label}),b.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:b.count}):null]},b.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:k?e.jsx(O,{title:"scanning…"}):e.jsx(Nt,{active:$,row:s,skills:a,agents:c,commands:x,mcpServers:f,files:p,onOpenSkill:j})})]})]})}function Nt({active:s,row:t,skills:n,agents:a,commands:l,mcpServers:c,files:r,onOpenSkill:x}){return s==="skills"?n.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:n.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description,onClick:()=>x(u)},u.id))}):s==="agents"?a.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:a.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description},u.id))}):s==="commands"?l.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:l.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description},u.id))}):s==="mcp"?c.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:c.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name,description:u.description},u.id))}):s==="hooks"?t.hooks===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:e.jsx(ee,{n:1,name:`${t.hooks} ${t.hooks===1?"hook":"hooks"} configured`,description:`${t.path}/hooks/hooks.json`})}):s==="monitors"?t.monitors===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:e.jsx(ee,{n:1,name:`${t.monitors} ${t.monitors===1?"monitor":"monitors"} configured`,description:`${t.path}/monitors/monitors.json`})}):s==="lsp"?t.hasLsp?e.jsx("div",{children:e.jsx(ee,{n:1,name:"LSP server enabled",description:`${t.path}/.lsp.json`})}):e.jsx(O,{title:"no components"}):r.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:r.map((u,f)=>e.jsx(ee,{n:f+1,name:u,description:null},u))})}function ee({n:s,name:t,description:n,onClick:a}){const l=a?"button":"div";return e.jsxs(l,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(s).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:t}),n?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:n}):null]})]})}const St=4;async function $t(s,t,n){const a=new Array(s.length);let l=0;const c=Array.from({length:Math.min(t,s.length)},async()=>{for(;l<s.length;){const r=l++;a[r]=await n(s[r])}});return await Promise.all(c),a}function Ct(s,t){return{name:s.name,path:s.path,mtimeMs:s.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,error:t}}async function Et(s){const{hasManifest:t,manifest:n}=await Te(s.path),[a,l]=await Promise.all([window.api.config.exists(`${s.path}/.lsp.json`),window.api.config.exists(`${s.path}/monitors/monitors.json`)]);let c=0;if(l){const p=await window.api.config.readJson(`${s.path}/monitors/monitors.json`);Array.isArray(p.data)?c=p.data.length:p.data&&typeof p.data=="object"&&Array.isArray(p.data.monitors)&&(c=p.data.monitors.length)}const[r,x,u]=await Promise.all([Re(s.path,n),fe(`${s.path}/bin`,{filesOnly:!0}),Pe(s.path)]),f=x.length,v=u?(await Me(u)).length:0;return{name:s.name,path:s.path,mtimeMs:s.mtimeMs,hasManifest:t,manifest:n,hasLsp:a,monitors:c,hooks:r.hooks,agents:r.agentFiles.length,commands:r.commandFiles.length,skills:v,binCount:f,hasMcp:r.mcpServers.length>0}}async function Te(s){let t=`${s}/.claude-plugin/plugin.json`,n=await window.api.config.exists(t);if(n||(t=`${s}/plugin.json`,n=await window.api.config.exists(t)),!n)return{hasManifest:n,manifest:null};const a=await window.api.config.readJson(t),l=a.exists&&!a.parseError&&a.data&&typeof a.data=="object"&&!Array.isArray(a.data);return{hasManifest:n,manifest:l?a.data:null}}const Y=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Pt(s,t){const n=t.startsWith("/")?t.startsWith(`${s}/`)?t.slice(s.length+1):null:t;if(n===null)return ve(t);const a=[];for(const l of n.split("/"))if(!(l===""||l===".")){if(l!=="..")a.push(l);else if(a.pop()===void 0)return ve(t)}return a.length>0?`${s}/${a.join("/")}`:s}function ve(s){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${s}`),null}function Mt(s){return typeof s=="string"?[s]:Array.isArray(s)?s.filter(t=>typeof t=="string"):[]}function At(s){if(!Y(s))return null;if(Y(s.mcpServers))return s.mcpServers;const t=Object.values(s);return t.length>0&&t.every(a=>Y(a)&&(typeof a.command=="string"||typeof a.url=="string"))?s:null}function Tt(s){if(!Y(s))return 0;const t=Y(s.hooks)?s.hooks:s;return Object.values(t).reduce((n,a)=>Array.isArray(a)?n+a.reduce((l,c)=>l+(Y(c)&&Array.isArray(c.hooks)?c.hooks.length:0),0):n,0)}async function Re(s,t){const n=(k,y)=>{const C=new Set;for(const R of Mt(k)){const F=Pt(s,R);F&&C.add(F)}return C.add(`${s}/${y}`),[...C]},a=async k=>{const y=new Set;for(const C of k)if(C.endsWith(".md"))y.add(C);else for(const R of await fe(C,{filesOnly:!0}))R.endsWith(".md")&&y.add(`${C}/${R}`);return[...y]},l=async k=>{try{const y=await window.api.config.readJson(k);return y.exists&&!y.parseError?y.data:null}catch{return null}},c=n(t==null?void 0:t.commands,"commands"),r=n(t==null?void 0:t.agents,"agents"),x=t==null?void 0:t.hooks,u=n(typeof x=="string"||Array.isArray(x)?x:void 0,"hooks/hooks.json"),f=t==null?void 0:t.mcpServers,v=n(typeof f=="string"||Array.isArray(f)?f:void 0,".mcp.json"),[p,A,$,P]=await Promise.all([a(c),a(r),Promise.all(u.map(l)),Promise.all(v.map(l))]),M=[...Y(x)?[x]:[],...$].reduce((k,y)=>k+Tt(y),0),j=new Map;for(const k of[...Y(f)?[f]:[],...P])for(const[y,C]of Object.entries(At(k)??{})){if(j.has(y))continue;const R=Y(C)?C.command:void 0,F=Y(C)?C.url:void 0;j.set(y,{id:y,name:y,description:typeof R=="string"?R:typeof F=="string"?F:null})}return{commandFiles:p,agentFiles:A,hooks:M,mcpServers:[...j.values()],sourcePaths:[...c,...r,...u,...v]}}async function ye(s){const t=await Promise.all(s.map(a=>window.api.config.readText(a))),n=[];return s.forEach((a,l)=>{if(!t[l].exists)return;const c=a.slice(a.lastIndexOf("/")+1),r=pe(t[l].text);n.push({id:a,name:r.name??c.replace(/\.md$/,""),description:r.description})}),n}async function fe(s,t){try{return(await window.api.config.listDir(s,t)).entries.map(a=>a.name)}catch{return[]}}const Rt=[{key:"skills",label:"Skills"},{key:"mcp",label:"MCP Servers"},{key:"plugins",label:"Plugins"}],Lt={skills:"Add skill",mcp:"Add MCP server",plugins:"Add plugin"};function Dt(){const s=ie(),[t,n]=o.useState("skills");De("extensions",v=>{(v==="skills"||v==="mcp"||v==="plugins")&&(n(v),l(!1))});const[a,l]=o.useState(!1),[c,r]=o.useState({scope:"user",cwd:null}),x=o.useCallback(()=>l(!1),[]),u=o.useCallback(v=>{r(v),l(!0)},[]),f=o.useCallback(()=>l(!0),[]);return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"extensions",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-1.5 border-b border-line",children:[e.jsx(Fe,{options:Rt,active:t,onChange:v=>{n(v),l(!1)}}),s&&t==="skills"&&e.jsx(le,{path:`${s}/.claude/skills`,note:"Open ~/.claude/skills/"}),s&&t==="mcp"&&e.jsx(le,{path:`${s}/.claude.json`,keyPath:["mcpServers"]}),s&&t==="plugins"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{path:`${s}/.claude/plugins/installed_plugins.json`}),e.jsx(le,{path:`${s}/.claude/settings.json`,keyPath:["enabledPlugins"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[t==="skills"&&e.jsx(Xe,{onAdd:f,scope:"user"}),t==="mcp"&&e.jsx(ut,{onAdd:u,scope:"user"}),t==="plugins"&&e.jsx(jt,{onAdd:f})]}),e.jsxs(Oe,{open:a,onClose:x,title:Lt[t],keyVals:[],children:[t==="skills"&&e.jsx(Ie,{}),t==="mcp"&&e.jsx(Be,{scope:c.scope,cwd:c.cwd}),t==="plugins"&&e.jsx(We,{})]})]})}const Ut=o.memo(Dt);export{Ut as Extensions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{aE as xe,aM as ze,bt as Ke,at as e,aJ as x,a$ as q,aF as A,aG as L,bm as Ve,bb as Ye,bk as ye,az as Xe,ba as qe,l as Je}from"./index-
|
|
1
|
+
import{aE as xe,aM as ze,bt as Ke,at as e,aJ as x,a$ as q,aF as A,aG as L,bm as Ve,bb as Ye,bk as ye,az as Xe,ba as qe,l as Je}from"./index-QJxszEhM.js";import{P as Qe}from"./Panel-CA6TdCHv.js";import{p as Ee,i as O,m as De,t as I,u as E,f as Ze}from"./historyTotals-NAZqiuzd.js";import"./monaco-editor-BsIlgG7c.js";function ce(){return{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0}}function Ce(t,s){t.promptCount+=s.promptCount,t.inputTokens+=s.inputTokens,t.outputTokens+=s.outputTokens,t.cacheReadTokens+=s.cacheReadTokens,t.cacheCreationTokens+=s.cacheCreationTokens,t.toolCallCount+=s.toolCallCount,t.sessionCount+=s.sessionCount,t.errorCount+=s.errorCount,t.activeMinutes+=s.activeMinutes,t.estimatedCostUsd+=s.estimatedCostUsd}function et(t){return t.promptCount>0||t.sessionCount>0||t.toolCallCount>0||t.inputTokens>0||t.outputTokens>0}function tt(t,s){const n=s===null,r=[],o=ce(),i={};let a=0;for(const c of t.days){const u=ce();let d=!1;for(const[l,p]of Object.entries(c.byProject))if(!(!n&&!s.has(l))){Ce(u,p),Ce(o,p),et(p)&&(d=!0);for(const[m,v]of Object.entries(p.byModel)){const k=i[m]??(i[m]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});k.inputTokens+=v.inputTokens,k.outputTokens+=v.outputTokens,k.cacheReadTokens+=v.cacheReadTokens,k.cacheCreationTokens+=v.cacheCreationTokens,k.costUsd+=v.costUsd,v.estimated&&(k.estimated=!0)}}d&&(a+=1),r.push({date:c.date,totals:u})}return{days:r,totals:o,prevTotals:n?t.prevTotals:ce(),prevAvailable:n,byModelTotals:i,activeDays:a}}function Ue(t,s){if(!s)return{pct:null,direction:"flat"};const n=(t-s)/s*100,r=n>0?"up":n<0?"down":"flat";return{pct:n,direction:r}}function st(t,s,n){return s<=0?0:t/s*n}const nt=["promptCount","inputTokens","outputTokens","cacheReadTokens","cacheCreationTokens","toolCallCount","sessionCount","errorCount","activeMinutes","estimatedCostUsd"],ot=["inputTokens","outputTokens","cacheReadTokens","cacheCreationTokens","costUsd"];function Ne(t){const s={promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0,byModel:{}},n=r=>typeof r=="number"&&Number.isFinite(r)?r:0;for(const r of t){for(const o of nt)s[o]+=n(r[o]);for(const[o,i]of Object.entries(r.byModel??{})){const a=s.byModel[o]??(s.byModel[o]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});for(const c of ot)a[c]+=n(i==null?void 0:i[c])}}return s}const Pe={in:"In tokens",out:"Out tokens",total:"Total tokens",prompts:"Prompts",sessions:"Sessions",time:"Time",spend:"Spend"};function $(t,s){const n=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens;switch(s){case"in":return n;case"out":return t.outputTokens;case"total":return n+t.outputTokens;case"prompts":return t.promptCount;case"sessions":return t.sessionCount;case"time":return t.activeMinutes;case"spend":return t.estimatedCostUsd}}function at(t,s){const n=$(t.totals,s),r=t.prevAvailable?Ue(n,$(t.prevTotals,s)):null,o=t.days.map(i=>$(i.totals,s));return{value:n,delta:r,series:o}}function Te(t,s){const n=new Map,r=Math.ceil(t.length/2);t.forEach((a,c)=>{for(const[u,d]of Object.entries(a.byProject)){let l=n.get(u);l||(l={totals:{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0},toolBreakdown:{},firstHalf:0,secondHalf:0},n.set(u,l)),l.totals.promptCount+=d.promptCount,l.totals.inputTokens+=d.inputTokens,l.totals.outputTokens+=d.outputTokens,l.totals.cacheReadTokens+=d.cacheReadTokens,l.totals.cacheCreationTokens+=d.cacheCreationTokens,l.totals.toolCallCount+=d.toolCallCount,l.totals.sessionCount+=d.sessionCount,l.totals.errorCount+=d.errorCount,l.totals.activeMinutes+=d.activeMinutes,l.totals.estimatedCostUsd+=d.estimatedCostUsd;for(const[m,v]of Object.entries(d.toolBreakdown))l.toolBreakdown[m]=(l.toolBreakdown[m]??0)+v;const p=$(d,s);c<r?l.firstHalf+=p:l.secondHalf+=p}});const o=Array.from(n.entries()).map(([a,c])=>{let u="",d=-1;for(const[l,p]of Object.entries(c.toolBreakdown))p>d&&(d=p,u=l);return{projectDir:a,value:$(c.totals,s),sharePct:0,trend:Ue(c.secondHalf,c.firstHalf),sessions:c.totals.sessionCount,topTool:u}}),i=o.reduce((a,c)=>a+c.value,0);for(const a of o)a.sharePct=i>0?a.value/i*100:0;return o.sort((a,c)=>c.value-a.value)}const rt=["date","cost_usd","input_tokens","output_tokens","cache_write_tokens","cache_read_tokens","total_tokens","cache_hit_pct","num_models","top_model"];function ct(t){return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function we(t){return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreationTokens}function it(t){const s=t.map(n=>{const r=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens,o=n.inputTokens+n.cacheReadTokens+n.cacheCreationTokens,i=o>0?n.cacheReadTokens/o*100:0,a=Object.entries(n.byModel).filter(([,l])=>we(l)>0);let c="",u=-1;for(const[l,p]of a){const m=we(p);m>u&&(u=m,c=l)}return[n.date,n.costUsd.toFixed(4),String(n.inputTokens),String(n.outputTokens),String(n.cacheCreationTokens),String(n.cacheReadTokens),String(r),i.toFixed(1),String(a.length),c?xe(c):""].map(ct).join(",")});return[rt.join(","),...s].join(`
|
|
2
2
|
`)}const lt={folderCount:0,sessionCount:0,promptCount:0,estimatedCostUsd:0,totalTokens:0};function dt(t,s){t.promptCount+=s.promptCount,t.inputTokens+=s.inputTokens,t.outputTokens+=s.outputTokens,t.cacheReadTokens+=s.cacheReadTokens,t.cacheCreationTokens+=s.cacheCreationTokens,t.toolCallCount+=s.toolCallCount,t.sessionCount+=s.sessionCount,t.errorCount+=s.errorCount,t.activeMinutes+=s.activeMinutes,t.estimatedCostUsd+=s.estimatedCostUsd;for(const[n,r]of Object.entries(s.toolBreakdown??{}))t.toolBreakdown[n]=(t.toolBreakdown[n]??0)+r;for(const[n,r]of Object.entries(s.byModel??{})){const o=t.byModel[n]??(t.byModel[n]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});o.inputTokens+=r.inputTokens,o.outputTokens+=r.outputTokens,o.cacheReadTokens+=r.cacheReadTokens,o.cacheCreationTokens+=r.cacheCreationTokens,o.costUsd+=r.costUsd,r.estimated&&(o.estimated=!0)}}function ut(t,s){const n={};for(const[r,o]of Object.entries(t.byModel??{}))n[r]={...o};return{...t,projectDir:s,toolBreakdown:{...t.toolBreakdown??{}},byModel:n}}function ft(t,s){const n={...lt},r=new Set,o=t.map(i=>{const a={};for(const[c,u]of Object.entries(i.byProject)){const d=s[c];if(!d){r.add(c),n.sessionCount+=u.sessionCount,n.promptCount+=u.promptCount,n.estimatedCostUsd+=u.estimatedCostUsd,n.totalTokens+=u.inputTokens+u.outputTokens;continue}const l=a[d];l?dt(l,u):a[d]=ut(u,d)}return{...i,byProject:a}});return n.folderCount=r.size,{days:o,excluded:n}}function xt(t){return t.folderCount>0}function pt(t){const s=[`${t.folderCount} transcript folder${t.folderCount===1?"":"s"} with no resolvable working directory`];return t.sessionCount&&s.push(`${t.sessionCount.toLocaleString()} sessions`),t.promptCount&&s.push(`${t.promptCount.toLocaleString()} prompts`),t.estimatedCostUsd>=.005&&s.push(`$${t.estimatedCostUsd.toFixed(2)}`),`Excluded: ${s.join(" · ")}`}async function pe(){return(await ze()).history??{}}let Re=Promise.resolve();function ue(t){const s=Re.then(async()=>{const n=await pe();await Ke({history:{...n,...t}})});return Re=s.catch(()=>{}),s}const ht=["in","out","total","prompts","sessions","time","spend"],mt=[{value:30,label:"30d"},{value:60,label:"60d"},{value:90,label:"90d"},{value:0,label:"All time"}];function Me({value:t,options:s,onChange:n}){return e.jsx("div",{className:"flex gap-0.5 p-0.5 rounded bg-bg-elev shadow-[inset_0_0_0_1px_rgba(0,0,0,0.06)] text-[11px]",children:s.map(r=>e.jsx("button",{onClick:()=>n(r.value),className:`px-2 py-1 rounded whitespace-nowrap font-mono ${t===r.value?"bg-bg-hi text-fg shadow-sm":"text-fg-faint hover:text-fg"}`,children:r.label},String(r.value)))})}function jt({measure:t,onMeasure:s,range:n,onRange:r,projectsShown:o,projectsTotal:i,fromDate:a,toDate:c,onRefresh:u,onExport:d,exportDisabled:l}){return e.jsxs("div",{className:"sticky top-0 z-10 border-b border-line px-4 py-2.5 flex flex-wrap items-center gap-3 backdrop-blur-sm",style:{backgroundColor:"rgba(246,239,225,0.93)"},children:[e.jsx(Me,{value:t,options:ht.map(p=>({value:p,label:Pe[p]})),onChange:s}),e.jsx(Me,{value:n,options:mt,onChange:r}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[o," / ",i," projects"]}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[a," → ",c]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:u,className:"px-2 py-1 text-[11px] border border-line rounded hover:text-fg hover:bg-bg-hi text-fg-faint",title:"Re-fetch the rollup (no scan)",children:"↻ Refresh"}),e.jsx("button",{onClick:d,disabled:l,className:"px-2 py-1 text-[11px] border border-line rounded hover:text-fg hover:bg-bg-hi text-fg-faint disabled:opacity-40 disabled:pointer-events-none",children:"Export CSV"})]})}const T="rounded-card bg-bg-hi border border-line",gt="#ded2bd",bt="#6f7d52";function R({kicker:t,title:s,right:n}){return e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wider text-accent font-mono",children:t}),e.jsx("h2",{className:"font-serif text-[25px] leading-tight tracking-tight text-fg",children:s})]}),n]})}function J(t,s){switch(t){case"spend":return E(s);case"in":case"out":case"total":return I(s);case"time":return De(s);default:return O(s)}}function vt({measure:t,headline:s,activeDays:n,projectsTouched:r,totalSessions:o}){const i=n>0?s.value/n:0,a=o>0?s.value/o:0,{delta:c}=s,u=c&&(t==="spend"?c.direction==="down":c.direction==="up"),d=c&&c.direction!=="flat"&&(t==="spend"?c.direction==="up":c.direction==="down"),l=u?"text-delta-good":d?"text-delta-bad":"text-fg-faint";return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"01 · overview",title:Pe[t]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[52px] leading-none font-mono tracking-tight text-fg",children:J(t,s.value)}),c?e.jsxs("div",{className:`text-xs font-mono mt-2 ${l}`,children:[c.direction==="up"?"▲":c.direction==="down"?"▼":"·"," ",Ee(Math.abs(c.pct??0))," vs prior period"]}):e.jsx("div",{className:"text-xs text-fg-faint mt-2",children:"no prior window to compare"})]}),e.jsx("div",{className:"flex-1 min-w-0 self-stretch",children:e.jsx(kt,{series:s.series})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-4 pt-3 border-t border-line",children:[e.jsx(X,{label:"per active day",value:J(t,i)}),e.jsx(X,{label:"per session",value:J(t,a)}),e.jsx(X,{label:"active days",value:O(n)}),e.jsx(X,{label:"projects touched",value:O(r)})]})]})}function X({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider",children:t}),e.jsx("div",{className:"text-[17px] font-mono tracking-tight text-fg-dim",children:s})]})}function kt({series:t}){if(t.length<2)return null;const r=Math.max(...t,0),o=Math.min(...t,0),i=r-o||1,a=160/(t.length-1),c=t.map((d,l)=>`${l*a},${48-(d-o)/i*48}`).join(" "),u=`0,48 ${c} 160,48`;return e.jsxs("svg",{viewBox:"0 0 160 48",preserveAspectRatio:"none",className:"w-full h-full min-h-[48px]",children:[e.jsx("polygon",{points:u,fill:"#b85c34",opacity:.15}),e.jsx("polyline",{points:c,fill:"none",stroke:"#b85c34",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})]})}const yt=50;function Ct({days:t}){const[s,n]=x.useState(yt),r=x.useRef(!1);x.useEffect(()=>{let d=!1;return pe().then(l=>{d||r.current||typeof l.budgetCapUsd=="number"&&Number.isFinite(l.budgetCapUsd)&&l.budgetCapUsd>0&&n(l.budgetCapUsd)}),()=>{d=!0}},[]);const o=d=>{r.current=!0;const l=s;n(d),ue({budgetCapUsd:d}).catch(()=>{n(l),q.error("Couldn't save the budget cap — reverted.")})},{mtdSpend:i,projectedSpend:a}=x.useMemo(()=>{const d=new Date,l=d.toLocaleDateString("en-CA").slice(0,7),p=new Date(d.getFullYear(),d.getMonth()+1,0).getDate(),m=d.getDate();let v=0;for(const k of t)if(k.date.startsWith(l))for(const M of Object.values(k.byProject))v+=M.estimatedCostUsd;return{mtdSpend:v,projectedSpend:st(v,m,p)}},[t]),c=a>s,u=s>0?Math.min(100,i/s*100):0;return e.jsxs("div",{className:`${T} p-3`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-[10.5px] uppercase tracking-wider text-fg-faint font-mono",children:"Monthly budget"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-faint",children:["cap",e.jsx("span",{children:"$"}),e.jsx("input",{type:"number",min:1,step:1,value:s,onChange:d=>{const l=Number(d.target.value);Number.isFinite(l)&&l>0&&o(l)},className:"w-16 bg-bg border border-line rounded px-1.5 py-0.5 text-xs text-fg font-mono"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono mb-1.5",children:[e.jsxs("span",{className:"text-fg",children:[E(i)," ",e.jsx("span",{className:"text-fg-faint",children:"month-to-date"})]}),e.jsxs("span",{className:c?"text-delta-bad":"text-fg-dim",children:[E(a)," ",e.jsx("span",{className:"text-fg-faint",children:"projected"})]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:`h-full ${c?"bg-delta-bad":"bg-sage"}`,style:{width:`${Math.max(u,u>0?2:0)}%`}})}),e.jsx("div",{className:`text-[10px] mt-1 font-mono ${c?"text-delta-bad":"text-fg-faint"}`,children:c?`projected to exceed $${s.toFixed(0)} cap`:`${u.toFixed(0)}% of $${s.toFixed(0)} cap`})]})}function Nt({chips:t,keep:s,onToggle:n,onIsolate:r,onShowAll:o}){const i=s===null;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("button",{onClick:o,className:`px-2 py-1 rounded text-[11px] font-mono border ${i?"bg-accent text-white border-accent":"border-line text-fg-faint hover:text-fg hover:bg-bg-hi"}`,children:["show all (",t.length,")"]}),t.map(a=>{const c=i||s.has(a.projectDir);return e.jsxs("button",{onClick:u=>u.shiftKey?r(a.projectDir):n(a.projectDir),title:a.projectDir,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-[11px] font-mono border ${c?"border-line text-fg-dim bg-bg-hi":"border-line text-fg-faint opacity-40 hover:opacity-70"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:A(a.projectDir)}}),L(a.projectDir)]},a.projectDir)})]})}function Tt(t,s){const n=new Map;for(const o of t)for(const[i,a]of Object.entries(o.values))n.set(i,(n.get(i)??0)+a);const r=Array.from(n.entries()).sort((o,i)=>i[1]-o[1]).map(([o])=>o);return t.map(o=>{const i=r.reduce((u,d)=>u+(o.values[d]??0),0);let a=0;const c=r.map(u=>{const d=o.values[u]??0;if(i<=0)return{projectDir:u,value:d,y0:0,y1:0};const l=s==="share"?d/i:d,p=a,m=a+l;return a=m,{projectDir:u,value:d,y0:p,y1:m}});return{date:o.date,bands:c,total:i}})}const ie=720,le=220,de=44,wt=20;function Rt(t,s){return t==="spend"?E(s):I(s)}function Mt({days:t,measure:s,selected:n,onSelect:r}){const[o,i]=x.useState("absolute"),a=x.useMemo(()=>Tt(t,o),[t,o]),c=x.useMemo(()=>{if(o==="share")return 1;let h=0;for(const g of a)h=Math.max(h,g.total);return h||1},[a,o]),u=ie-de,d=le-wt,l=a.length>1?u/(a.length-1):u,p=h=>de+h*l,m=h=>d-h/c*d,v=Math.max(1,Math.ceil(a.length/8)),k=4,M=Array.from({length:k+1},(h,g)=>c/k*g);return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"02 · over time",title:"Trend by project",right:e.jsx("div",{className:"flex border border-line rounded overflow-hidden text-[10px] font-mono",children:["absolute","share"].map(h=>e.jsx("button",{onClick:()=>i(h),className:`px-2 py-0.5 ${o===h?"bg-accent text-white":"text-fg-faint hover:text-fg"}`,children:h},h))})}),e.jsxs("svg",{width:"100%",viewBox:`0 0 ${ie} ${le}`,className:"overflow-visible",children:[M.map((h,g)=>e.jsxs("g",{children:[e.jsx("line",{x1:de,x2:ie,y1:m(h),y2:m(h),stroke:"currentColor",className:"text-line",strokeWidth:1}),e.jsx("text",{x:0,y:m(h)+3,fontSize:9,className:"fill-fg-faint",children:o==="share"?`${Math.round(h*100)}%`:Rt(s,h)})]},g)),a.map((h,g)=>{if(g===0)return null;const D=a[g-1];return h.bands.map((j,Z)=>{const G=D.bands[Z],W=n!==null&&n!==j.projectDir,ee=W?gt:A(j.projectDir),te=[`${p(g-1)},${m(G.y0)}`,`${p(g)},${m(j.y0)}`,`${p(g)},${m(j.y1)}`,`${p(g-1)},${m(G.y1)}`].join(" ");return e.jsx("polygon",{points:te,fill:ee,opacity:W?.6:.75,className:"cursor-pointer",onClick:()=>r(n===j.projectDir?null:j.projectDir),children:e.jsx("title",{children:L(j.projectDir)})},`${j.projectDir}-${g}`)})}),a.map((h,g)=>g%v!==0&&g!==a.length-1?null:e.jsx("text",{x:p(g),y:le-4,fontSize:9,textAnchor:"middle",className:"fill-fg-faint",children:h.date.slice(5)},h.date))]})]})}function St({rows:t,measure:s,selected:n,onSelect:r}){return t.length?e.jsxs("div",{className:`${T} overflow-hidden`,children:[e.jsx("div",{className:"p-4 pb-0",children:e.jsx(R,{kicker:"03 · by project",title:"Ranking"})}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-bg-elev",children:e.jsx("tr",{children:["project","share","value","share %","trend","sessions","top tool"].map(o=>e.jsx("th",{className:"text-left px-3 py-2 text-fg-faint uppercase tracking-wider whitespace-nowrap",children:o},o))})}),e.jsx("tbody",{children:t.map(o=>{const i=A(o.projectDir),a=n===o.projectDir;return e.jsxs("tr",{onClick:()=>r(o.projectDir),className:`border-t border-line hover:bg-bg-elev cursor-pointer ${a?"bg-bg-elev":""}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono text-fg-dim",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:i}}),L(o.projectDir)]})}),e.jsx("td",{className:"px-3 py-2 w-32",children:e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(o.sharePct,o.sharePct>0?2:0)}%`,backgroundColor:i}})})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:J(s,o.value)}),e.jsxs("td",{className:"px-3 py-2 text-fg-faint font-mono",children:[o.sharePct.toFixed(1),"%"]}),e.jsx("td",{className:"px-3 py-2 font-mono",children:o.trend.pct===null?e.jsx("span",{className:"text-fg-faint",children:"—"}):e.jsxs("span",{className:o.trend.direction==="up"?"text-delta-good":o.trend.direction==="down"?"text-delta-bad":"text-fg-faint",children:[o.trend.direction==="up"?"▲":o.trend.direction==="down"?"▼":"·"," ",Ee(Math.abs(o.trend.pct))]})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:O(o.sessions)}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:o.topTool||"—"})]},o.projectDir)})})]})]}):e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"03 · by project",title:"Ranking"}),e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"})]})}function $t({projectDir:t,totals:s,byModel:n,toolBreakdown:r,onClear:o}){var l;const i=$(s,"in"),a=$(s,"out"),c=Object.entries(n).sort((p,m)=>m[1].costUsd-p[1].costUsd),u=Object.entries(r).sort((p,m)=>m[1]-p[1]),d=((l=u[0])==null?void 0:l[1])??0;return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"04 · drill in",title:L(t),right:e.jsx("button",{onClick:o,className:"text-[11px] text-fg-faint hover:text-fg font-mono",children:"clear ✕"})}),e.jsx("div",{className:"flex items-center gap-1.5 -mt-2 mb-3",children:e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:A(t)}})}),e.jsxs("div",{className:"grid grid-cols-6 gap-3 mb-4",children:[e.jsx(H,{label:"prompts",value:O(s.promptCount)}),e.jsx(H,{label:"sessions",value:O(s.sessionCount)}),e.jsx(H,{label:"in tokens",value:I(i)}),e.jsx(H,{label:"out tokens",value:I(a)}),e.jsx(H,{label:"spend",value:E(s.estimatedCostUsd)}),e.jsx(H,{label:"time",value:De(s.activeMinutes)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"model mix"}),c.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data"}):e.jsx("div",{className:"space-y-1",children:c.map(([p,m])=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-fg-dim",children:[e.jsx("span",{children:xe(p)}),e.jsx("span",{className:"text-fg-faint",children:E(m.costUsd)})]},p))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"tool mix"}),u.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no tool data"}):e.jsx("div",{className:"space-y-1",children:u.slice(0,6).map(([p,m])=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"w-20 shrink-0 truncate text-fg-dim font-mono",children:p}),e.jsx("div",{className:"flex-1 h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full bg-hive-teal",style:{width:`${d>0?m/d*100:0}%`}})}),e.jsx("span",{className:"text-fg-faint font-mono w-8 text-right",children:m})]},p))})]})]})]})}function H({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider",children:t}),e.jsx("div",{className:"text-[17px] font-mono tracking-tight text-fg",children:s})]})}function Et({byModelTotals:t}){const s=Object.entries(t).sort((r,o)=>o[1].costUsd-r[1].costUsd),n=s.reduce((r,[,o])=>r+o.costUsd,0);return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"05 · composition",title:"Model mix",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:[E(n)," total"]})}),s.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data in range"}):e.jsx("div",{className:"space-y-2",children:s.map(([r,o])=>{const i=n>0?o.costUsd/n*100:0,a=A(r);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-fg-dim truncate",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{backgroundColor:a}}),xe(r),o.estimated&&e.jsx("span",{className:"text-fg-faint",children:"(est.)"})]}),e.jsxs("span",{className:"text-fg-faint whitespace-nowrap ml-2",children:[E(o.costUsd)," · ",i.toFixed(0),"%"]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(i,i>0?2:0)}%`,backgroundColor:a}})})]},r)})})]})}function Dt({rows:t}){const s=t.slice(0,3),n=s.reduce((i,a)=>i+a.sharePct,0),r=t.slice(3),o=r.reduce((i,a)=>i+a.sharePct,0);return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"05 · composition",title:"Concentration",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["top 3 = ",n.toFixed(0),"%"]})}),t.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-3 rounded overflow-hidden mb-2",children:t.map(i=>e.jsx("div",{style:{width:`${Math.max(i.sharePct,.5)}%`,backgroundColor:A(i.projectDir)},title:`${L(i.projectDir)} · ${i.sharePct.toFixed(1)}%`},i.projectDir))}),e.jsx("div",{className:"space-y-1 mb-2",children:s.map(i=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim truncate",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:A(i.projectDir)}}),L(i.projectDir)]}),e.jsxs("span",{className:"text-fg-faint",children:[i.sharePct.toFixed(1),"%"]})]},i.projectDir))}),r.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-faint",children:[r.length," more project",r.length===1?"":"s"," account for ",o.toFixed(1),"% (long tail)."]})]})]})}const Q=30,fe=9,P=(Q+fe)*2;function Ut({totals:t}){const s=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,n=s>0?t.cacheReadTokens/s*100:0,r=2*Math.PI*Q,o=P/2;return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"05 · composition",title:"Cache"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative shrink-0",style:{width:P,height:P},children:[e.jsxs("svg",{width:P,height:P,viewBox:`0 0 ${P} ${P}`,className:"-rotate-90",children:[e.jsx("circle",{cx:o,cy:o,r:Q,fill:"none",stroke:"currentColor",className:"text-bg-hi",strokeWidth:fe}),e.jsx("circle",{cx:o,cy:o,r:Q,fill:"none",stroke:bt,strokeWidth:fe,strokeDasharray:r,strokeDashoffset:r*(1-n/100),strokeLinecap:"round"})]}),e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-[13px] font-mono text-fg",children:[n.toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-[11px] space-y-1 font-mono",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-fg-faint",children:"reused (cache read)"}),e.jsx("span",{className:"text-fg-dim",children:I(t.cacheReadTokens)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-fg-faint",children:"written to cache"}),e.jsx("span",{className:"text-fg-dim",children:I(t.cacheCreationTokens)})]})]})]})]})}const Pt=.05,At="—",Se=t=>`$${t.toFixed(2)}`;function Ft(){const[t,s]=x.useState(null),[n,r]=x.useState(null),o=Ve(a=>a.show);x.useEffect(()=>{let a=!0;const c=()=>{window.api.history.loopEfficiency().then(d=>{a&&(s(d),r(null))}).catch(d=>{if(!a)return;const l=d instanceof Error?d.message:String(d);r(l),o("error",`Loop efficiency failed to load: ${l}`)})};c();const u=window.api.history.onUpdated(c);return()=>{a=!1,u()}},[o]);let i;if(n&&!t)i=e.jsxs("div",{"data-testid":"loop-eff-error",className:"text-[11px] font-mono text-fg-faint",children:["Failed to load: ",n]});else if(!t)i=e.jsx("div",{"data-testid":"loop-eff-loading",className:"text-[11px] font-mono text-fg-faint",children:"Loading…"});else if(t.rows.length===0)i=e.jsx("div",{"data-testid":"loop-eff-empty",className:"text-[11px] font-mono text-fg-faint",children:"No runs this week."});else{const a=t.totals.wastedRunRate>Pt;i=e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-[11px] font-mono","data-testid":"loop-eff-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-fg-faint text-left",children:[e.jsx("th",{className:"font-normal",children:"Project"}),e.jsx("th",{className:"font-normal text-right",children:"Runs"}),e.jsx("th",{className:"font-normal text-right",children:"Wasted"}),e.jsx("th",{className:"font-normal text-right",children:"Verified"}),e.jsx("th",{className:"font-normal text-right",children:"Refuted"}),e.jsx("th",{className:"font-normal text-right",children:"List-price $"}),e.jsx("th",{className:"font-normal text-right",children:"$ / verified"})]})}),e.jsx("tbody",{className:"text-fg-dim",children:t.rows.map(c=>e.jsxs("tr",{"data-testid":"loop-eff-row",children:[e.jsx("td",{children:c.project}),e.jsx("td",{className:"text-right",children:c.runs}),e.jsx("td",{className:"text-right",children:c.wastedRuns}),e.jsx("td",{className:"text-right",children:c.verified}),e.jsx("td",{className:"text-right",children:c.refuted}),e.jsx("td",{className:"text-right",children:Se(c.executorUsd)}),e.jsx("td",{className:"text-right","data-testid":"loop-eff-per-verified",children:c.usdPerVerified==null?At:Se(c.usdPerVerified)})]},c.cwd))})]}),e.jsxs("div",{"data-testid":"loop-eff-totals","data-warning":a?"true":"false",className:`mt-2 text-[11px] font-mono ${a?"text-amber-300":"text-fg-dim"}`,children:["wasted runs ",(t.totals.wastedRunRate*100).toFixed(1),"% (",t.totals.wastedRuns,"/",t.totals.runs,") · target ≤ 5%"]}),e.jsx("div",{"data-testid":"loop-eff-usage",className:"mt-1 text-[11px] font-mono text-fg-faint",children:t.verifiedPerUsagePct!=null?`${t.verifiedPerUsagePct} verified PRDs per 1% of weekly usage`:"weekly usage unavailable"})]})}return e.jsxs("div",{className:`${T} p-4`,"data-testid":"loop-efficiency",children:[e.jsx(R,{kicker:"06 · reliability",title:"Loop efficiency"}),i]})}const _t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Bt({days:t,measure:s}){const{buckets:n,weekendShare:r,peakIdx:o}=x.useMemo(()=>{const a=new Array(7).fill(0);for(const l of t){const[p,m,v]=l.date.split("-").map(Number),k=new Date(p,m-1,v).getDay();a[k]+=$(l.totals,s)}const c=a.reduce((l,p)=>l+p,0),u=a[0]+a[6];let d=0;for(let l=1;l<7;l++)a[l]>a[d]&&(d=l);return{buckets:a,weekendShare:c>0?u/c*100:0,peakIdx:d}},[t,s]),i=Math.max(...n,1);return e.jsxs("div",{className:`${T} p-4`,children:[e.jsx(R,{kicker:"05 · composition",title:"Rhythm",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["weekend ",r.toFixed(0),"%"]})}),e.jsx("div",{className:"flex items-end gap-2 h-24",children:n.map((a,c)=>e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end gap-1 h-full",children:[e.jsx("div",{className:`w-full rounded-t ${c===o?"bg-accent":"bg-rhythm"}`,style:{height:`${i>0?a/i*100:0}%`,minHeight:a>0?2:0}}),e.jsx("span",{className:"text-[9px] text-fg-faint font-mono",children:_t[c]})]},c))})]})}const Ht=["in","out","total","prompts","sessions","time","spend"],Lt=[30,60,90,0],Ot="spend",It=30,Wt=3e4,Gt=[];function zt(){var ke;const[t,s]=x.useState(Ot),[n,r]=x.useState(It),o=x.useRef(!1),i=x.useRef(!1),a=f=>{o.current=!0;const b=t;s(f),ue({measure:f}).catch(()=>{s(b),q.error("Couldn't save the measure preference — reverted.")})},c=f=>{i.current=!0;const b=n;r(f),ue({range:f}).catch(()=>{r(b),q.error("Couldn't save the range preference — reverted.")})};x.useEffect(()=>{let f=!1;return pe().then(b=>{f||(!o.current&&b.measure&&Ht.includes(b.measure)&&s(b.measure),!i.current&&b.range!==void 0&&Lt.includes(b.range)&&r(b.range))}),()=>{f=!0}},[]);const u=Ye(f=>f.navFace),d=ye(f=>f.tabs),l=ye(f=>f.activeTabId),p=((ke=d.find(f=>f.id===l))==null?void 0:ke.cwd)??null,m=x.useRef(u),v=p?Xe(p):null,[k,M]=x.useState(null),h=x.useMemo(()=>u==="project"&&v?new Set([v]):k,[u,v,k]),[g,D]=x.useState(null),[j,Z]=x.useState(null),[G,W]=x.useState(!0),[ee,te]=x.useState(0),se=x.useRef(n);se.current=n;const z=x.useRef(!0),ne=x.useRef(0),he=x.useRef(0),F=x.useRef(null),K=x.useCallback(f=>{const b=se.current;ne.current+=1,he.current=Date.now(),Ze(b).then(y=>{if(ne.current-=1,!(!z.current||b!==se.current)){if(W(!1),y.ok){Z(y.data);return}f||q.error(`History analytics failed to load: ${y.error}`)}})},[]);x.useEffect(()=>{z.current=!0,W(!0),K(!1)},[n,ee,K]),x.useEffect(()=>{const f=()=>{if(!z.current)return;const N=he.current+Wt-Date.now();if(ne.current===0&&N<=0){K(!0);return}F.current||(F.current=setTimeout(()=>{F.current=null,f()},Math.max(N,1e3)))},b=()=>{document.visibilityState==="visible"&&f()},y=window.api.history.onUpdated(f);return window.addEventListener("focus",f),document.addEventListener("visibilitychange",b),()=>{z.current=!1,y(),window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",b),F.current&&(clearTimeout(F.current),F.current=null)}},[K]);const me=x.useRef(!1);x.useEffect(()=>{if(!me.current){me.current=!0;return}M(null),D(null)},[n]),x.useEffect(()=>{m.current!==u&&(m.current=u,u==="home"&&M(null))},[u]);const{projects:je,resolving:ge}=qe(),be=x.useMemo(()=>{const f={};for(const b of je)for(const y of b.encodedIds)f[y]=b.cwd;return f},[je]),_=x.useMemo(()=>j&&!ge?ft(j.days,be):null,[j,be,ge]),w=(_==null?void 0:_.days)??(j==null?void 0:j.days)??Gt,oe=(_==null?void 0:_.excluded)??null,S=x.useMemo(()=>j?tt({days:w,totals:j.totals,prevTotals:j.prevTotals},h):null,[j,w,h]),B=x.useMemo(()=>h===null?w:w.map(f=>({date:f.date,byProject:Object.fromEntries(Object.entries(f.byProject).filter(([b])=>h.has(b)))})),[w,h]),V=x.useMemo(()=>Te(w,t),[w,t]),ae=x.useMemo(()=>Te(B,t),[B,t]),Ae=x.useMemo(()=>B.map(f=>({date:f.date,values:Object.fromEntries(Object.entries(f.byProject).map(([b,y])=>[b,$(y,t)]))})),[B,t]),ve=x.useMemo(()=>S?at(S,t):null,[S,t]),Y=x.useMemo(()=>{if(!j||!g)return null;const f=w.flatMap(C=>C.byProject[g]?[C.byProject[g]]:[]),{byModel:b,...y}=Ne(f),N={};for(const C of f)for(const[U,re]of Object.entries(C.toolBreakdown))N[U]=(N[U]??0)+re;return{totals:y,byModel:b,toolBreakdown:N}},[j,w,g]);x.useEffect(()=>{g&&h!==null&&!h.has(g)&&D(null)},[g,h]);function Fe(f){M(b=>{const y=new Set(V.map(U=>U.projectDir)),N=b??new Set(y),C=new Set(N);return C.has(f)?C.delete(f):C.add(f),C.size>=y.size?null:C})}function _e(f){M(new Set([f]))}function Be(){M(null)}function He(){if(!j)return;const f=B.map(U=>{const{byModel:re,estimatedCostUsd:Le,inputTokens:Oe,outputTokens:Ie,cacheCreationTokens:We,cacheReadTokens:Ge}=Ne(Object.values(U.byProject));return{date:U.date,costUsd:Le,inputTokens:Oe,outputTokens:Ie,cacheCreationTokens:We,cacheReadTokens:Ge,byModel:re}}),b=it(f),y=new Blob([b],{type:"text/csv"}),N=URL.createObjectURL(y),C=document.createElement("a");C.href=N,C.download=`usage-history-${j.from}-${j.to}.csv`,C.click(),URL.revokeObjectURL(N)}return G&&!j?e.jsx($e,{}):j&&j.days.length===0?e.jsx(Je,{title:"no sessions in range",hint:"Widen the range or check back after your next session."}):!j||!S||!ve?e.jsx($e,{}):e.jsxs("div",{"data-testid":"history-dashboard",className:"flex flex-col h-full",children:[e.jsxs("h1",{className:"font-serif text-[42px] leading-tight tracking-tight text-fg px-4 pt-4",children:["Where your ",e.jsx("em",{className:"italic text-accent",children:"Claude time"})," goes"]}),e.jsx(jt,{measure:t,onMeasure:a,range:n,onRange:c,projectsShown:h===null?V.length:h.size,projectsTotal:V.length,fromDate:j.from,toDate:j.to,onRefresh:()=>te(f=>f+1),onExport:He,exportDisabled:B.length===0}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-4 space-y-4",children:[e.jsx(vt,{measure:t,headline:ve,activeDays:S.activeDays,projectsTouched:ae.length,totalSessions:S.totals.sessionCount}),e.jsx(Ct,{days:w}),oe&&xt(oe)&&e.jsx("div",{"data-testid":"history-excluded-note",className:"rounded-[10px] border border-line bg-bg-hi px-3 py-2 text-[11.5px] font-mono text-fg-faint",title:"A project is a working directory. ~/.claude/projects holds one folder per path the CLI was ever launched from — throwaway /tmp dirs and test fixtures included — and a folder whose cwd can't be recovered from its transcripts is not a project. Their totals are stated here rather than silently folded into the charts.",children:pt(oe)}),u==="home"&&e.jsx(Nt,{chips:V.map(f=>({projectDir:f.projectDir,value:f.value})),keep:h,onToggle:Fe,onIsolate:_e,onShowAll:Be}),e.jsx(Mt,{days:Ae,measure:t,selected:g,onSelect:D}),e.jsx(St,{rows:ae,measure:t,selected:g,onSelect:D}),g&&Y&&e.jsx($t,{projectDir:g,totals:Y.totals,byModel:Y.byModel,toolBreakdown:Y.toolBreakdown,onClear:()=>D(null)}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(Et,{byModelTotals:S.byModelTotals}),e.jsx(Dt,{rows:ae}),e.jsx(Ut,{totals:S.totals}),e.jsx(Bt,{days:S.days,measure:t})]}),e.jsx(Ft,{})]})]})}function $e(){return e.jsxs("div",{className:"p-4 space-y-4 animate-pulse",children:[e.jsx("div",{className:"h-24 bg-bg-elev rounded"}),e.jsx("div",{className:"h-16 bg-bg-elev rounded"}),e.jsx("div",{className:"h-8 bg-bg-elev rounded"}),e.jsx("div",{className:"h-56 bg-bg-elev rounded"}),e.jsx("div",{className:"h-40 bg-bg-elev rounded"})]})}function Kt(){return e.jsx(Qe,{children:e.jsx(zt,{})})}const Jt=x.memo(Kt);export{Jt as History};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{at as e,am as J,a$ as w,aJ as p,b3 as O,a5 as Y,b9 as I,l as R,b as k,au as X,a9 as Z}from"./index-DfWJO7nP.js";import{B as _}from"./Button-fOCJry21.js";function fe({dirty:t,busy:a,parseError:i,lastSavedAt:n,onSave:s,onRevert:r,leading:u}){const o=t&&!a&&!i;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:u}),i&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:i,children:i}),!t&&!i&&n&&e.jsx("span",{className:"text-fg-faint",children:J(n)}),t&&!i&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:r,disabled:!t||a,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:s,disabled:!o,className:`px-2.5 py-0.5 rounded border ${o?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:a?"Saving…":"Save"})]})}const K=/<[A-Za-z][A-Za-z0-9_-]*>/g,ee=/<[A-Za-z][A-Za-z0-9_-]*>/;function te(t){return t.match(K)??[]}function se(t){const a=[],i=(s,r)=>{if(typeof s=="string")for(const u of te(s))a.push({token:u,label:r})};i(t.command,"command");const n=Array.isArray(t.args)?t.args:[];n.forEach((s,r)=>{if(typeof s!="string")return;const u=n[r-1],o=r>0&&typeof u=="string"&&u.startsWith("-")&&!ee.test(u)?`${u} ${s}`:s;i(s,o)});for(const[s,r]of Object.entries(t.env??{}))i(r,`env ${s}`);return i(t.url,"url"),a}function ie(t){const a=new Map;for(const i of se(t))a.has(i.token)||a.set(i.token,i);return[...a.values()]}function ne(t,a){const i=s=>s.replace(K,r=>Object.prototype.hasOwnProperty.call(a,r)?a[r]:r),n={...t};return typeof n.command=="string"&&(n.command=i(n.command)),Array.isArray(n.args)&&(n.args=n.args.map(s=>typeof s=="string"?i(s):s)),n.env&&(n.env=Object.fromEntries(Object.entries(n.env).map(([s,r])=>[s,typeof r=="string"?i(r):r]))),typeof n.url=="string"&&(n.url=i(n.url)),n}const T=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function ae(t){if(typeof t=="string")return t;if(T(t)){for(const a of["url","repo","path"])if(typeof t[a]=="string")return t[a]}return""}async function oe(t){const a=`${t}/.claude/plugins`,i=[];let n;try{const s=await window.api.config.readJson(`${a}/known_marketplaces.json`);if(s.parseError||s.error)return w.error(`known_marketplaces.json unreadable: ${s.parseError??s.error}`),i;if(!s.exists)return i;if(!T(s.data))return w.error("known_marketplaces.json is not an object"),i;n=s.data}catch(s){return w.error(`known_marketplaces.json unreadable: ${s instanceof Error?s.message:String(s)}`),i}for(const[s,r]of Object.entries(n)){const o=`${T(r)&&typeof r.installLocation=="string"?r.installLocation:`${a}/marketplaces/${s}`}/.claude-plugin/marketplace.json`;try{const m=await window.api.config.readJson(o);if(!m.exists){w.warn(`Marketplace ${s}: ${o} not found`);continue}if(m.parseError||m.error||!T(m.data)||!Array.isArray(m.data.plugins)){w.error(`Marketplace ${s}: invalid marketplace.json${m.parseError?` — ${m.parseError}`:""}`);continue}for(const l of m.data.plugins)!T(l)||typeof l.name!="string"||!l.name||i.push({marketplace:s,name:l.name,description:typeof l.description=="string"?l.description:"",source:ae(l.source)})}catch(m){w.error(`Marketplace ${s}: ${m instanceof Error?m.message:String(m)}`)}}return i}const q=[{id:"filesystem",name:"Filesystem",description:"Secure file operations with configurable access controls",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem",config:{command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","<path>"]},envVars:[]},{id:"fetch",name:"Fetch",description:"Web content fetching and conversion for efficient LLM usage",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/fetch",config:{command:"uvx",args:["mcp-server-fetch"]},envVars:[]},{id:"memory",name:"Memory",description:"Knowledge graph-based persistent memory system",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/memory",config:{command:"npx",args:["-y","@modelcontextprotocol/server-memory"]},envVars:[]},{id:"sequential-thinking",name:"Sequential Thinking",description:"Dynamic and reflective problem-solving through thought sequences",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",config:{command:"npx",args:["-y","@modelcontextprotocol/server-sequential-thinking"]},envVars:[]},{id:"git",name:"Git",description:"Tools to read, search, and manipulate Git repositories",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/git",config:{command:"uvx",args:["mcp-server-git","--repository","<path>"]},envVars:[]},{id:"time",name:"Time",description:"Time and timezone conversion capabilities",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/time",config:{command:"uvx",args:["mcp-server-time"]},envVars:[]},{id:"everything",name:"Everything",description:"Reference/test server with prompts, resources, and tools",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/everything",config:{command:"npx",args:["-y","@modelcontextprotocol/server-everything"]},envVars:[]},{id:"github",name:"GitHub",description:"Official GitHub repository, issues, and PR management",official:!1,homepage:"https://github.com/github/github-mcp-server",config:{command:"docker",args:["run","-i","--rm","-e","GITHUB_PERSONAL_ACCESS_TOKEN","ghcr.io/github/github-mcp-server"]},envVars:["GITHUB_PERSONAL_ACCESS_TOKEN"]},{id:"gitlab",name:"GitLab",description:"GitLab API integration for projects, issues, and merge requests",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/gitlab",config:{command:"npx",args:["-y","@modelcontextprotocol/server-gitlab"]},envVars:["GITLAB_PERSONAL_ACCESS_TOKEN","GITLAB_API_URL"]},{id:"postgres",name:"PostgreSQL",description:"Read-only database access with schema inspection",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/postgres",config:{command:"npx",args:["-y","@modelcontextprotocol/server-postgres","<connection-string>"]},envVars:[]},{id:"sqlite",name:"SQLite",description:"Database interaction and business intelligence over SQLite",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/sqlite",config:{command:"uvx",args:["--with","mcp<2","mcp-server-sqlite","--db-path","<path>"]},envVars:[]},{id:"slack",name:"Slack",description:"Channel management and messaging for Slack workspaces",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/slack",config:{command:"npx",args:["-y","@modelcontextprotocol/server-slack"]},envVars:["SLACK_BOT_TOKEN","SLACK_TEAM_ID"]},{id:"google-drive",name:"Google Drive",description:"File access and search for Google Drive",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/gdrive",config:{command:"npx",args:["-y","@modelcontextprotocol/server-gdrive"]},envVars:["GDRIVE_CREDENTIALS_PATH"]},{id:"google-maps",name:"Google Maps",description:"Location services, directions, and place details",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/google-maps",config:{command:"npx",args:["-y","@modelcontextprotocol/server-google-maps"]},envVars:["GOOGLE_MAPS_API_KEY"]},{id:"puppeteer",name:"Puppeteer",description:"Browser automation and web scraping via Puppeteer",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/puppeteer",config:{command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]},envVars:[]},{id:"playwright",name:"Playwright",description:"Cross-browser automation for navigation, screenshots, and data extraction",official:!1,homepage:"https://github.com/microsoft/playwright-mcp",config:{command:"npx",args:["-y","@playwright/mcp@latest"]},envVars:[]},{id:"brave-search",name:"Brave Search",description:"Web and local search using the Brave Search API",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/brave-search",config:{command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]},envVars:["BRAVE_API_KEY"]},{id:"redis",name:"Redis",description:"Interact with Redis key-value stores",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/redis",config:{command:"npx",args:["-y","@modelcontextprotocol/server-redis","<redis-url>"]},envVars:[]},{id:"sentry",name:"Sentry",description:"Retrieve and analyze Sentry error tracking issues",official:!1,homepage:"https://github.com/getsentry/sentry-mcp",config:{command:"npx",args:["-y","@sentry/mcp-server@latest"]},envVars:["SENTRY_AUTH_TOKEN"]},{id:"linear",name:"Linear",description:"Issue tracking and project management for Linear",official:!1,homepage:"https://linear.app/docs/mcp",config:{command:"npx",args:["-y","mcp-remote","https://mcp.linear.app/sse"]},envVars:[]},{id:"notion",name:"Notion",description:"Notion workspace page and database management",official:!1,homepage:"https://github.com/makenotion/notion-mcp-server",config:{command:"npx",args:["-y","@notionhq/notion-mcp-server"]},envVars:["NOTION_API_KEY"]},{id:"stripe",name:"Stripe",description:"Payment processing, customers, and invoices via Stripe API",official:!1,homepage:"https://github.com/stripe/agent-toolkit",config:{command:"npx",args:["-y","@stripe/mcp","--tools=all"]},envVars:["STRIPE_SECRET_KEY"]},{id:"cloudflare",name:"Cloudflare",description:"Manage Cloudflare Workers, KV, R2, D1, and Workers AI",official:!1,homepage:"https://github.com/cloudflare/mcp-server-cloudflare",config:{command:"npx",args:["-y","mcp-remote","https://observability.mcp.cloudflare.com/sse"]},envVars:[]},{id:"context7",name:"Context7",description:"Up-to-date version-specific library docs injected into prompts",official:!1,homepage:"https://github.com/upstash/context7",config:{command:"npx",args:["-y","@upstash/context7-mcp@latest"]},envVars:[]},{id:"tavily",name:"Tavily",description:"AI-optimized web search with clean structured results",official:!1,homepage:"https://github.com/tavily-ai/tavily-mcp",config:{command:"npx",args:["-y","tavily-mcp@latest"]},envVars:["TAVILY_API_KEY"]},{id:"perplexity",name:"Perplexity",description:"Answer-engine search with deep research and reasoning",official:!1,homepage:"https://github.com/ppl-ai/modelcontextprotocol",config:{command:"npx",args:["-y","server-perplexity-ask"]},envVars:["PERPLEXITY_API_KEY"]},{id:"figma",name:"Figma Dev Mode",description:"First-party Figma design-to-code bridge exposing node tree",official:!1,homepage:"https://help.figma.com/hc/en-us/articles/32132100833559",config:{url:"http://127.0.0.1:3845/sse"},envVars:[]},{id:"supabase",name:"Supabase",description:"Manage Supabase projects, tables, and SQL queries",official:!1,homepage:"https://github.com/supabase-community/supabase-mcp",config:{command:"npx",args:["-y","@supabase/mcp-server-supabase@latest"]},envVars:["SUPABASE_ACCESS_TOKEN"]},{id:"atlassian",name:"Atlassian (Jira/Confluence)",description:"Official Jira and Confluence integration",official:!1,homepage:"https://www.atlassian.com/platform/remote-mcp-server",config:{command:"npx",args:["-y","mcp-remote","https://mcp.atlassian.com/v1/sse"]},envVars:[]},{id:"aws",name:"AWS",description:"AWS services access and best-practice guidance",official:!1,homepage:"https://github.com/awslabs/mcp",config:{command:"uvx",args:["awslabs.core-mcp-server@latest"]},envVars:["AWS_PROFILE","AWS_REGION"]},{id:"obsidian",name:"Obsidian",description:"Read and search notes in an Obsidian vault",official:!1,homepage:"https://github.com/MarkusPfundstein/mcp-obsidian",config:{command:"uvx",args:["mcp-obsidian"]},envVars:["OBSIDIAN_API_KEY"]}],F=[{id:"pdf",name:"PDF",description:"Create, edit, and extract content from PDF documents",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/pdf"},{id:"docx",name:"DOCX",description:"Create and edit Microsoft Word documents",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/docx"},{id:"xlsx",name:"XLSX",description:"Create and edit Excel spreadsheets with formulas and formatting",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/xlsx"},{id:"pptx",name:"PPTX",description:"Create and edit PowerPoint presentations",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/pptx"},{id:"webapp-testing",name:"Webapp Testing",description:"Test web applications using Playwright-driven browser automation",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/webapp-testing"},{id:"playwright-e2e",name:"Playwright E2E",description:"End-to-end browser tests — navigation, forms, assertions, waiting strategies",official:!1,source:"local"},{id:"playwright-visual-testing",name:"Playwright Visual Testing",description:"Visual regression testing — screenshot comparison, pixel diffs, responsive layouts",official:!1,source:"local"},{id:"playwright-accessibility",name:"Playwright Accessibility",description:"Accessibility testing — WCAG compliance, axe-core scans, keyboard navigation",official:!1,source:"local"},{id:"playwright-api-testing",name:"Playwright API Testing",description:"API testing with Playwright request context — REST endpoints, auth flows, contracts",official:!1,source:"local"},{id:"playwright-debug",name:"Playwright Debug",description:"Debug failing tests — trace viewer, inspector, headed mode, flaky test fixes",official:!1,source:"local"},{id:"web-artifacts-builder",name:"Web Artifacts Builder",description:"Build polished interactive web artifacts and demos",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/web-artifacts-builder"},{id:"frontend-design",name:"Frontend Design",description:"Apply frontend UI/UX design patterns and visual polish",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/frontend-design"},{id:"canvas-design",name:"Canvas Design",description:"Canvas-based graphic design and composition techniques",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/canvas-design"},{id:"algorithmic-art",name:"Algorithmic Art",description:"Create generative and algorithmic art",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/algorithmic-art"},{id:"brand-guidelines",name:"Brand Guidelines",description:"Apply brand identity and style guideline specifications",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/brand-guidelines"},{id:"theme-factory",name:"Theme Factory",description:"Generate and customize visual themes",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/theme-factory"},{id:"slack-gif-creator",name:"Slack GIF Creator",description:"Create animated GIFs suitable for Slack",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/slack-gif-creator"},{id:"doc-coauthoring",name:"Doc Coauthoring",description:"Collaborative document authoring and editing workflows",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/doc-coauthoring"},{id:"internal-comms",name:"Internal Comms",description:"Internal communications templates and drafting",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/internal-comms"},{id:"claude-api",name:"Claude API",description:"Build apps with the Claude API and Anthropic SDKs",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/claude-api"},{id:"mcp-builder",name:"MCP Builder",description:"Scaffold and build new Model Context Protocol servers",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/mcp-builder"},{id:"skill-creator",name:"Skill Creator",description:"Scaffold and create new Claude Code skills",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/skill-creator"}],z=[{id:"prettier-on-write",name:"Prettier on Write",description:"Auto-format JS/TS/JSON/MD files after edit via prettier",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.(js|jsx|ts|tsx|json|md|css|html|yaml|yml)$' | xargs -r -I{} npx --no-install prettier --write {} 2>/dev/null || true"},{id:"black-on-write",name:"Black on Write (Python)",description:"Auto-format Python files after edit via black",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.py$' | xargs -r black -q 2>/dev/null || true"},{id:"rustfmt-on-write",name:"rustfmt on Write",description:"Auto-format Rust files after edit via rustfmt",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.rs$' | xargs -r rustfmt 2>/dev/null || true"},{id:"gofmt-on-write",name:"gofmt on Write",description:"Auto-format Go files after edit via gofmt",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.go$' | xargs -r gofmt -w 2>/dev/null || true"},{id:"block-secret-writes",name:"Block Writes to Secrets",description:"Deny edits to .env, credentials, key files",event:"PreToolUse",matcher:"Write|Edit",command:`path=$(jq -r '.tool_input.file_path // empty'); echo "$path" | grep -qE '(^|/)(\\.env|\\.env\\..+|id_rsa|id_ed25519|.*\\.pem|.*\\.key|credentials\\.json|\\.aws/credentials)$' && { echo '{"decision":"block","reason":"refusing to edit secret file"}'; exit 2; } || true`},{id:"notify-on-stop",name:"Desktop Notify on Stop",description:"Send a desktop notification when Claude finishes a turn",event:"Stop",command:`command -v notify-send >/dev/null && notify-send "Claude Code" "Session ready" || (command -v osascript >/dev/null && osascript -e 'display notification "Session ready" with title "Claude Code"') || true`},{id:"bell-on-notification",name:"Terminal Bell on Notification",description:"Ring the terminal bell on permission prompts / idle notifications",event:"Notification",command:"printf '\\a'"},{id:"log-tool-calls",name:"Log Tool Calls (JSONL)",description:"Append every tool call to ~/.claude/logs/tool-calls.jsonl for audit",event:"PreToolUse",command:"mkdir -p ~/.claude/logs && cat >> ~/.claude/logs/tool-calls.jsonl"},{id:"auto-stage-edits",name:"Auto-stage Edited Files",description:"git add each file Claude edits (inside a repo)",event:"PostToolUse",matcher:"Write|Edit",command:`path=$(jq -r '.tool_input.file_path // empty'); [ -n "$path" ] && git -C "$(dirname "$path")" add "$path" 2>/dev/null || true`},{id:"block-dangerous-bash",name:"Block Dangerous Bash",description:"Refuse rm -rf /, fork bombs, curl|sh pipes",event:"PreToolUse",matcher:"Bash",command:`cmd=$(jq -r '.tool_input.command // empty'); echo "$cmd" | grep -qE '(rm -rf /|:\\(\\)\\{.*\\};|curl.*\\|\\s*(bash|sh)|wget.*\\|\\s*(bash|sh)|mkfs\\.|dd if=.*of=/dev/)' && { echo '{"decision":"block","reason":"dangerous command pattern"}'; exit 2; } || true`},{id:"prepend-cwd-to-prompt",name:"Prepend CWD to Prompt",description:"Add cwd context to every user prompt automatically",event:"UserPromptSubmit",command:'echo "{\\"additionalContext\\":\\"cwd: $(pwd)\\"}"'},{id:"archive-transcript",name:"Archive Transcript on SessionEnd",description:"Copy the session jsonl to ~/.claude/archive/ when done",event:"SessionEnd",command:`src=$(jq -r '.transcript_path // empty'); [ -n "$src" ] && mkdir -p ~/.claude/archive && cp "$src" ~/.claude/archive/ 2>/dev/null || true`}],S=(t,a,i,n)=>`---
|
|
1
|
+
import{at as e,am as J,a$ as w,aJ as p,b3 as O,a5 as Y,b9 as I,l as R,b as k,au as X,a9 as Z}from"./index-QJxszEhM.js";import{B as _}from"./Button-DvTXa_-4.js";function fe({dirty:t,busy:a,parseError:i,lastSavedAt:n,onSave:s,onRevert:r,leading:u}){const o=t&&!a&&!i;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:u}),i&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:i,children:i}),!t&&!i&&n&&e.jsx("span",{className:"text-fg-faint",children:J(n)}),t&&!i&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:r,disabled:!t||a,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:s,disabled:!o,className:`px-2.5 py-0.5 rounded border ${o?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:a?"Saving…":"Save"})]})}const K=/<[A-Za-z][A-Za-z0-9_-]*>/g,ee=/<[A-Za-z][A-Za-z0-9_-]*>/;function te(t){return t.match(K)??[]}function se(t){const a=[],i=(s,r)=>{if(typeof s=="string")for(const u of te(s))a.push({token:u,label:r})};i(t.command,"command");const n=Array.isArray(t.args)?t.args:[];n.forEach((s,r)=>{if(typeof s!="string")return;const u=n[r-1],o=r>0&&typeof u=="string"&&u.startsWith("-")&&!ee.test(u)?`${u} ${s}`:s;i(s,o)});for(const[s,r]of Object.entries(t.env??{}))i(r,`env ${s}`);return i(t.url,"url"),a}function ie(t){const a=new Map;for(const i of se(t))a.has(i.token)||a.set(i.token,i);return[...a.values()]}function ne(t,a){const i=s=>s.replace(K,r=>Object.prototype.hasOwnProperty.call(a,r)?a[r]:r),n={...t};return typeof n.command=="string"&&(n.command=i(n.command)),Array.isArray(n.args)&&(n.args=n.args.map(s=>typeof s=="string"?i(s):s)),n.env&&(n.env=Object.fromEntries(Object.entries(n.env).map(([s,r])=>[s,typeof r=="string"?i(r):r]))),typeof n.url=="string"&&(n.url=i(n.url)),n}const T=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);function ae(t){if(typeof t=="string")return t;if(T(t)){for(const a of["url","repo","path"])if(typeof t[a]=="string")return t[a]}return""}async function oe(t){const a=`${t}/.claude/plugins`,i=[];let n;try{const s=await window.api.config.readJson(`${a}/known_marketplaces.json`);if(s.parseError||s.error)return w.error(`known_marketplaces.json unreadable: ${s.parseError??s.error}`),i;if(!s.exists)return i;if(!T(s.data))return w.error("known_marketplaces.json is not an object"),i;n=s.data}catch(s){return w.error(`known_marketplaces.json unreadable: ${s instanceof Error?s.message:String(s)}`),i}for(const[s,r]of Object.entries(n)){const o=`${T(r)&&typeof r.installLocation=="string"?r.installLocation:`${a}/marketplaces/${s}`}/.claude-plugin/marketplace.json`;try{const m=await window.api.config.readJson(o);if(!m.exists){w.warn(`Marketplace ${s}: ${o} not found`);continue}if(m.parseError||m.error||!T(m.data)||!Array.isArray(m.data.plugins)){w.error(`Marketplace ${s}: invalid marketplace.json${m.parseError?` — ${m.parseError}`:""}`);continue}for(const l of m.data.plugins)!T(l)||typeof l.name!="string"||!l.name||i.push({marketplace:s,name:l.name,description:typeof l.description=="string"?l.description:"",source:ae(l.source)})}catch(m){w.error(`Marketplace ${s}: ${m instanceof Error?m.message:String(m)}`)}}return i}const q=[{id:"filesystem",name:"Filesystem",description:"Secure file operations with configurable access controls",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem",config:{command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","<path>"]},envVars:[]},{id:"fetch",name:"Fetch",description:"Web content fetching and conversion for efficient LLM usage",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/fetch",config:{command:"uvx",args:["mcp-server-fetch"]},envVars:[]},{id:"memory",name:"Memory",description:"Knowledge graph-based persistent memory system",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/memory",config:{command:"npx",args:["-y","@modelcontextprotocol/server-memory"]},envVars:[]},{id:"sequential-thinking",name:"Sequential Thinking",description:"Dynamic and reflective problem-solving through thought sequences",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",config:{command:"npx",args:["-y","@modelcontextprotocol/server-sequential-thinking"]},envVars:[]},{id:"git",name:"Git",description:"Tools to read, search, and manipulate Git repositories",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/git",config:{command:"uvx",args:["mcp-server-git","--repository","<path>"]},envVars:[]},{id:"time",name:"Time",description:"Time and timezone conversion capabilities",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/time",config:{command:"uvx",args:["mcp-server-time"]},envVars:[]},{id:"everything",name:"Everything",description:"Reference/test server with prompts, resources, and tools",official:!0,homepage:"https://github.com/modelcontextprotocol/servers/tree/main/src/everything",config:{command:"npx",args:["-y","@modelcontextprotocol/server-everything"]},envVars:[]},{id:"github",name:"GitHub",description:"Official GitHub repository, issues, and PR management",official:!1,homepage:"https://github.com/github/github-mcp-server",config:{command:"docker",args:["run","-i","--rm","-e","GITHUB_PERSONAL_ACCESS_TOKEN","ghcr.io/github/github-mcp-server"]},envVars:["GITHUB_PERSONAL_ACCESS_TOKEN"]},{id:"gitlab",name:"GitLab",description:"GitLab API integration for projects, issues, and merge requests",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/gitlab",config:{command:"npx",args:["-y","@modelcontextprotocol/server-gitlab"]},envVars:["GITLAB_PERSONAL_ACCESS_TOKEN","GITLAB_API_URL"]},{id:"postgres",name:"PostgreSQL",description:"Read-only database access with schema inspection",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/postgres",config:{command:"npx",args:["-y","@modelcontextprotocol/server-postgres","<connection-string>"]},envVars:[]},{id:"sqlite",name:"SQLite",description:"Database interaction and business intelligence over SQLite",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/sqlite",config:{command:"uvx",args:["--with","mcp<2","mcp-server-sqlite","--db-path","<path>"]},envVars:[]},{id:"slack",name:"Slack",description:"Channel management and messaging for Slack workspaces",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/slack",config:{command:"npx",args:["-y","@modelcontextprotocol/server-slack"]},envVars:["SLACK_BOT_TOKEN","SLACK_TEAM_ID"]},{id:"google-drive",name:"Google Drive",description:"File access and search for Google Drive",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/gdrive",config:{command:"npx",args:["-y","@modelcontextprotocol/server-gdrive"]},envVars:["GDRIVE_CREDENTIALS_PATH"]},{id:"google-maps",name:"Google Maps",description:"Location services, directions, and place details",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/google-maps",config:{command:"npx",args:["-y","@modelcontextprotocol/server-google-maps"]},envVars:["GOOGLE_MAPS_API_KEY"]},{id:"puppeteer",name:"Puppeteer",description:"Browser automation and web scraping via Puppeteer",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/puppeteer",config:{command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]},envVars:[]},{id:"playwright",name:"Playwright",description:"Cross-browser automation for navigation, screenshots, and data extraction",official:!1,homepage:"https://github.com/microsoft/playwright-mcp",config:{command:"npx",args:["-y","@playwright/mcp@latest"]},envVars:[]},{id:"brave-search",name:"Brave Search",description:"Web and local search using the Brave Search API",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/brave-search",config:{command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]},envVars:["BRAVE_API_KEY"]},{id:"redis",name:"Redis",description:"Interact with Redis key-value stores",official:!1,homepage:"https://github.com/modelcontextprotocol/servers-archived/tree/main/src/redis",config:{command:"npx",args:["-y","@modelcontextprotocol/server-redis","<redis-url>"]},envVars:[]},{id:"sentry",name:"Sentry",description:"Retrieve and analyze Sentry error tracking issues",official:!1,homepage:"https://github.com/getsentry/sentry-mcp",config:{command:"npx",args:["-y","@sentry/mcp-server@latest"]},envVars:["SENTRY_AUTH_TOKEN"]},{id:"linear",name:"Linear",description:"Issue tracking and project management for Linear",official:!1,homepage:"https://linear.app/docs/mcp",config:{command:"npx",args:["-y","mcp-remote","https://mcp.linear.app/sse"]},envVars:[]},{id:"notion",name:"Notion",description:"Notion workspace page and database management",official:!1,homepage:"https://github.com/makenotion/notion-mcp-server",config:{command:"npx",args:["-y","@notionhq/notion-mcp-server"]},envVars:["NOTION_API_KEY"]},{id:"stripe",name:"Stripe",description:"Payment processing, customers, and invoices via Stripe API",official:!1,homepage:"https://github.com/stripe/agent-toolkit",config:{command:"npx",args:["-y","@stripe/mcp","--tools=all"]},envVars:["STRIPE_SECRET_KEY"]},{id:"cloudflare",name:"Cloudflare",description:"Manage Cloudflare Workers, KV, R2, D1, and Workers AI",official:!1,homepage:"https://github.com/cloudflare/mcp-server-cloudflare",config:{command:"npx",args:["-y","mcp-remote","https://observability.mcp.cloudflare.com/sse"]},envVars:[]},{id:"context7",name:"Context7",description:"Up-to-date version-specific library docs injected into prompts",official:!1,homepage:"https://github.com/upstash/context7",config:{command:"npx",args:["-y","@upstash/context7-mcp@latest"]},envVars:[]},{id:"tavily",name:"Tavily",description:"AI-optimized web search with clean structured results",official:!1,homepage:"https://github.com/tavily-ai/tavily-mcp",config:{command:"npx",args:["-y","tavily-mcp@latest"]},envVars:["TAVILY_API_KEY"]},{id:"perplexity",name:"Perplexity",description:"Answer-engine search with deep research and reasoning",official:!1,homepage:"https://github.com/ppl-ai/modelcontextprotocol",config:{command:"npx",args:["-y","server-perplexity-ask"]},envVars:["PERPLEXITY_API_KEY"]},{id:"figma",name:"Figma Dev Mode",description:"First-party Figma design-to-code bridge exposing node tree",official:!1,homepage:"https://help.figma.com/hc/en-us/articles/32132100833559",config:{url:"http://127.0.0.1:3845/sse"},envVars:[]},{id:"supabase",name:"Supabase",description:"Manage Supabase projects, tables, and SQL queries",official:!1,homepage:"https://github.com/supabase-community/supabase-mcp",config:{command:"npx",args:["-y","@supabase/mcp-server-supabase@latest"]},envVars:["SUPABASE_ACCESS_TOKEN"]},{id:"atlassian",name:"Atlassian (Jira/Confluence)",description:"Official Jira and Confluence integration",official:!1,homepage:"https://www.atlassian.com/platform/remote-mcp-server",config:{command:"npx",args:["-y","mcp-remote","https://mcp.atlassian.com/v1/sse"]},envVars:[]},{id:"aws",name:"AWS",description:"AWS services access and best-practice guidance",official:!1,homepage:"https://github.com/awslabs/mcp",config:{command:"uvx",args:["awslabs.core-mcp-server@latest"]},envVars:["AWS_PROFILE","AWS_REGION"]},{id:"obsidian",name:"Obsidian",description:"Read and search notes in an Obsidian vault",official:!1,homepage:"https://github.com/MarkusPfundstein/mcp-obsidian",config:{command:"uvx",args:["mcp-obsidian"]},envVars:["OBSIDIAN_API_KEY"]}],F=[{id:"pdf",name:"PDF",description:"Create, edit, and extract content from PDF documents",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/pdf"},{id:"docx",name:"DOCX",description:"Create and edit Microsoft Word documents",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/docx"},{id:"xlsx",name:"XLSX",description:"Create and edit Excel spreadsheets with formulas and formatting",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/xlsx"},{id:"pptx",name:"PPTX",description:"Create and edit PowerPoint presentations",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/pptx"},{id:"webapp-testing",name:"Webapp Testing",description:"Test web applications using Playwright-driven browser automation",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/webapp-testing"},{id:"playwright-e2e",name:"Playwright E2E",description:"End-to-end browser tests — navigation, forms, assertions, waiting strategies",official:!1,source:"local"},{id:"playwright-visual-testing",name:"Playwright Visual Testing",description:"Visual regression testing — screenshot comparison, pixel diffs, responsive layouts",official:!1,source:"local"},{id:"playwright-accessibility",name:"Playwright Accessibility",description:"Accessibility testing — WCAG compliance, axe-core scans, keyboard navigation",official:!1,source:"local"},{id:"playwright-api-testing",name:"Playwright API Testing",description:"API testing with Playwright request context — REST endpoints, auth flows, contracts",official:!1,source:"local"},{id:"playwright-debug",name:"Playwright Debug",description:"Debug failing tests — trace viewer, inspector, headed mode, flaky test fixes",official:!1,source:"local"},{id:"web-artifacts-builder",name:"Web Artifacts Builder",description:"Build polished interactive web artifacts and demos",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/web-artifacts-builder"},{id:"frontend-design",name:"Frontend Design",description:"Apply frontend UI/UX design patterns and visual polish",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/frontend-design"},{id:"canvas-design",name:"Canvas Design",description:"Canvas-based graphic design and composition techniques",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/canvas-design"},{id:"algorithmic-art",name:"Algorithmic Art",description:"Create generative and algorithmic art",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/algorithmic-art"},{id:"brand-guidelines",name:"Brand Guidelines",description:"Apply brand identity and style guideline specifications",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/brand-guidelines"},{id:"theme-factory",name:"Theme Factory",description:"Generate and customize visual themes",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/theme-factory"},{id:"slack-gif-creator",name:"Slack GIF Creator",description:"Create animated GIFs suitable for Slack",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/slack-gif-creator"},{id:"doc-coauthoring",name:"Doc Coauthoring",description:"Collaborative document authoring and editing workflows",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/doc-coauthoring"},{id:"internal-comms",name:"Internal Comms",description:"Internal communications templates and drafting",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/internal-comms"},{id:"claude-api",name:"Claude API",description:"Build apps with the Claude API and Anthropic SDKs",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/claude-api"},{id:"mcp-builder",name:"MCP Builder",description:"Scaffold and build new Model Context Protocol servers",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/mcp-builder"},{id:"skill-creator",name:"Skill Creator",description:"Scaffold and create new Claude Code skills",official:!0,source:"https://github.com/anthropics/skills/tree/main/skills/skill-creator"}],z=[{id:"prettier-on-write",name:"Prettier on Write",description:"Auto-format JS/TS/JSON/MD files after edit via prettier",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.(js|jsx|ts|tsx|json|md|css|html|yaml|yml)$' | xargs -r -I{} npx --no-install prettier --write {} 2>/dev/null || true"},{id:"black-on-write",name:"Black on Write (Python)",description:"Auto-format Python files after edit via black",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.py$' | xargs -r black -q 2>/dev/null || true"},{id:"rustfmt-on-write",name:"rustfmt on Write",description:"Auto-format Rust files after edit via rustfmt",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.rs$' | xargs -r rustfmt 2>/dev/null || true"},{id:"gofmt-on-write",name:"gofmt on Write",description:"Auto-format Go files after edit via gofmt",event:"PostToolUse",matcher:"Write|Edit",command:"jq -r '.tool_input.file_path // empty' | grep -E '\\.go$' | xargs -r gofmt -w 2>/dev/null || true"},{id:"block-secret-writes",name:"Block Writes to Secrets",description:"Deny edits to .env, credentials, key files",event:"PreToolUse",matcher:"Write|Edit",command:`path=$(jq -r '.tool_input.file_path // empty'); echo "$path" | grep -qE '(^|/)(\\.env|\\.env\\..+|id_rsa|id_ed25519|.*\\.pem|.*\\.key|credentials\\.json|\\.aws/credentials)$' && { echo '{"decision":"block","reason":"refusing to edit secret file"}'; exit 2; } || true`},{id:"notify-on-stop",name:"Desktop Notify on Stop",description:"Send a desktop notification when Claude finishes a turn",event:"Stop",command:`command -v notify-send >/dev/null && notify-send "Claude Code" "Session ready" || (command -v osascript >/dev/null && osascript -e 'display notification "Session ready" with title "Claude Code"') || true`},{id:"bell-on-notification",name:"Terminal Bell on Notification",description:"Ring the terminal bell on permission prompts / idle notifications",event:"Notification",command:"printf '\\a'"},{id:"log-tool-calls",name:"Log Tool Calls (JSONL)",description:"Append every tool call to ~/.claude/logs/tool-calls.jsonl for audit",event:"PreToolUse",command:"mkdir -p ~/.claude/logs && cat >> ~/.claude/logs/tool-calls.jsonl"},{id:"auto-stage-edits",name:"Auto-stage Edited Files",description:"git add each file Claude edits (inside a repo)",event:"PostToolUse",matcher:"Write|Edit",command:`path=$(jq -r '.tool_input.file_path // empty'); [ -n "$path" ] && git -C "$(dirname "$path")" add "$path" 2>/dev/null || true`},{id:"block-dangerous-bash",name:"Block Dangerous Bash",description:"Refuse rm -rf /, fork bombs, curl|sh pipes",event:"PreToolUse",matcher:"Bash",command:`cmd=$(jq -r '.tool_input.command // empty'); echo "$cmd" | grep -qE '(rm -rf /|:\\(\\)\\{.*\\};|curl.*\\|\\s*(bash|sh)|wget.*\\|\\s*(bash|sh)|mkfs\\.|dd if=.*of=/dev/)' && { echo '{"decision":"block","reason":"dangerous command pattern"}'; exit 2; } || true`},{id:"prepend-cwd-to-prompt",name:"Prepend CWD to Prompt",description:"Add cwd context to every user prompt automatically",event:"UserPromptSubmit",command:'echo "{\\"additionalContext\\":\\"cwd: $(pwd)\\"}"'},{id:"archive-transcript",name:"Archive Transcript on SessionEnd",description:"Copy the session jsonl to ~/.claude/archive/ when done",event:"SessionEnd",command:`src=$(jq -r '.transcript_path // empty'); [ -n "$src" ] && mkdir -p ~/.claude/archive && cp "$src" ~/.claude/archive/ 2>/dev/null || true`}],S=(t,a,i,n)=>`---
|
|
2
2
|
name: ${t}
|
|
3
3
|
description: ${a}
|
|
4
4
|
tools: ${i}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{at as e}from"./index-
|
|
1
|
+
import{at as e}from"./index-QJxszEhM.js";function o({sidebar:r,detail:s,sidebarWidth:i="18rem"}){return e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"shrink-0 border-r border-line overflow-y-auto",style:{width:i},children:r}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:s})]})}export{o as L};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aJ as i,a$ as E,at as e,a5 as K,ag as vt,aN as kt,af as Nt,L as wt,b9 as jt,b0 as Ct,l as St}from"./index-
|
|
1
|
+
import{aJ as i,a$ as E,at as e,a5 as K,ag as vt,aN as kt,af as Nt,L as wt,b9 as jt,b0 as Ct,l as St}from"./index-QJxszEhM.js";import{V as $t}from"./VoiceButton-5ETBv9eI.js";import"./monaco-editor-BsIlgG7c.js";function Mt(s){return!s||!s.trim()?"default":s.replace(/[^a-zA-Z0-9]/g,"-")}const De=["bg-accent","bg-sage-dark","bg-honey","bg-fg-dim","bg-fg-faint","bg-hive-teal","bg-butter","bg-delta-bad"],Ge=864e5,Et="MEMORY.md",Ie=2e3,we=s=>s.replace(/\.md$/,"");function At(s,t,n,l){var v,k,f;const x=new Map(((t==null?void 0:t.entries)??[]).map(o=>[o.name,o])),a=new Set(((v=t==null?void 0:t.index)==null?void 0:v.orphans)??[]),p=new Map;for(const o of(n==null?void 0:n.clusters)??[])for(const b of o.memberSlugs)p.has(b)||p.set(b,o.id);const m=s.filter(o=>o.name!==Et),c=new Map;for(const o of m){const b=we(o.name),u=((k=x.get(o.name))==null?void 0:k.outLinks)??((f=x.get(b))==null?void 0:f.outLinks)??[];for(const j of u){const M=we(j),y=c.get(M)??[];y.includes(b)||y.push(b),c.set(M,y)}}return m.map(o=>{const b=we(o.name),u=x.get(o.name)??x.get(b),j=(u==null?void 0:u.deadRefs)??[],M=(u==null?void 0:u.danglingLinks)??[],y=(u==null?void 0:u.stale)??!1;return{name:o.name,slug:b,path:o.path,description:(u==null?void 0:u.description)??"",bytes:o.bytes,mtimeMs:o.mtimeMs,ageDays:Math.floor((l-o.mtimeMs)/Ge),stale:y,staleReasons:(u==null?void 0:u.reasons)??[],ageOnlyStale:y&&j.length===0,deadRefs:j,broken:j.length>0||M.length>0,danglingLinks:M,outLinks:(u==null?void 0:u.outLinks)??[],inLinks:c.get(b)??[],notIndexed:a.has(o.name)||a.has(b),clusterId:p.get(b)??null,type:(u==null?void 0:u.type)??null,originSessionId:(u==null?void 0:u.originSessionId)??null}})}function Lt(s,t){const n=new Set(t.filter(l=>l.stale).map(l=>l.slug));return((s==null?void 0:s.clusters)??[]).map((l,x)=>({id:l.id,name:l.name,summary:l.summary,memberSlugs:l.memberSlugs,linkCount:l.links.length,retireCount:l.links.filter(a=>/retire/i.test(a.label??"")).length,staleCount:l.memberSlugs.filter(a=>n.has(a)).length,dotClass:De[x%De.length]}))}function Ye(s,t,n){const l=t.trim().toLowerCase(),x=l?s.filter(a=>a.slug.toLowerCase().includes(l)||a.description.toLowerCase().includes(l)):s;return n===void 0?x:x.slice(0,n)}function de(s,t,n){let l;return t==="ask"||t==="clusters"||t==="archived"?[]:(t==="all"?l=s:t==="stale"?l=s.filter(x=>x.stale):t==="broken"?l=s.filter(x=>x.broken):t==="recent"?l=s.filter(x=>Date.now()-x.mtimeMs<=7*Ge):t==="unindexed"?l=s.filter(x=>x.notIndexed):t==="cluster:unclustered"?l=s.filter(x=>x.clusterId===null):t.startsWith("cluster:")?l=s.filter(x=>x.clusterId===t.slice(8)):l=s,Ye(l,n))}function qe(s,t){const n=[...s];return t==="recent"?n.sort((l,x)=>x.mtimeMs-l.mtimeMs):t==="name"?n.sort((l,x)=>l.slug<x.slug?-1:l.slug>x.slug?1:0):n.sort((l,x)=>x.bytes-l.bytes),n}function Rt(s){return{all:s.length,stale:de(s,"stale","").length,broken:de(s,"broken","").length,recent:de(s,"recent","").length,unindexed:de(s,"unindexed","").length}}function Xe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"untitled_memory"}function Dt(s,t){const n=s===""?[]:s.split(`
|
|
2
2
|
`),l=t===""?[]:t.split(`
|
|
3
3
|
`);if(n.length>Ie||l.length>Ie)return[...n.map(k=>({sign:"−",text:k})),...l.map(k=>({sign:"+",text:k}))];const x=n.length,a=l.length,p=Array.from({length:x+1},()=>new Array(a+1).fill(0));for(let k=x-1;k>=0;k--)for(let f=a-1;f>=0;f--)p[k][f]=n[k]===l[f]?p[k+1][f+1]+1:Math.max(p[k+1][f],p[k][f+1]);const m=[];let c=0,v=0;for(;c<x&&v<a;)n[c]===l[v]?(c++,v++):p[c+1][v]>=p[c][v+1]?m.push({sign:"−",text:n[c++]}):m.push({sign:"+",text:l[v++]});for(;c<x;)m.push({sign:"−",text:n[c++]});for(;v<a;)m.push({sign:"+",text:l[v++]});return m}const F=s=>s instanceof Error?s.message:String(s);function Te(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return t?{front:t[0],body:s.slice(t[0].length)}:{front:"",body:s}}function It(s){return s.split(`
|
|
4
4
|
`).map(t=>t.trim()).find(t=>t.length>0)??""}function Tt(s,t){const n=s.kind==="agent"?s.agent:null,l=n?`${n.name}|${n.memoryScope??""}`:"",x=n!==null&&n.memoryScope===null,a=i.useMemo(()=>x?null:n&&n.memoryScope?{agent:{name:n.name,scope:n.memoryScope},...t?{cwd:t}:{}}:{workspace:Mt(t),...t?{cwd:t}:{}},[l,x,t]),p=n===null,[m,c]=i.useState(!0),[v,k]=i.useState([]),[f,o]=i.useState(null),[b,u]=i.useState(null),[j,M]=i.useState(!1),[y,C]=i.useState(""),[I,W]=i.useState(!0),[ee,xe]=i.useState([]),[q,A]=i.useState([]),[U,L]=i.useState({}),[me,ye]=i.useState(()=>Date.now()),X=i.useRef(a);X.current=a;const T=i.useCallback(async()=>{if(!a){k([]),o(null),u(null),xe([]),C(""),c(!1);return}try{const h=await window.api.memory.list(a);if(X.current!==a)return;k(h.entries??[]),C(h.dir??""),W(h.autoMemoryEnabled!==!1),h.error&&E.error(`Memory list failed: ${h.error}`);const[d,N]=await Promise.all([window.api.memory.stale(a).catch(w=>(E.error(`Memory staleness check failed: ${F(w)}`),null)),window.api.memory.listArchived(a).catch(()=>({names:[],error:null}))]);if(X.current!==a)return;o(d),xe(N.names??[]),ye(Date.now())}catch(h){E.error(`Memory list failed: ${F(h)}`)}finally{c(!1)}},[a]);i.useEffect(()=>{c(!0),u(null),T(),a&&p&&a.workspace&&window.api.memory.aggregate(a.workspace,!1,t??void 0).then(h=>{X.current===a&&u(h)}).catch(h=>E.error(`Memory clusters failed: ${F(h)}`))},[T]),i.useEffect(()=>{let h=!1;return(async()=>{try{const{agents:d}=await window.api.memory.agents(t??void 0);if(h)return;A(d);const N={};await Promise.all(d.filter(w=>w.memoryScope).map(async w=>{const G=await window.api.memory.list({agent:{name:w.name,scope:w.memoryScope},...t?{cwd:t}:{}});N[w.name]=(G.entries??[]).filter(O=>O.name!=="MEMORY.md").length})),h||L(N)}catch(d){h||E.error(`Memory agents failed: ${F(d)}`)}})(),()=>{h=!0}},[t]),i.useEffect(()=>{if(!y)return;const h=y;window.api.config.watch([h]);const d=window.api.config.onChanged(({path:N})=>{(N===h||N.startsWith(h+"/"))&&T()});return()=>{d(),window.api.config.unwatch([h])}},[y,T]);const _=i.useMemo(()=>At(v,f,b,me),[v,f,b,me]),te=i.useMemo(()=>Lt(b,_),[b,_]),ve=i.useMemo(()=>({generatedAt:(b==null?void 0:b.generatedAt)??null,running:j}),[b,j]),R=i.useCallback(async h=>{if(!a)return null;try{const d=await window.api.memory.read(h,a);return d.error?(E.error(`Memory read failed: ${d.error}`),null):d.content}catch(d){return E.error(`Memory read failed: ${F(d)}`),null}},[a]),$=i.useCallback(async(h,d)=>{try{const N=await d();return N.ok?(await T(),!0):(E.error(`${h} failed: ${N.error??"unknown error"}`),!1)}catch(N){return E.error(`${h} failed: ${F(N)}`),!1}},[T]),Q=i.useCallback(async(h,d)=>{if(!a)return!1;const N=await R(h);if(N===null)return!1;const{front:w}=Te(N);return $("Memory save",()=>window.api.memory.write(h,w+d,a))},[a,R,$]),V=i.useCallback(async(h,d)=>{if(!a)return null;const N=Xe(h),w=It(d);if(!await $("Memory create",()=>window.api.memory.create(N,w,a)))return null;const O=`---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{at as e}from"./index-
|
|
1
|
+
import{at as e}from"./index-QJxszEhM.js";function n({toolbar:s,footer:l,children:r}){return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:s}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:r}),l&&e.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:l})]})}export{n as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aa as P,b9 as M,aJ as x,at as s,a5 as R,B as G,b as T}from"./index-
|
|
1
|
+
import{aa as P,b9 as M,aJ as x,at as s,a5 as R,B as G,b as T}from"./index-QJxszEhM.js";import{a as E,C as _,c as j,b as B}from"./Library-LftcMs6C.js";const N=e=>`${e}/.claude/session-manager/provenance.json`;function I(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const D=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const a=await window.api.config.readJson(N(n)),d=a.exists?I(a.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const a={...t().overrides};o===null?delete a[n]:a[n]=o,e({overrides:a});const d=t().home;if(d)try{await window.api.config.writeJson(N(d),a)}catch{}}})),i=e=>(e??"").toLowerCase().trim(),$=new Set,L=new Set;for(const e of B){const t=e.official?$:L;t.add(i(e.id)),t.add(i(e.name))}const K=new Set(j.filter(e=>e.official).flatMap(e=>[i(e.id),i(e.name)])),H=new Set(j.filter(e=>!e.official).flatMap(e=>[i(e.id),i(e.name)])),J=new Set(_.flatMap(e=>[i(e.id),i(e.name)])),V=new Set(E.flatMap(e=>[i(e.id),i(e.name)])),z=new Set(E.map(e=>e.command.trim())),U=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Z=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,q=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function F(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),C=e=>({provenance:"community",reason:e});function Q(e,t,n){switch(e){case"mcp":return $.has(t)?l("official MCP server (catalog)"):L.has(t)?C("third-party server (catalog)"):null;case"skill":case"command":return K.has(t)?l("official Anthropic skill (catalog)"):H.has(t)?C("third-party skill (catalog)"):null;case"plugin":return null;case"subagent":return J.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return V.has(t)||n&&z.has(n.trim())?l("bundled hook (catalog)"):null}}function W(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":q.test(t)?"installed from a package registry":null}function X(e){const t=i(e.name),n=F(e),o=Q(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&U.has(t))return l("built-in Claude Code command");if(Z.test(n))return l("Anthropic package or repo");const a=W(e,n);return a?C(a):{provenance:"local",reason:"no external source — assumed self-created"}}function Y(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},O={anthropic:"accent",community:"warn",local:"dim"},ee=["anthropic","community","local"];function oe({input:e,scope:t,interactive:n=!0,className:o=""}){const a=M(),{overrides:d,load:h,setOverride:k}=D(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{a&&h(a)},[a,h]),x.useEffect(()=>{if(!b)return;const r=w=>{v.current&&!v.current.contains(w.target)&&m(!1)},g=w=>{w.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",r),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",g)}},[b]);const y=Y(e.type,t??null,e.name),u=X(e),p=d[y],f=p??u.provenance,S=p?`Origin manually set to ${c[f]} — auto-detected ${c[u.provenance]} (${u.reason})`:`Auto-detected ${c[f]}: ${u.reason}`,A=s.jsxs(T,{tone:O[f],title:S,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[f],p&&s.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?s.jsxs("span",{ref:v,className:"relative inline-flex",children:[s.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[f]}. Click to change.`,children:A}),b&&s.jsxs("span",{className:`absolute ${R.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:r=>r.stopPropagation(),children:[s.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),ee.map(r=>s.jsxs("button",{type:"button",onClick:()=>{k(y,r),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${f===r?"text-fg":"text-fg-dim"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full border ${G[O[r]]}`,"aria-hidden":!0}),c[r],p===r&&s.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},r)),s.jsx("div",{className:"my-1 border-t border-line"}),s.jsxs("button",{type:"button",onClick:()=>{k(y,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[u.provenance]})`,children:["Auto-detect",s.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[u.provenance]})]})]})]}):A}export{oe as P};
|