claude-code-session-manager 0.133.1 → 0.134.0

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.
Files changed (90) hide show
  1. package/dist/assets/AgentLibrary-C9KFGJQq.js +2 -0
  2. package/dist/assets/{AppSettings-DwnfV9-4.js → AppSettings-CvVQ6ot5.js} +2 -2
  3. package/dist/assets/{Button-CObXxw7b.js → Button-BHvploNk.js} +1 -1
  4. package/dist/assets/{DocumentEditorPane-CgB5IuOY.js → DocumentEditorPane-DaX4xag_.js} +1 -1
  5. package/dist/assets/{Extensions-Fuhshcl6.js → Extensions-DbRY-KEz.js} +2 -2
  6. package/dist/assets/{History-DbUV4jxK.js → History-BE_mjM24.js} +2 -2
  7. package/dist/assets/{Library-COr79GyT.js → Library-I37dQ6pB.js} +1 -1
  8. package/dist/assets/{ListDetail-DY53nXya.js → ListDetail-DJYMWYQd.js} +1 -1
  9. package/dist/assets/{Panel-D7NX5iP8.js → Panel-DP8eSKSs.js} +1 -1
  10. package/dist/assets/{ProjectClaudeConfig-DuWzM8qA.js → ProjectClaudeConfig-Cw8lc3Qi.js} +5 -5
  11. package/dist/assets/{ProvenanceBadge-AnwE1p5X.js → ProvenanceBadge-DUwhsmdA.js} +1 -1
  12. package/dist/assets/Scheduler-B9D2gZqs.js +16 -0
  13. package/dist/assets/{Settings-tt0VZCyz.js → Settings-DSk7bn-1.js} +2 -2
  14. package/dist/assets/{SkillReferenceGraph-D_rxqWgq.js → SkillReferenceGraph-DtJcJJHR.js} +1 -1
  15. package/dist/assets/{Skills-BVQPJZaF.js → Skills-BPZnSjsB.js} +10 -10
  16. package/dist/assets/{SourceChip-DC5XD8KC.js → SourceChip-DUxulNOp.js} +1 -1
  17. package/dist/assets/{SystemPrompt-XnvP0_cS.js → SystemPrompt-BXAugVle.js} +1 -1
  18. package/dist/assets/{TiptapBody-B_TNEADm.js → TiptapBody-CDC1vrOo.js} +28 -28
  19. package/dist/assets/{Toggle-CxQO8pGN.js → Toggle-CrgM7OTR.js} +1 -1
  20. package/dist/assets/{ViewTabs-CEjnWPD9.js → ViewTabs-DLwaU9RB.js} +1 -1
  21. package/dist/assets/{VoiceButton-B-6gdmKe.js → VoiceButton-C4hIBxIP.js} +1 -1
  22. package/dist/assets/geist-sans-latin-300-normal-C3kkMBb6.woff2 +0 -0
  23. package/dist/assets/geist-sans-latin-400-normal-gapTbOY8.woff2 +0 -0
  24. package/dist/assets/geist-sans-latin-500-normal-uokXdC-Q.woff2 +0 -0
  25. package/dist/assets/geist-sans-latin-600-normal-DFOURf8L.woff2 +0 -0
  26. package/dist/assets/geist-sans-latin-700-normal-BmN9tIp5.woff2 +0 -0
  27. package/dist/assets/{historyTotals-dT8vcKzX.js → historyTotals-itA00dXm.js} +1 -1
  28. package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  29. package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  30. package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  31. package/dist/assets/{index-5QIl5Kcd.css → index-Cjt8B7H9.css} +1 -1
  32. package/dist/assets/index-Cznhnxhq.js +3116 -0
  33. package/dist/assets/newsreader-latin-400-italic-CEihAR-f.woff2 +0 -0
  34. package/dist/assets/newsreader-latin-400-normal-BFBkh4jY.woff2 +0 -0
  35. package/dist/assets/newsreader-latin-500-normal-B66TYsaK.woff2 +0 -0
  36. package/dist/assets/newsreader-latin-600-normal-30OJ_TG_.woff2 +0 -0
  37. package/dist/assets/newsreader-latin-700-normal-rIgV_oaK.woff2 +0 -0
  38. package/dist/index.html +2 -5
  39. package/dist-web/app.css +1 -1
  40. package/dist-web/app.js +407 -402
  41. package/dist-web/index.html +0 -3
  42. package/package.json +1 -1
  43. package/scripts/scheduler-mcp-server.cjs +31 -0
  44. package/src/main/agentLibrary.cjs +27 -4
  45. package/src/main/build-info.json +4 -4
  46. package/src/main/chatRunner.cjs +9 -0
  47. package/src/main/config.cjs +22 -0
  48. package/src/main/crashDiagnostics.cjs +10 -2
  49. package/src/main/index.cjs +34 -25
  50. package/src/main/ipcSchemas.cjs +6 -0
  51. package/src/main/lib/agent-cli/agentCliEvents.cjs +8 -0
  52. package/src/main/lib/demo-video-kit/capture.cjs +4 -37
  53. package/src/main/lib/demo-video-kit/character.cjs +20 -2
  54. package/src/main/lib/demo-video-kit/checks.cjs +82 -1
  55. package/src/main/lib/demo-video-kit/frames.cjs +3 -28
  56. package/src/main/lib/demo-video-kit/playwrightLoader.cjs +67 -0
  57. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  58. package/src/main/lib/demo-video-kit/sound.cjs +5 -2
  59. package/src/main/lib/epic/epicMint.cjs +1 -3
  60. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +37 -4
  61. package/src/main/lib/epic/restorableSessions.cjs +88 -0
  62. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +56 -1
  63. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +21 -3
  64. package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
  65. package/src/main/lib/mcpToolCatalog.cjs +15 -0
  66. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +10 -1
  67. package/src/main/lib/persona-macro/builtinMacros.cjs +3 -2
  68. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  69. package/src/main/lib/prd/listPrdsSingleFlight.cjs +79 -0
  70. package/src/main/lib/prd/prdAgentType.cjs +17 -7
  71. package/src/main/lib/telemetry/crashTelemetry.cjs +10 -5
  72. package/src/main/lib/telemetry/telemetryBoot.cjs +77 -4
  73. package/src/main/lib/telemetry/telemetryClient.cjs +54 -9
  74. package/src/main/lib/telemetry/telemetryConsent.cjs +3 -0
  75. package/src/main/lib/telemetry/telemetryCounters.cjs +7 -2
  76. package/src/main/lib/telemetry/telemetrySettings.cjs +5 -0
  77. package/src/main/pty.cjs +2 -2
  78. package/src/main/scheduler/prdParser.cjs +1 -1
  79. package/src/main/scheduler.cjs +19 -3
  80. package/src/main/seedAgentPersonas.cjs +24 -0
  81. package/src/main/seedStatus.cjs +5 -2
  82. package/src/main/telemetryIpc.cjs +1 -5
  83. package/src/preload/api.d.ts +29 -14
  84. package/src/preload/apiSurface.json +7 -0
  85. package/src/preload/index.cjs +3 -1
  86. package/src/seed/agents/demo-video-builder.md +7 -2
  87. package/dist/assets/AgentLibrary-BTIBmZkM.js +0 -2
  88. package/dist/assets/Scheduler-BHfx0rXd.js +0 -16
  89. package/dist/assets/index-BLORXCcT.js +0 -3111
  90. package/src/main/lib/telemetry/telemetryBacklog.cjs +0 -607
@@ -1,4 +1,4 @@
1
- import{aN as f,ax as s,a6 as Bt,ac as Kt,b5 as q,ai as Wt,b as Ht,ab as Ut,ay as jt,bf as yt,b6 as wt,b9 as T,l as ne,bs as Jt,F as Yt,P as Vt,ae as zt,aR as qt,aU as Gt,ba as Nt}from"./index-BLORXCcT.js";import{P as Te}from"./Panel-D7NX5iP8.js";import{L as St}from"./ListDetail-DY53nXya.js";import{f as rt,S as $t,m as Qt}from"./Library-COr79GyT.js";import{a as Qe,u as lt,p as Zt,c as Xt,P as es}from"./ProvenanceBadge-AnwE1p5X.js";import{T as ts}from"./Toggle-CxQO8pGN.js";function Ct({filter:e,onFilterChange:t,placeholder:n,summary:a,children:l,primary:r}){const[i,o]=f.useState(!1),h=f.useRef(null),m=f.useRef(null),g=f.useId();return f.useEffect(()=>{if(!i)return;const u=v=>{var b,w;const p=v.target;(b=h.current)!=null&&b.contains(p)||(w=m.current)!=null&&w.contains(p)||o(!1)},x=v=>{v.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",u),window.addEventListener("keydown",x),()=>{window.removeEventListener("mousedown",u),window.removeEventListener("keydown",x)}},[i]),s.jsxs("div",{"data-testid":"extensions-toolbar",className:"relative shrink-0 h-11 flex items-center gap-3 px-3 bg-bg-elev border-b border-line text-xs",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsxs("svg",{"aria-hidden":"true",className:"pointer-events-none absolute left-[9px] top-1/2 -translate-y-1/2 text-fg-faint/80",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),s.jsx("input",{type:"text","data-testid":"extensions-toolbar-filter",value:e,onChange:u=>t(u.target.value),placeholder:n,"aria-label":n,spellCheck:!1,className:"w-[276px] h-7 pl-[29px] pr-[9px] bg-bg-hi border border-line rounded-md text-xs text-fg placeholder:text-fg-faint/80 focus:outline-none focus:border-fg-faint"})]}),s.jsx("span",{"data-testid":"extensions-toolbar-summary",className:"min-w-0 truncate text-fg-faint",children:a}),l,s.jsxs("button",{ref:h,type:"button","data-testid":r.testId,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?g:void 0,onClick:()=>o(u=>!u),className:"ml-auto shrink-0 h-7 inline-flex items-center gap-1.5 pl-3 pr-2.5 rounded-md bg-accent text-bg-hi text-[12.5px] font-semibold shadow-sm hover:bg-accent/90",children:[r.label,s.jsx("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m6 9 6 6 6-6"})})]}),i&&s.jsx("div",{ref:m,id:g,role:"menu","aria-label":r.label,"data-testid":`${r.testId}-menu`,className:`absolute ${Bt.dialog} right-3 top-[42px] min-w-[210px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[12.5px] text-fg`,children:r.items.map(u=>s.jsx("button",{type:"button",role:"menuitem","data-testid":u.testId,onClick:()=>{o(!1),u.onSelect()},className:"px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev",children:u.label},u.testId))})]})}const ss=2;function be(e){return`${e.source}:${e.pluginKey??e.cwd??""}:${e.name}`}const He=new Map,ns=e=>e instanceof Error?e.message:String(e);async function as(e){try{return await window.api.mcp.checkServer(e)}catch(t){const n=ns(t);return q.error(`MCP check of ${e.name} failed: ${n}`),{ok:!1,status:"failed",error:n,checkedAt:Date.now()}}}const ve=Kt((e,t)=>({results:{},checking:{},check:n=>{const a=be(n),l=He.get(a);if(l)return l;e(i=>({checking:{...i.checking,[a]:!0}}));const r=as(n).then(i=>(He.delete(a),e(o=>{const h={...o.checking};return delete h[a],{results:{...o.results,[a]:i},checking:h}}),i));return He.set(a,r),r},checkAll:async n=>{const a=[...new Map(n.map(i=>[be(i),i])).values()];let l=0;const r=async()=>{for(;l<a.length;)await t().check(a[l++])};await Promise.all(Array.from({length:Math.min(ss,a.length)},r))}})),rs=e=>e.results,ls=e=>e.checking,qe={unchecked:"Not checked",connected:"Connected",failed:"Failed","needs-auth":"Needs auth"},Et={unchecked:"border-[1.5px] border-fg-faint/60",connected:"bg-sage",failed:"bg-red-500","needs-auth":"bg-honey"},is={unchecked:"bg-bg-elev text-fg-dim",connected:"bg-sage/15 text-sage-dark",failed:"bg-red-500/10 text-red-700","needs-auth":"bg-honey/15 text-honey-dark"},os={user:"User scope",project:"Project scope",local:"Local scope"},cs=3e4,ds="••••••••",us=/^[A-Za-z0-9_@%+=:,./-]+$/;function ms(e){return us.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Ze(e){return(e.type??"stdio")!=="stdio"}function ps(e){return Ze(e)?e.url??"":e.command?[e.command,...e.args??[]].map(ms).join(" "):""}const it=e=>e.replace(/[^A-Za-z0-9_-]/g,"_");function fs(e,t){return`mcp__${it(e)}__${it(t)}`}const Ue="h-7 inline-flex items-center whitespace-nowrap px-[11px] bg-bg-hi border border-line rounded-md text-[12.5px] text-fg hover:border-rule disabled:opacity-50 disabled:hover:border-line",Xe="text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",Je="px-3 py-2.5 border border-dashed border-rule rounded-md text-[12.5px] text-fg-faint";function ot({name:e,server:t,scope:n,fileLabel:a,plugin:l,checkRequest:r,provenance:i,onChange:o,editing:h=!1,onEditingChange:m,editor:g}){const u=l!==void 0,x=!u&&h,v=r?be(r):null,p=ve(P=>v===null?void 0:P.results[v]),b=ve(P=>v===null?!1:P.checking[v]===!0),w=ve(P=>P.check);xs(cs,p!==void 0);const C=(p==null?void 0:p.status)??"unchecked",A=Date.now(),J=Ze(t);return s.jsxs("div",{"data-testid":"mcp-detail",className:"flex flex-col gap-[18px] px-6 py-[18px]",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[s.jsx("h2",{"data-testid":"mcp-detail-name",className:"min-w-0 truncate text-[22px] leading-tight font-semibold tracking-[-.01em] text-fg",children:e}),s.jsxs("span",{"data-testid":"mcp-detail-status","data-status":C,title:p&&!p.ok?p.error:void 0,className:`shrink-0 inline-flex items-center gap-1.5 h-[22px] px-[9px] rounded-full text-xs font-semibold ${is[C]}`,children:[s.jsx("span",{"aria-hidden":"true",className:`w-1.5 h-1.5 shrink-0 box-border rounded-full ${Et[C]}${b?" animate-pulse":""}`}),qe[C]]}),b?s.jsx("span",{"data-testid":"mcp-detail-checked",className:"shrink-0 text-xs text-fg-faint",children:"checking…"}):p?s.jsxs("span",{"data-testid":"mcp-detail-checked",title:new Date(p.checkedAt).toLocaleString(),className:"shrink-0 text-xs text-fg-faint",children:["checked ",Wt(Math.min(p.checkedAt,A),A)]}):null]}),s.jsxs("div",{"data-testid":"mcp-detail-meta",className:"flex flex-wrap items-center gap-2 text-xs text-fg-faint",children:[s.jsx(Qe,{scope:n,input:i,interactive:!1}),s.jsx("span",{"data-testid":"mcp-detail-transport",className:"inline-flex",children:s.jsx(Ht,{tone:"dim",children:u?"plugin":t.type??"stdio"})}),u?s.jsxs(s.Fragment,{children:[s.jsxs("span",{"data-testid":"mcp-detail-plugin",children:["via the ",l," plugin"]}),s.jsx("span",{"aria-hidden":"true",className:"text-fg-faint/60",children:"·"}),s.jsx("span",{"data-testid":"mcp-detail-readonly",children:"read-only"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-testid":"mcp-detail-scope",children:os[n]}),s.jsx("span",{"aria-hidden":"true",className:"text-fg-faint/60",children:"·"}),s.jsxs("span",{"data-testid":"mcp-detail-keypath",className:"min-w-0 font-mono text-[11.5px] text-fg-dim break-words",children:[a," › mcpServers › ",e]})]})]})]}),s.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-2",children:[s.jsx("button",{type:"button","data-testid":"mcp-check-again",onClick:()=>{r&&w(r)},disabled:r===null||b,className:Ue,children:b?"Checking…":"Check again"}),u?null:x?s.jsx("button",{type:"button","data-testid":"mcp-edit-done",onClick:()=>m==null?void 0:m(!1),className:Ue,children:"Done"}):s.jsx("button",{type:"button","data-testid":"mcp-edit-json",onClick:()=>m==null?void 0:m(!0),className:Ue,children:"Edit JSON"})]})]}),x?g:s.jsxs(s.Fragment,{children:[s.jsx(hs,{server:t,readOnly:u}),u?null:J?s.jsx(ct,{testId:"mcp-headers",label:"Headers",noun:"header",separator:":",emptyText:"No headers set",values:t.headers??{},onAdd:(P,B)=>o==null?void 0:o({...t,headers:{...t.headers??{},[P]:B}})}):s.jsx(ct,{testId:"mcp-env",label:"Environment",noun:"variable",separator:"=",emptyText:"No variables set",values:t.env??{},onAdd:(P,B)=>o==null?void 0:o({...t,env:{...t.env??{},[P]:B}})}),s.jsx(gs,{serverName:e,result:p})]})]})}function xs(e,t){const[,n]=f.useState(0);f.useEffect(()=>{if(!t)return;const a=window.setInterval(()=>n(l=>l+1),e);return()=>window.clearInterval(a)},[e,t])}function hs({server:e,readOnly:t}){const n=Ze(e),a=ps(e),l=async()=>{await Ut(a)?q.success(n?"URL copied":"Command copied"):q.error(n?"Copy failed — the URL was not copied":"Copy failed — the command was not copied")};return s.jsxs("section",{className:"flex flex-col gap-[7px]",children:[s.jsx("h3",{className:Xe,children:"Command"}),s.jsxs("div",{"data-testid":"mcp-command-box",className:"flex items-center gap-2.5 px-3 py-2.5 bg-bg-hi border border-line rounded-md font-mono text-[13px] text-fg",children:[n?null:s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-faint/60",children:"$"}),a?s.jsx("span",{"data-testid":"mcp-command",className:"min-w-0 break-words",children:a}):s.jsx("span",{"data-testid":"mcp-command-empty",className:"min-w-0 font-sans text-[12.5px] text-fg-faint",children:t?n?"No URL set.":"No command set.":n?"No URL set — Edit JSON to add one.":"No command set — Edit JSON to add one."}),s.jsx("button",{type:"button","data-testid":"mcp-command-copy",onClick:()=>void l(),disabled:!a,className:"ml-auto shrink-0 font-sans text-xs text-fg-faint hover:text-fg disabled:opacity-50 disabled:hover:text-fg-faint",children:"Copy"})]})]})}function ct({testId:e,label:t,noun:n,separator:a,emptyText:l,values:r,onAdd:i}){const[o,h]=f.useState(()=>new Set),[m,g]=f.useState(!1),[u,x]=f.useState(""),v=f.useRef(null),p=Object.keys(r),b=u.trim(),w=b!==""&&!/\s/.test(b)&&!b.includes(a),C=N=>h(L=>{const G=new Set(L);return G.has(N)?G.delete(N):G.add(N),G}),A=()=>{g(!1),x("")},J=()=>{var N;w&&(i(b,((N=v.current)==null?void 0:N.value)??""),A())},P=N=>{N.key==="Enter"?(N.preventDefault(),J()):N.key==="Escape"&&(N.preventDefault(),A())},B=s.jsxs("button",{type:"button","data-testid":`${e}-add`,onClick:()=>g(!0),className:"shrink-0 text-[12.5px] font-semibold text-accent hover:text-accent-dark",children:["+ Add ",n]});return s.jsxs("section",{"data-testid":e,className:"flex flex-col gap-[7px]",children:[s.jsx("h3",{className:Xe,children:t}),p.length===0&&!m?s.jsxs("div",{"data-testid":`${e}-empty`,className:"flex items-center gap-2.5 px-3 py-2.5 border border-dashed border-rule rounded-md text-[12.5px] text-fg-faint",children:[l,s.jsx("span",{className:"ml-auto",children:B})]}):null,p.length>0?s.jsx("div",{className:"bg-bg-hi border border-line rounded-md divide-y divide-line",children:p.map(N=>{const L=o.has(N);return s.jsxs("div",{"data-testid":`${e}-row-${N}`,className:"flex items-center gap-2.5 px-3 py-2 font-mono text-[12.5px]",children:[s.jsx("span",{className:"shrink-0 font-semibold text-fg",children:N}),s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-faint/60",children:a}),s.jsx("span",{"data-testid":`${e}-value-${N}`,title:L?void 0:"Hidden — Show reveals it",className:`min-w-0 break-words ${L?"text-fg-dim":"text-fg-faint tracking-wider"}`,children:L?r[N]:ds}),s.jsx("button",{type:"button","data-testid":`${e}-reveal-${N}`,"aria-pressed":L,"aria-label":`${L?"Hide":"Show"} the value of ${N}`,onClick:()=>C(N),className:"ml-auto shrink-0 font-sans text-xs text-fg-faint hover:text-fg",children:L?"Hide":"Show"})]},N)})}):null,m?s.jsxs("div",{"data-testid":`${e}-add-form`,className:"flex items-center gap-2 px-3 py-2 bg-bg-hi border border-line rounded-md",children:[s.jsx("input",{"data-testid":`${e}-new-key`,"aria-label":`New ${n} name`,value:u,onChange:N=>x(N.target.value),onKeyDown:P,placeholder:n==="variable"?"KEY":"Header-Name",spellCheck:!1,autoFocus:!0,className:"w-44 h-7 px-2 bg-bg border border-line rounded font-mono text-xs text-fg"}),s.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs text-fg-faint",children:a}),s.jsx("input",{ref:v,type:"password",autoComplete:"off","data-testid":`${e}-new-value`,"aria-label":`New ${n} value`,onKeyDown:P,placeholder:"value",spellCheck:!1,className:"flex-1 min-w-0 h-7 px-2 bg-bg border border-line rounded font-mono text-xs text-fg"}),s.jsx("button",{type:"button","data-testid":`${e}-add-confirm`,onClick:J,disabled:!w,className:"shrink-0 h-7 px-2.5 rounded-md bg-accent text-bg-hi text-xs font-semibold hover:bg-accent/90 disabled:opacity-50 disabled:hover:bg-accent",children:"Add"}),s.jsx("button",{type:"button","data-testid":`${e}-add-cancel`,onClick:A,className:"shrink-0 h-7 px-2 text-xs text-fg-faint hover:text-fg",children:"Cancel"})]}):p.length>0?s.jsx("div",{children:B}):null]})}function gs({serverName:e,result:t}){return s.jsxs("section",{"data-testid":"mcp-tools",className:"flex flex-col gap-[7px]",children:[s.jsxs("h3",{className:`flex items-baseline gap-2 ${Xe}`,children:["Tools",t!=null&&t.ok?s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-testid":"mcp-tools-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:t.tools.length}),s.jsx("span",{className:"font-normal tracking-normal normal-case text-fg-faint/80",children:"from the last check"})]}):null]}),t?t.ok?t.tools.length===0?s.jsx("div",{"data-testid":"mcp-tools-empty",className:Je,children:"The last check listed no tools."}):s.jsx("div",{className:"bg-bg-hi border border-line rounded-md divide-y divide-line",children:t.tools.map((n,a)=>s.jsxs("div",{"data-testid":`mcp-tool-row-${n.name}`,className:"grid grid-cols-[120px_minmax(0,1fr)_auto] items-baseline gap-4 px-3 py-2.5",children:[s.jsx("span",{title:n.name,className:"truncate font-mono text-[12.5px] font-semibold text-fg",children:n.name}),s.jsx("span",{title:n.description||void 0,className:"line-clamp-2 text-[12.5px] text-fg-dim",children:n.description??""}),s.jsx("span",{className:"font-mono text-[11px] text-fg-faint/80",children:fs(e,n.name)})]},`${a}:${n.name}`))}):s.jsxs("div",{"data-testid":"mcp-tools-empty",className:Je,children:[t.status==="needs-auth"?"The last check needs auth":"The last check failed",": ",t.error]}):s.jsx("div",{"data-testid":"mcp-tools-empty",className:Je,children:"Check this server to list its tools."})]})}const et=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Ye="disable-model-invocation",At=/^\s*disable-model-invocation\s*:/;function bs(e){const t=e.match(et);if(!t)return!1;for(const n of t[1].split(/\r?\n/)){if(!At.test(n))continue;const a=n.slice(n.indexOf(":")+1).trim().toLowerCase();return a==="true"||a==="yes"}return!1}function vs(e){const t=e.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function de(e){return e.length-e.trimStart().length}function Oe(e){const t=e.match(et);if(!t)return{name:null,description:null,body:e};const n=t[1].split(/\r?\n/),a=t[2]??"";let l=null,r=null;for(let i=0;i<n.length;i++){const o=n[i],h=o.match(/^(\s*)(name|description)\s*:(.*)$/);if(!h)continue;const[,,m,g]=h,u=g.trim(),x=de(o);let v;if(u===""||u===">-"||u===">"||u==="|-"||u==="|"){const p=[];let b=i+1;for(;b<n.length&&n[b].trim()!==""&&de(n[b])>x;)p.push(n[b].trim()),b++;v=p.join(" ")}else v=vs(u);m==="name"?l=v:r=v}return{name:l,description:r,body:a}}function ks(e,t){const n=e.match(et);if(!n){if(!t)return e;const i=e.startsWith(`
1
+ import{aO as f,ay as s,a7 as Bt,ad as Kt,b7 as q,aj as Wt,c as Ht,ac as Ut,az as jt,bh as yt,b8 as wt,bb as T,m as ne,bu as Jt,F as Yt,P as Vt,af as zt,aS as qt,aW as Gt,bc as Nt}from"./index-Cznhnxhq.js";import{P as Te}from"./Panel-DP8eSKSs.js";import{L as St}from"./ListDetail-DJYMWYQd.js";import{f as rt,S as $t,m as Qt}from"./Library-I37dQ6pB.js";import{a as Qe,u as lt,p as Zt,c as Xt,P as es}from"./ProvenanceBadge-DUwhsmdA.js";import{T as ts}from"./Toggle-CrgM7OTR.js";function Ct({filter:e,onFilterChange:t,placeholder:n,summary:a,children:l,primary:r}){const[i,o]=f.useState(!1),h=f.useRef(null),m=f.useRef(null),g=f.useId();return f.useEffect(()=>{if(!i)return;const u=v=>{var b,w;const p=v.target;(b=h.current)!=null&&b.contains(p)||(w=m.current)!=null&&w.contains(p)||o(!1)},x=v=>{v.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",u),window.addEventListener("keydown",x),()=>{window.removeEventListener("mousedown",u),window.removeEventListener("keydown",x)}},[i]),s.jsxs("div",{"data-testid":"extensions-toolbar",className:"relative shrink-0 h-11 flex items-center gap-3 px-3 bg-bg-elev border-b border-line text-xs",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsxs("svg",{"aria-hidden":"true",className:"pointer-events-none absolute left-[9px] top-1/2 -translate-y-1/2 text-fg-faint/80",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),s.jsx("input",{type:"text","data-testid":"extensions-toolbar-filter",value:e,onChange:u=>t(u.target.value),placeholder:n,"aria-label":n,spellCheck:!1,className:"w-[276px] h-7 pl-[29px] pr-[9px] bg-bg-hi border border-line rounded-md text-xs text-fg placeholder:text-fg-faint/80 focus:outline-none focus:border-fg-faint"})]}),s.jsx("span",{"data-testid":"extensions-toolbar-summary",className:"min-w-0 truncate text-fg-faint",children:a}),l,s.jsxs("button",{ref:h,type:"button","data-testid":r.testId,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?g:void 0,onClick:()=>o(u=>!u),className:"ml-auto shrink-0 h-7 inline-flex items-center gap-1.5 pl-3 pr-2.5 rounded-md bg-accent text-bg-hi text-[12.5px] font-semibold shadow-sm hover:bg-accent/90",children:[r.label,s.jsx("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m6 9 6 6 6-6"})})]}),i&&s.jsx("div",{ref:m,id:g,role:"menu","aria-label":r.label,"data-testid":`${r.testId}-menu`,className:`absolute ${Bt.dialog} right-3 top-[42px] min-w-[210px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[12.5px] text-fg`,children:r.items.map(u=>s.jsx("button",{type:"button",role:"menuitem","data-testid":u.testId,onClick:()=>{o(!1),u.onSelect()},className:"px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev",children:u.label},u.testId))})]})}const ss=2;function be(e){return`${e.source}:${e.pluginKey??e.cwd??""}:${e.name}`}const He=new Map,ns=e=>e instanceof Error?e.message:String(e);async function as(e){try{return await window.api.mcp.checkServer(e)}catch(t){const n=ns(t);return q.error(`MCP check of ${e.name} failed: ${n}`),{ok:!1,status:"failed",error:n,checkedAt:Date.now()}}}const ve=Kt((e,t)=>({results:{},checking:{},check:n=>{const a=be(n),l=He.get(a);if(l)return l;e(i=>({checking:{...i.checking,[a]:!0}}));const r=as(n).then(i=>(He.delete(a),e(o=>{const h={...o.checking};return delete h[a],{results:{...o.results,[a]:i},checking:h}}),i));return He.set(a,r),r},checkAll:async n=>{const a=[...new Map(n.map(i=>[be(i),i])).values()];let l=0;const r=async()=>{for(;l<a.length;)await t().check(a[l++])};await Promise.all(Array.from({length:Math.min(ss,a.length)},r))}})),rs=e=>e.results,ls=e=>e.checking,qe={unchecked:"Not checked",connected:"Connected",failed:"Failed","needs-auth":"Needs auth"},Et={unchecked:"border-[1.5px] border-fg-faint/60",connected:"bg-sage",failed:"bg-red-500","needs-auth":"bg-honey"},is={unchecked:"bg-bg-elev text-fg-dim",connected:"bg-sage/15 text-sage-dark",failed:"bg-red-500/10 text-red-700","needs-auth":"bg-honey/15 text-honey-dark"},os={user:"User scope",project:"Project scope",local:"Local scope"},cs=3e4,ds="••••••••",us=/^[A-Za-z0-9_@%+=:,./-]+$/;function ms(e){return us.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Ze(e){return(e.type??"stdio")!=="stdio"}function ps(e){return Ze(e)?e.url??"":e.command?[e.command,...e.args??[]].map(ms).join(" "):""}const it=e=>e.replace(/[^A-Za-z0-9_-]/g,"_");function fs(e,t){return`mcp__${it(e)}__${it(t)}`}const Ue="h-7 inline-flex items-center whitespace-nowrap px-[11px] bg-bg-hi border border-line rounded-md text-[12.5px] text-fg hover:border-rule disabled:opacity-50 disabled:hover:border-line",Xe="text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",Je="px-3 py-2.5 border border-dashed border-rule rounded-md text-[12.5px] text-fg-faint";function ot({name:e,server:t,scope:n,fileLabel:a,plugin:l,checkRequest:r,provenance:i,onChange:o,editing:h=!1,onEditingChange:m,editor:g}){const u=l!==void 0,x=!u&&h,v=r?be(r):null,p=ve(P=>v===null?void 0:P.results[v]),b=ve(P=>v===null?!1:P.checking[v]===!0),w=ve(P=>P.check);xs(cs,p!==void 0);const C=(p==null?void 0:p.status)??"unchecked",A=Date.now(),J=Ze(t);return s.jsxs("div",{"data-testid":"mcp-detail",className:"flex flex-col gap-[18px] px-6 py-[18px]",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[s.jsx("h2",{"data-testid":"mcp-detail-name",className:"min-w-0 truncate text-[22px] leading-tight font-semibold tracking-[-.01em] text-fg",children:e}),s.jsxs("span",{"data-testid":"mcp-detail-status","data-status":C,title:p&&!p.ok?p.error:void 0,className:`shrink-0 inline-flex items-center gap-1.5 h-[22px] px-[9px] rounded-full text-xs font-semibold ${is[C]}`,children:[s.jsx("span",{"aria-hidden":"true",className:`w-1.5 h-1.5 shrink-0 box-border rounded-full ${Et[C]}${b?" animate-pulse":""}`}),qe[C]]}),b?s.jsx("span",{"data-testid":"mcp-detail-checked",className:"shrink-0 text-xs text-fg-faint",children:"checking…"}):p?s.jsxs("span",{"data-testid":"mcp-detail-checked",title:new Date(p.checkedAt).toLocaleString(),className:"shrink-0 text-xs text-fg-faint",children:["checked ",Wt(Math.min(p.checkedAt,A),A)]}):null]}),s.jsxs("div",{"data-testid":"mcp-detail-meta",className:"flex flex-wrap items-center gap-2 text-xs text-fg-faint",children:[s.jsx(Qe,{scope:n,input:i,interactive:!1}),s.jsx("span",{"data-testid":"mcp-detail-transport",className:"inline-flex",children:s.jsx(Ht,{tone:"dim",children:u?"plugin":t.type??"stdio"})}),u?s.jsxs(s.Fragment,{children:[s.jsxs("span",{"data-testid":"mcp-detail-plugin",children:["via the ",l," plugin"]}),s.jsx("span",{"aria-hidden":"true",className:"text-fg-faint/60",children:"·"}),s.jsx("span",{"data-testid":"mcp-detail-readonly",children:"read-only"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-testid":"mcp-detail-scope",children:os[n]}),s.jsx("span",{"aria-hidden":"true",className:"text-fg-faint/60",children:"·"}),s.jsxs("span",{"data-testid":"mcp-detail-keypath",className:"min-w-0 font-mono text-[11.5px] text-fg-dim break-words",children:[a," › mcpServers › ",e]})]})]})]}),s.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-2",children:[s.jsx("button",{type:"button","data-testid":"mcp-check-again",onClick:()=>{r&&w(r)},disabled:r===null||b,className:Ue,children:b?"Checking…":"Check again"}),u?null:x?s.jsx("button",{type:"button","data-testid":"mcp-edit-done",onClick:()=>m==null?void 0:m(!1),className:Ue,children:"Done"}):s.jsx("button",{type:"button","data-testid":"mcp-edit-json",onClick:()=>m==null?void 0:m(!0),className:Ue,children:"Edit JSON"})]})]}),x?g:s.jsxs(s.Fragment,{children:[s.jsx(hs,{server:t,readOnly:u}),u?null:J?s.jsx(ct,{testId:"mcp-headers",label:"Headers",noun:"header",separator:":",emptyText:"No headers set",values:t.headers??{},onAdd:(P,B)=>o==null?void 0:o({...t,headers:{...t.headers??{},[P]:B}})}):s.jsx(ct,{testId:"mcp-env",label:"Environment",noun:"variable",separator:"=",emptyText:"No variables set",values:t.env??{},onAdd:(P,B)=>o==null?void 0:o({...t,env:{...t.env??{},[P]:B}})}),s.jsx(gs,{serverName:e,result:p})]})]})}function xs(e,t){const[,n]=f.useState(0);f.useEffect(()=>{if(!t)return;const a=window.setInterval(()=>n(l=>l+1),e);return()=>window.clearInterval(a)},[e,t])}function hs({server:e,readOnly:t}){const n=Ze(e),a=ps(e),l=async()=>{await Ut(a)?q.success(n?"URL copied":"Command copied"):q.error(n?"Copy failed — the URL was not copied":"Copy failed — the command was not copied")};return s.jsxs("section",{className:"flex flex-col gap-[7px]",children:[s.jsx("h3",{className:Xe,children:"Command"}),s.jsxs("div",{"data-testid":"mcp-command-box",className:"flex items-center gap-2.5 px-3 py-2.5 bg-bg-hi border border-line rounded-md font-mono text-[13px] text-fg",children:[n?null:s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-faint/60",children:"$"}),a?s.jsx("span",{"data-testid":"mcp-command",className:"min-w-0 break-words",children:a}):s.jsx("span",{"data-testid":"mcp-command-empty",className:"min-w-0 font-sans text-[12.5px] text-fg-faint",children:t?n?"No URL set.":"No command set.":n?"No URL set — Edit JSON to add one.":"No command set — Edit JSON to add one."}),s.jsx("button",{type:"button","data-testid":"mcp-command-copy",onClick:()=>void l(),disabled:!a,className:"ml-auto shrink-0 font-sans text-xs text-fg-faint hover:text-fg disabled:opacity-50 disabled:hover:text-fg-faint",children:"Copy"})]})]})}function ct({testId:e,label:t,noun:n,separator:a,emptyText:l,values:r,onAdd:i}){const[o,h]=f.useState(()=>new Set),[m,g]=f.useState(!1),[u,x]=f.useState(""),v=f.useRef(null),p=Object.keys(r),b=u.trim(),w=b!==""&&!/\s/.test(b)&&!b.includes(a),C=N=>h(L=>{const G=new Set(L);return G.has(N)?G.delete(N):G.add(N),G}),A=()=>{g(!1),x("")},J=()=>{var N;w&&(i(b,((N=v.current)==null?void 0:N.value)??""),A())},P=N=>{N.key==="Enter"?(N.preventDefault(),J()):N.key==="Escape"&&(N.preventDefault(),A())},B=s.jsxs("button",{type:"button","data-testid":`${e}-add`,onClick:()=>g(!0),className:"shrink-0 text-[12.5px] font-semibold text-accent hover:text-accent-dark",children:["+ Add ",n]});return s.jsxs("section",{"data-testid":e,className:"flex flex-col gap-[7px]",children:[s.jsx("h3",{className:Xe,children:t}),p.length===0&&!m?s.jsxs("div",{"data-testid":`${e}-empty`,className:"flex items-center gap-2.5 px-3 py-2.5 border border-dashed border-rule rounded-md text-[12.5px] text-fg-faint",children:[l,s.jsx("span",{className:"ml-auto",children:B})]}):null,p.length>0?s.jsx("div",{className:"bg-bg-hi border border-line rounded-md divide-y divide-line",children:p.map(N=>{const L=o.has(N);return s.jsxs("div",{"data-testid":`${e}-row-${N}`,className:"flex items-center gap-2.5 px-3 py-2 font-mono text-[12.5px]",children:[s.jsx("span",{className:"shrink-0 font-semibold text-fg",children:N}),s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-faint/60",children:a}),s.jsx("span",{"data-testid":`${e}-value-${N}`,title:L?void 0:"Hidden — Show reveals it",className:`min-w-0 break-words ${L?"text-fg-dim":"text-fg-faint tracking-wider"}`,children:L?r[N]:ds}),s.jsx("button",{type:"button","data-testid":`${e}-reveal-${N}`,"aria-pressed":L,"aria-label":`${L?"Hide":"Show"} the value of ${N}`,onClick:()=>C(N),className:"ml-auto shrink-0 font-sans text-xs text-fg-faint hover:text-fg",children:L?"Hide":"Show"})]},N)})}):null,m?s.jsxs("div",{"data-testid":`${e}-add-form`,className:"flex items-center gap-2 px-3 py-2 bg-bg-hi border border-line rounded-md",children:[s.jsx("input",{"data-testid":`${e}-new-key`,"aria-label":`New ${n} name`,value:u,onChange:N=>x(N.target.value),onKeyDown:P,placeholder:n==="variable"?"KEY":"Header-Name",spellCheck:!1,autoFocus:!0,className:"w-44 h-7 px-2 bg-bg border border-line rounded font-mono text-xs text-fg"}),s.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs text-fg-faint",children:a}),s.jsx("input",{ref:v,type:"password",autoComplete:"off","data-testid":`${e}-new-value`,"aria-label":`New ${n} value`,onKeyDown:P,placeholder:"value",spellCheck:!1,className:"flex-1 min-w-0 h-7 px-2 bg-bg border border-line rounded font-mono text-xs text-fg"}),s.jsx("button",{type:"button","data-testid":`${e}-add-confirm`,onClick:J,disabled:!w,className:"shrink-0 h-7 px-2.5 rounded-md bg-accent text-bg-hi text-xs font-semibold hover:bg-accent/90 disabled:opacity-50 disabled:hover:bg-accent",children:"Add"}),s.jsx("button",{type:"button","data-testid":`${e}-add-cancel`,onClick:A,className:"shrink-0 h-7 px-2 text-xs text-fg-faint hover:text-fg",children:"Cancel"})]}):p.length>0?s.jsx("div",{children:B}):null]})}function gs({serverName:e,result:t}){return s.jsxs("section",{"data-testid":"mcp-tools",className:"flex flex-col gap-[7px]",children:[s.jsxs("h3",{className:`flex items-baseline gap-2 ${Xe}`,children:["Tools",t!=null&&t.ok?s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-testid":"mcp-tools-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:t.tools.length}),s.jsx("span",{className:"font-normal tracking-normal normal-case text-fg-faint/80",children:"from the last check"})]}):null]}),t?t.ok?t.tools.length===0?s.jsx("div",{"data-testid":"mcp-tools-empty",className:Je,children:"The last check listed no tools."}):s.jsx("div",{className:"bg-bg-hi border border-line rounded-md divide-y divide-line",children:t.tools.map((n,a)=>s.jsxs("div",{"data-testid":`mcp-tool-row-${n.name}`,className:"grid grid-cols-[120px_minmax(0,1fr)_auto] items-baseline gap-4 px-3 py-2.5",children:[s.jsx("span",{title:n.name,className:"truncate font-mono text-[12.5px] font-semibold text-fg",children:n.name}),s.jsx("span",{title:n.description||void 0,className:"line-clamp-2 text-[12.5px] text-fg-dim",children:n.description??""}),s.jsx("span",{className:"font-mono text-[11px] text-fg-faint/80",children:fs(e,n.name)})]},`${a}:${n.name}`))}):s.jsxs("div",{"data-testid":"mcp-tools-empty",className:Je,children:[t.status==="needs-auth"?"The last check needs auth":"The last check failed",": ",t.error]}):s.jsx("div",{"data-testid":"mcp-tools-empty",className:Je,children:"Check this server to list its tools."})]})}const et=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Ye="disable-model-invocation",At=/^\s*disable-model-invocation\s*:/;function bs(e){const t=e.match(et);if(!t)return!1;for(const n of t[1].split(/\r?\n/)){if(!At.test(n))continue;const a=n.slice(n.indexOf(":")+1).trim().toLowerCase();return a==="true"||a==="yes"}return!1}function vs(e){const t=e.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function de(e){return e.length-e.trimStart().length}function Oe(e){const t=e.match(et);if(!t)return{name:null,description:null,body:e};const n=t[1].split(/\r?\n/),a=t[2]??"";let l=null,r=null;for(let i=0;i<n.length;i++){const o=n[i],h=o.match(/^(\s*)(name|description)\s*:(.*)$/);if(!h)continue;const[,,m,g]=h,u=g.trim(),x=de(o);let v;if(u===""||u===">-"||u===">"||u==="|-"||u==="|"){const p=[];let b=i+1;for(;b<n.length&&n[b].trim()!==""&&de(n[b])>x;)p.push(n[b].trim()),b++;v=p.join(" ")}else v=vs(u);m==="name"?l=v:r=v}return{name:l,description:r,body:a}}function ks(e,t){const n=e.match(et);if(!n){if(!t)return e;const i=e.startsWith(`
2
2
  `)?"":`
3
3
  `;return`---
4
4
  ${Ye}: true
@@ -7,23 +7,23 @@ ${i}${e}`}const a=n[2]??"",l=n[1].split(/\r?\n/),r=l.findIndex(i=>At.test(i));if
7
7
  ${l.join(`
8
8
  `)}
9
9
  ---
10
- ${a}`}const Lt=/^(---\r?\n)([\s\S]*?\r?\n)---/,Rt=/^\s*description\s*:/,js=/^\s*name\s*:/,ys=/^[|>][-+\d]*\s*(?:#.*)?$/;function ws(e){const t=Lt.exec(e);if(!t)return{frontmatter:null,body:e};const n=e.indexOf(`
10
+ ${a}`}const Lt=/^(---\r?\n)([\s\S]*?\r?\n)---/,_t=/^\s*description\s*:/,js=/^\s*name\s*:/,ys=/^[|>][-+\d]*\s*(?:#.*)?$/;function ws(e){const t=Lt.exec(e);if(!t)return{frontmatter:null,body:e};const n=e.indexOf(`
11
11
  `,t[0].length),a=n===-1?e.length:n+1;return{frontmatter:e.slice(0,a),body:e.slice(a)}}function Ns(e,t){if(!e||!t||e.endsWith(`
12
12
  `))return(e??"")+t;const n=e.endsWith("\r")?`
13
13
  `:e.startsWith(`---\r
14
14
  `)?`\r
15
15
  `:`
16
- `;return e+n+t}function _t(e){const t=Lt.exec(e);if(!t)return null;const n=t[1],a=t[2],l=a.match(/[^\n]*\n/g)??[],r=l.map(o=>o.replace(/\r?\n$/,""));let i=null;for(const o of r)o.trim()===""||o.trimStart().startsWith("#")||(i===null||de(o)<i.length)&&(i=o.slice(0,de(o)));return{open:n,lines:l,texts:r,pad:i??"",rest:e.slice(n.length+a.length)}}function Ge(e,t){const{texts:n}=e,a=e.pad.length,l=[];for(let r=0;r<n.length;r++){if(de(n[r])!==a||!t.test(n[r]))continue;let i=r+1;for(let o=i;o<n.length;o++)if(n[o].trim()!==""){if(de(n[o])<=a)break;i=o+1}l.push({start:r,end:i}),r=i-1}return l}function dt(e){return e.endsWith(`\r
16
+ `;return e+n+t}function Rt(e){const t=Lt.exec(e);if(!t)return null;const n=t[1],a=t[2],l=a.match(/[^\n]*\n/g)??[],r=l.map(o=>o.replace(/\r?\n$/,""));let i=null;for(const o of r)o.trim()===""||o.trimStart().startsWith("#")||(i===null||de(o)<i.length)&&(i=o.slice(0,de(o)));return{open:n,lines:l,texts:r,pad:i??"",rest:e.slice(n.length+a.length)}}function Ge(e,t){const{texts:n}=e,a=e.pad.length,l=[];for(let r=0;r<n.length;r++){if(de(n[r])!==a||!t.test(n[r]))continue;let i=r+1;for(let o=i;o<n.length;o++)if(n[o].trim()!==""){if(de(n[o])<=a)break;i=o+1}l.push({start:r,end:i}),r=i-1}return l}function dt(e){return e.endsWith(`\r
17
17
  `)?`\r
18
18
  `:`
19
- `}const Ss=/^(?:true|false|yes|no|on|off|y|n|null|~|[-+]?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:e[-+]?\d+)?|0x[\da-f_]+|0o[0-7_]+|0b[01_]+|[-+]?\.(?:inf|nan)|\d{4}-\d\d?-\d\d?)$/i,$s=/^$|^[-?,[\]{}&*!|>'"%@`]|[\u0000-\u001f\u007f\u0085\u2028\u2029]/,Cs={"\\":"\\\\",'"':'\\"',"\n":"\\n","\r":"\\r"," ":"\\t"};function Es(e){return/[:#]|^\s|\s$/.test(e)||$s.test(e)||Ss.test(e)?`"${e.replace(/[\\"\u0000-\u001f\u007f\u0085\u2028\u2029]/g,a=>Cs[a]??`\\u${a.charCodeAt(0).toString(16).padStart(4,"0")}`)}"`:e}function As(e,t){const n=`description: ${Es(t)}`,a=_t(e);if(!a){const u=e.indexOf(`
19
+ `}const Ss=/^(?:true|false|yes|no|on|off|y|n|null|~|[-+]?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:e[-+]?\d+)?|0x[\da-f_]+|0o[0-7_]+|0b[01_]+|[-+]?\.(?:inf|nan)|\d{4}-\d\d?-\d\d?)$/i,$s=/^$|^[-?,[\]{}&*!|>'"%@`]|[\u0000-\u001f\u007f\u0085\u2028\u2029]/,Cs={"\\":"\\\\",'"':'\\"',"\n":"\\n","\r":"\\r"," ":"\\t"};function Es(e){return/[:#]|^\s|\s$/.test(e)||$s.test(e)||Ss.test(e)?`"${e.replace(/[\\"\u0000-\u001f\u007f\u0085\u2028\u2029]/g,a=>Cs[a]??`\\u${a.charCodeAt(0).toString(16).padStart(4,"0")}`)}"`:e}function As(e,t){const n=`description: ${Es(t)}`,a=Rt(e);if(!a){const u=e.indexOf(`
20
20
  `),x=u>0&&e[u-1]==="\r"?`\r
21
21
  `:`
22
- `;return`---${x}${n}${x}---${x}${e}`}const{open:l,lines:r,texts:i,pad:o,rest:h}=a,[m,...g]=Ge(a,Rt);if(m){for(const x of g.reverse())r.splice(x.start,x.end-x.start);const u=r[m.start];r.splice(m.start,m.end-m.start,u.slice(0,de(u))+n+dt(u))}else{const[u]=Ge(a,js);let x=u?u.end:i.length;if(!u)for(;x>0&&i[x-1].trim()==="";)x--;r.splice(x,0,o+n+dt(x>0?r[x-1]:l))}return l+r.join("")+h}const Ls={0:"\0",a:"\x07",b:"\b",t:" "," ":" ",n:`
23
- `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function Rs(e){const t=e.trim(),n=/^"((?:[^"\\]|\\[\s\S])*)"/.exec(t);if(n)return n[1].replace(/\\(x[\da-fA-F]{2}|u[\da-fA-F]{4}|U[\da-fA-F]{8}|[\s\S])/g,(r,i)=>{if(i.length===1)return Ls[i]??r;const o=parseInt(i.slice(1),16);return o<=1114111?String.fromCodePoint(o):r});const a=/^'((?:[^']|'')*)'/.exec(t);if(a)return a[1].replace(/''/g,"'");const l=t.search(/(?:^|\s)#/);return l===-1?t:t.slice(0,l).trimEnd()}function _s(e){const t=_t(e),n=t?Ge(t,Rt)[0]:void 0;if(!t||!n)return null;const[a,...l]=t.texts.slice(n.start,n.end),r=a.slice(a.indexOf(":")+1).trim().replace(/^#.*/,""),i=l.map(o=>o.trim()).filter(Boolean);return ys.test(r)?i.join(" "):Rs([r,...i].join(" "))}async function Pt(e){const t=`${e}/skills`;return await window.api.config.exists(t)?t:null}async function Mt(e){const{entries:t}=await jt(e,{nested:!1});return t.map(n=>{const a=Oe(n.text);return{id:n.name,name:a.name,description:a.description,dir:n.dir,path:n.path,body:a.body}})}function wn(e){const t=[],n=new Set;for(const a of e)for(const l of e){if(a.id===l.id)continue;const r=l.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=[`/${r}\\b`,`\`${r}\``];if(l.id.length>=4&&i.push(`\\b${r}\\b`),!i.some(m=>new RegExp(m,"i").test(a.body)))continue;const h=`${a.id}->${l.id}`;n.has(h)||(n.add(h),t.push({from:a.id,to:l.id}))}return t}function Nn(e,t){return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,mcpServers:0,error:t}}async function Sn(e){const{hasManifest:t,manifest:n}=await tt(e.path),[a,l]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let r=0;if(l){const u=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(u.data)?r=u.data.length:u.data&&typeof u.data=="object"&&Array.isArray(u.data.monitors)&&(r=u.data.monitors.length)}const[i,o,h]=await Promise.all([Ot(e.path,n),It(`${e.path}/bin`,{filesOnly:!0}),Pt(e.path)]),m=o.length,g=h?(await Mt(h)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:t,manifest:n,hasLsp:a,monitors:r,hooks:i.hooks,agents:i.agentFiles.length,commands:i.commandFiles.length,skills:g,binCount:m,hasMcp:i.mcpServers.length>0,mcpServers:i.mcpServers.length}}function $n(e){return{skills:e.skills,commands:e.commands,agents:e.agents,hooks:e.hooks,mcpServers:e.mcpServers}}async function tt(e){let t=`${e}/.claude-plugin/plugin.json`,n=await window.api.config.exists(t);if(n||(t=`${e}/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 Q=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Ps(e,t){const n=t.startsWith("/")?t.startsWith(`${e}/`)?t.slice(e.length+1):null:t;if(n===null)return ut(t);const a=[];for(const l of n.split("/"))if(!(l===""||l===".")){if(l!=="..")a.push(l);else if(a.pop()===void 0)return ut(t)}return a.length>0?`${e}/${a.join("/")}`:e}function ut(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Ms(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Fs(e){if(!Q(e))return null;if(Q(e.mcpServers))return e.mcpServers;const t=Object.values(e);return t.length>0&&t.every(a=>Q(a)&&(typeof a.command=="string"||typeof a.url=="string"))?e:null}function Ds(e){if(!Q(e))return 0;const t=Q(e.hooks)?e.hooks:e;return Object.values(t).reduce((n,a)=>Array.isArray(a)?n+a.reduce((l,r)=>l+(Q(r)&&Array.isArray(r.hooks)?r.hooks.length:0),0):n,0)}function Me(e,t,n){const a=new Set;for(const l of Ms(t)){const r=Ps(e,l);r&&a.add(r)}return a.add(`${e}/${n}`),[...a]}async function Ft(e){try{const t=await window.api.config.readJson(e);return t.exists&&!t.parseError?t.data:null}catch{return null}}function Dt(e,t){return Me(e,typeof t=="string"||Array.isArray(t)?t:void 0,".mcp.json")}async function Tt(e,t){const n=await Promise.all(t.map(Ft)),a=new Map;for(const l of[...Q(e)?[e]:[],...n])for(const[r,i]of Object.entries(Fs(l)??{})){if(a.has(r))continue;const o=Q(i)?i.command:void 0,h=Q(i)?i.url:void 0;a.set(r,{id:r,name:r,description:typeof o=="string"?o:typeof h=="string"?h:null})}return[...a.values()]}async function Ot(e,t){const n=async p=>{const b=new Set;for(const w of p)if(w.endsWith(".md"))b.add(w);else for(const C of await It(w,{filesOnly:!0}))C.endsWith(".md")&&b.add(`${w}/${C}`);return[...b]},a=Me(e,t==null?void 0:t.commands,"commands"),l=Me(e,t==null?void 0:t.agents,"agents"),r=t==null?void 0:t.hooks,i=Me(e,typeof r=="string"||Array.isArray(r)?r:void 0,"hooks/hooks.json"),o=t==null?void 0:t.mcpServers,h=Dt(e,o),[m,g,u,x]=await Promise.all([n(a),n(l),Promise.all(i.map(Ft)),Tt(o,h)]),v=[...Q(r)?[r]:[],...u].reduce((p,b)=>p+Ds(b),0);return{commandFiles:m,agentFiles:g,hooks:v,mcpServers:x,sourcePaths:[...a,...l,...i,...h]}}async function Ts(e){const{manifest:t}=await tt(e),n=t==null?void 0:t.mcpServers;return Tt(n,Dt(e,n))}async function Os(e){const t=await Promise.all(e.map(a=>window.api.config.readText(a))),n=[];return e.forEach((a,l)=>{if(!t[l].exists)return;const r=a.slice(a.lastIndexOf("/")+1),i=Oe(t[l].text);n.push({id:a,name:i.name??r.replace(/\.md$/,""),description:i.description})}),n}async function It(e,t){try{return(await window.api.config.listDir(e,t)).entries.map(a=>a.name)}catch{return[]}}const Fe=(e,t)=>({type:"mcp",name:e,command:t.command,args:t.args,url:t.url}),Is=["stdio","http","streamable-http","sse","ws"],Bs=new Set(["workspace"]),Ks=new Set(["ide","tasks"]);function Ws(e,t,n){return e==="user"?`${t}/.claude.json`:n?`${n}/.mcp.json`:null}function Hs(e){if(e.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(e),n=t.mcpServers??{};return{full:t,servers:n,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Us(e,t){const n={};for(const[a,l]of Object.entries(t)){const{enabled:r,...i}=l;n[a]=i}return JSON.stringify({...e,mcpServers:n},null,2)+`
24
- `}function Js(e,t){const n=[];for(const[a,l]of Object.entries(t)){if(JSON.stringify(l)===JSON.stringify(e[a]))continue;const{enabled:r,...i}=l;n.push({name:a,value:i})}for(const a of Object.keys(e))a in t||n.push({name:a,value:void 0});return n}function Ys(e){let t=Object.keys(e).length+1,n=`server-${t}`;for(;e[n];)t+=1,n=`server-${t}`;return n}const Ve=e=>({source:"plugin",name:e.name,pluginKey:e.pluginKey});async function Vs(){var r,i;const t=(await((i=(r=window.api.plugins)==null?void 0:r.list)==null?void 0:i.call(r))??[]).filter(o=>o.enabled&&!!o.installPath),n=await Promise.allSettled(t.map(o=>Ts(o.installPath))),a=[],l=[];return n.forEach((o,h)=>{const m=t[h];if(o.status==="rejected"){l.push(m.name);return}for(const g of o.value){const u=g.description??"",x=/^[a-z][a-z0-9+.-]*:\/\//i.test(u)?{type:"http",url:u}:{command:u||void 0};a.push({id:`${m.key}/${g.name}`,pluginKey:m.key,plugin:m.name,name:g.name,server:x})}}),l.length>0&&q.error(`Could not read the MCP servers of plugin ${l.join(", ")}`),a.sort((o,h)=>o.plugin.localeCompare(h.plugin)||o.name.localeCompare(h.name))}const zs={anthropic:"text-accent-dark",community:"text-honey-dark",local:""};function mt(e){if(!e)return"not checked";if(e.status==="connected"){const t=e.tools.length;return`connected · ${t} tool${t===1?"":"s"}`}return e.status==="needs-auth"?"needs auth":"failed"}function qs(e,t,n){return e==="user"?{source:"user",name:n}:t?{source:"project",name:n,cwd:t}:null}function pt({result:e,checking:t,testId:n}){const a=(e==null?void 0:e.status)??"unchecked";return s.jsx("span",{"aria-hidden":"true","data-testid":n,"data-status":a,title:e&&!e.ok?`${qe[a]}: ${e.error}`:qe[a],className:`w-2 h-2 shrink-0 box-border rounded-full ${Et[a]}${t?" animate-pulse":""}`})}function Gs({onAdd:e,scope:t="user"}={}){const n=yt(),a=wt(),l=(a==null?void 0:a.cwd)??null,[r,i]=f.useState(null),[o,h]=f.useState(null),[m,g]=f.useState(""),[u,x]=f.useState(null),v=f.useRef(null),p=f.useMemo(()=>n?Ws(t,n,l):null,[n,t,l]),b=T(d=>d.files),w=T(d=>d.loadJson),C=T(d=>d.setDraft),A=T(d=>d.revert),J=T(d=>d.watchFile),P=T(d=>d.unwatchFile);f.useEffect(()=>{if(p)return b[p]||w(p),J(p),()=>P(p)},[p]);const[B,N]=f.useState(null),[L,G]=f.useState([]);f.useEffect(()=>{if(t!=="user"){G([]);return}let d=!0;return Vs().then(k=>{d&&G(k)}).catch(k=>{d&&q.error(`Could not list plugin MCP servers: ${k instanceof Error?k.message:String(k)}`)}),()=>{d=!1}},[t]);const ae=ve(rs),ee=ve(ls),$e=ve(d=>d.checkAll),ue=lt(d=>d.overrides),R=lt(d=>d.load);if(f.useEffect(()=>{n&&R(n)},[n,R]),!n)return s.jsx(ne,{title:"loading…"});if(t==="project"&&!l)return s.jsx(Te,{toolbar:s.jsx(s.Fragment,{}),children:s.jsx(ne,{title:"no active project"})});if(!p)return s.jsx(ne,{title:"loading…"});const W=b[p],{full:me,servers:D,err:Ce}=W?Hs(W.draftRaw):{full:{},servers:{},err:null},K=Object.keys(D).sort(),Y=m.trim().toLowerCase(),H=Y?K.filter(d=>d.toLowerCase().includes(Y)):K,V=Y?L.filter(d=>d.name.toLowerCase().includes(Y)):L,ke=o!==null?L.find(d=>d.id===o)??null:null,Ee=r!==null&&K.includes(r)?r:null,re=H[0]??(V.length>0?null:K[0]??null),O=ke??(Ee===null&&re===null?V[0]??L[0]??null:null),M=O?null:Ee??re,pe=d=>qs(t,l,d),Ae=d=>{const k=pe(d);return k?ae[be(k)]:void 0},Le=d=>{const k=pe(d);return k?ee[be(k)]===!0:!1},fe=d=>be(Ve(d)),Re=[...H.map(pe).filter(d=>d!==null),...V.map(Ve)],Ie=[`${K.length} server${K.length===1?"":"s"}`,...L.length>0?[`${L.length} from plugins`]:[]],Be=K.filter(d=>Ae(d)!==void 0).length+L.filter(d=>ae[fe(d)]!==void 0).length,le=H.some(Le)||V.some(d=>ee[fe(d)]===!0),ie=t==="user"?"~/.claude.json":".mcp.json",oe=d=>{N(null),C(p,Us(me,d))},je=()=>{const d=Ys(D);oe({...D,[d]:{type:"stdio",command:"",args:[]}}),i(d),h(null),x(d)},Ke=d=>{d!==M&&x(null),i(d),h(null)},z=d=>{x(null),h(d)},te=d=>{const k=H.includes(d)?H:K,E=k.indexOf(d),_=k.filter(Z=>Z!==d),I={...D};delete I[d],oe(I),i(_[Math.min(E,_.length-1)]??null),x(null)},_e=(d,k)=>{if(!k||k===d||D[k])return;const E={};for(const _ of Object.keys(D))E[_===d?k:_]=D[_];oe(E),i(k),x(_=>_===d?k:_)},ce=(d,k)=>{oe({...D,[d]:k})},ye=[{label:"New server",testId:"mcp-new-server",onSelect:je}];return e&&ye.push({label:"Browse catalog…",testId:"mcp-browse-catalog",onSelect:()=>e({scope:t,cwd:l})}),s.jsxs("div",{ref:v,className:"h-full flex flex-col",children:[s.jsx(Ct,{filter:m,onFilterChange:g,placeholder:"Filter servers",summary:[...Ie,`${Be} checked`].join(" · "),primary:{label:"+ Add server",testId:"mcp-add-server",items:ye},children:s.jsx("button",{type:"button","data-testid":"mcp-check-all",onClick:()=>void $e(Re),disabled:Re.length===0||le,className:"shrink-0 h-7 inline-flex items-center px-[11px] bg-bg-hi border border-line rounded-md text-[12.5px] text-fg hover:border-rule disabled:opacity-50 disabled:hover:border-line",children:le?"Checking…":"Check all"})}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsxs(Te,{footer:W&&!O?s.jsx($t,{dirty:W.dirty,busy:W.busy,parseError:B||Ce||W.parseError,lastSavedAt:W.lastSavedAt,onSave:async()=>{var k;N(null);const d=((k=W.diskData)==null?void 0:k.mcpServers)??{};for(const[E,_]of Object.entries(D)){if(JSON.stringify(_)===JSON.stringify(d[E]))continue;const I=rt(_);if(I.length>0){Jt.getState().show("error",`Not saved: "${E}" still contains placeholder ${I.map(Z=>Z.token).join(", ")} — replace it with a real value`);return}}try{for(const E of Js(d,D))await window.api.claudeConfig.patch({...Qt(t,l),keyPath:["mcpServers",E.name],value:E.value});await w(p)}catch(E){N(E.message||"save failed")}},onRevert:()=>{N(null),A(p)},cleanLabel:`Saved — matches ${ie}`,shortcutHint:!0,scopeRef:v}):null,children:[t==="project"&&l&&s.jsx(Zs,{cwd:l,names:K}),s.jsx(St,{sidebarWidth:"300px",sidebar:s.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1",children:[s.jsxs("div",{"data-testid":"mcp-list-header",className:"flex items-center gap-2 mx-1.5 mt-3 mb-1 text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",children:[`In ${ie}`,s.jsx("span",{className:"font-mono font-medium tracking-normal text-fg-faint/60",children:H.length})]}),K.length===0?s.jsx("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:L.length>0?`No servers in ${ie} yet.`:"No servers yet."}):H.length===0?s.jsxs("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:["No servers match “",m.trim(),"”."]}):H.map(d=>{var we;const k=D[d],E=d===M,_=Ae(d),I=Le(d),Z=ue[Zt("mcp",t,d)]??Xt(Fe(d,k)).provenance,xe=rt(k).map(We=>We.token).join(", ");return s.jsxs("button",{type:"button","data-testid":`mcp-row-${d}`,"aria-current":E?"true":void 0,title:((we=k.description)==null?void 0:we.trim())||void 0,onClick:()=>Ke(d),className:`w-full text-left grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-x-2.5 px-2.5 py-1.5 rounded-[7px] border ${E?"bg-bg-hi border-line":"border-transparent hover:bg-bg-hi/60"}`,children:[s.jsx(pt,{result:_,checking:I,testId:`mcp-dot-${d}`}),s.jsx("span",{className:`truncate text-[13px] text-fg${E?" font-semibold":""}`,children:d}),s.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint/80",children:k.type??"stdio"}),s.jsxs("span",{"data-testid":`mcp-status-${d}`,className:"col-start-2 col-span-2 truncate text-[11px] text-fg-faint",children:[s.jsx("span",{className:zs[Z],children:es[Z]})," · ",I?"checking…":mt(_)]}),xe?s.jsxs("span",{className:"col-start-2 col-span-2 truncate text-[11px] text-honey-dark",title:`${t} scope · ${p} — replace ${xe} with a real value; Save refuses it until then`,children:["⚠ unconfigured placeholder: ",xe]}):null]},d)}),L.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"mcp-plugins-header",className:"flex items-center gap-2 mx-1.5 mt-3 mb-1 text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",children:["From plugins",s.jsx("span",{"data-testid":"mcp-plugins-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:V.length}),s.jsx("span",{"data-testid":"mcp-plugins-readonly",className:"ml-auto px-[5px] border border-line rounded-[3px] text-[9.5px] font-medium tracking-normal text-fg-faint/80",children:"READ-ONLY"})]}),V.length===0?s.jsxs("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:["No plugin servers match “",m.trim(),"”."]}):V.map(d=>{const k=(O==null?void 0:O.id)===d.id,E=fe(d),_=ae[E],I=ee[E]===!0;return s.jsxs("button",{type:"button","data-testid":`mcp-plugin-row-${d.id}`,"aria-current":k?"true":void 0,onClick:()=>z(d.id),className:`w-full text-left grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-x-2.5 px-2.5 py-1.5 rounded-[7px] border ${k?"bg-bg-hi border-line":"border-transparent hover:bg-bg-hi/60"}`,children:[s.jsx(pt,{result:_,checking:I,testId:`mcp-plugin-dot-${d.id}`}),s.jsx("span",{className:`truncate text-[13px] text-fg${k?" font-semibold":""}`,children:d.name}),s.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint/80",children:"plugin"}),s.jsxs("span",{"data-testid":`mcp-plugin-status-${d.id}`,className:"col-start-2 col-span-2 truncate text-[11px] text-fg-faint",children:["via the ",d.plugin," plugin · ",I?"checking…":mt(_)]})]},d.id)})]}):null]}),detail:O?s.jsx(ot,{name:O.name,server:O.server,scope:"user",plugin:O.plugin,checkRequest:Ve(O),provenance:Fe(O.name,O.server)},`plugin:${O.id}`):M!==null?s.jsx(ot,{name:M,server:D[M],scope:t,fileLabel:ie,checkRequest:pe(M),provenance:Fe(M,D[M]),onChange:d=>ce(M,d),editing:u===M,onEditingChange:d=>x(d?M:null),editor:u===M?s.jsx(Qs,{name:M,server:D[M],scope:t,onRename:d=>_e(M,d),onChange:d=>ce(M,d),onRemove:()=>te(M)}):null},M):s.jsx(ne,{title:"No MCP servers yet",hint:e?"+ Add server starts a new one or browses the catalog.":"+ Add server starts a new one."})})]})})]})}const Cn=f.memo(Gs);function Qs({name:e,server:t,scope:n,onRename:a,onChange:l,onRemove:r}){var v;const i=t.type??"stdio",o=Bs.has(e),h=Ks.has(e),m=(v=t.permissions)==null?void 0:v.tools,g=m===void 0?"inherit":m==="allow"?"allow":m==="deny"?"deny":"list",u=Array.isArray(m)?m:[],x=(t.disabledTools??[]).join(", ");return s.jsxs("div",{"data-testid":"mcp-json-form",className:"space-y-4 max-w-2xl",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-fg-faint w-20",children:"origin"}),s.jsx(Qe,{scope:n,input:Fe(e,t)}),s.jsx("span",{className:"text-xs text-fg-faint",children:"click to change"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),s.jsx("input",{"aria-label":"Server name",defaultValue:e,onBlur:p=>a(p.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),s.jsx("button",{onClick:r,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),s.jsx(Ne,{label:"description",value:t.description??"",onChange:p=>l({...t,description:p||void 0}),placeholder:"what this server does…"}),o?s.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",s.jsx("span",{className:"font-mono",children:e})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):h?s.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",s.jsx("span",{className:"font-mono",children:e})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),s.jsx("select",{value:i,onChange:p=>l({...t,type:p.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:Is.map(p=>s.jsx("option",{value:p,children:p},p))}),i==="sse"?s.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),i==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(Ne,{label:"command",value:t.command??"",onChange:p=>l({...t,command:p}),placeholder:"npx / node / python …"}),s.jsx(Ne,{label:"args",value:(t.args??[]).join(" "),onChange:p=>l({...t,args:p.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),s.jsx(ft,{label:"env",value:t.env??{},onChange:p=>l({...t,env:p})})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ne,{label:"url",value:t.url??"",onChange:p=>l({...t,url:p}),placeholder:"https://…"}),s.jsx(ft,{label:"headers",value:t.headers??{},onChange:p=>l({...t,headers:p})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[s.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:p=>l({...t,alwaysLoad:p.target.checked||void 0})}),s.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),s.jsx(Ne,{label:"disabledTools",value:x,onChange:p=>{const b=p.split(",").map(w=>w.trim()).filter(Boolean);l({...t,disabledTools:b.length?b:void 0})},placeholder:"comma-separated tool names to hide"}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsxs("select",{value:g,onChange:p=>{const b=p.target.value,w={...t};if(b==="inherit"){if(w.permissions){const{tools:C,...A}=w.permissions;w.permissions=Object.keys(A).length?A:void 0}}else b==="list"?w.permissions={...w.permissions??{},tools:[]}:w.permissions={...w.permissions??{},tools:b};l(w)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[s.jsx("option",{value:"inherit",children:"inherit (default)"}),s.jsx("option",{value:"allow",children:"allow all tools"}),s.jsx("option",{value:"deny",children:"deny all tools"}),s.jsx("option",{value:"list",children:"allowlist…"})]}),g==="list"?s.jsx("input",{value:u.join(", "),onChange:p=>{const b=p.target.value.split(",").map(w=>w.trim()).filter(Boolean);l({...t,permissions:{...t.permissions??{},tools:b}})},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:e,value:t,onChange:n,placeholder:a}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:e}),s.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 ft({label:e,value:t,onChange:n}){const[a,l]=f.useState(""),[r,i]=f.useState(""),o=Object.entries(t);return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:e}),s.jsxs("div",{className:"flex-1 space-y-1",children:[o.map(([h,m])=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:h,onChange:g=>{const u={...t};delete u[h],u[g.target.value]=m,n(u)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),s.jsx("input",{value:m,onChange:g=>n({...t,[h]:g.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),s.jsx("button",{onClick:()=>{const g={...t};delete g[h],n(g)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},h)),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:a,onChange:h=>l(h.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"}),s.jsx("input",{value:r,onChange:h=>i(h.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"}),s.jsx("button",{onClick:()=>{a.trim()&&(n({...t,[a.trim()]:r}),l(""),i(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}function Zs({cwd:e,names:t}){const n={fileId:"settings",scope:"project",cwd:e},[a,l]=f.useState([]),[r,i]=f.useState(!1),[o,h]=f.useState(!1);f.useEffect(()=>{var p,b;let u=!0;const x=()=>window.api.claudeConfig.read(n).then(w=>{if(!u)return;const C=w.data;l(Array.isArray(C==null?void 0:C.disabledMcpjsonServers)?C.disabledMcpjsonServers:[]),i((C==null?void 0:C.enableAllProjectMcpServers)===!0)}).catch(()=>{});x();const v=(b=(p=window.api.config)==null?void 0:p.onChanged)==null?void 0:b.call(p,()=>{x()});return()=>{u=!1,v==null||v()}},[e]);const m=async(u,x)=>{h(!0);try{await window.api.claudeConfig.patch({...n,keyPath:[u],value:x})}catch(v){q.error(v.message||"save failed")}finally{h(!1)}},g=async(u,x)=>{const v=x?a.filter(p=>p!==u):[...new Set([...a,u])];l(v),await m("disabledMcpjsonServers",v.length?v:void 0)};return s.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:[s.jsxs("span",{children:["Gating · ",e,"/.claude/settings.json"]}),s.jsxs("label",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"checkbox","data-testid":"mcp-enable-all",checked:r,disabled:o,onChange:u=>{i(u.target.checked),m("enableAllProjectMcpServers",u.target.checked?!0:void 0)}}),"enableAllProjectMcpServers"]}),t.map(u=>s.jsxs("label",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"checkbox","data-testid":`mcp-gate-${u}`,checked:!a.includes(u),disabled:o,onChange:x=>g(u,x.target.checked)}),u]},u))]})}function Xs({value:e,onChange:t,path:n,readOnly:a,theme:l="dark"}){const r=l==="paper";return s.jsx(Yt,{path:`file://${n}`,defaultLanguage:"markdown",value:e,onChange:i=>t(i??""),beforeMount:r?zt:void 0,theme:r?Vt:"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 Pe="h-4 inline-flex items-center px-1.5 bg-bg-elev border border-line rounded-[3px] text-[10px] tracking-[0.04em] text-fg-dim",ze="text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",en=["prose-chat max-w-[720px] px-[26px] py-4 text-[14px] leading-[1.6] text-fg","[&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_h4]:font-serif","[&_h1]:text-[24px] [&_h2]:text-[20px] [&_h3]:text-[18px] [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold","[&_h1]:mb-1.5 [&_h2]:mb-1.5 [&_h3]:mb-1.5 [&_p]:mb-3.5 [&_ul]:mb-3.5 [&_ul]:pl-5 [&_ul]:list-disc [&_ol]:pl-5 [&_ol]:list-decimal","[&_pre]:!bg-bg-elev [&_code]:!bg-bg-elev"].join(" ");function tn(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function xt({item:e,home:t,draft:n,dirty:a,busy:l,lastSavedAt:r,saveError:i,onDraftChange:o,onSave:h,onRevert:m,readOnly:g=!1}){const u=f.useRef(null),[x,v]=f.useState("source"),p=f.useMemo(()=>ws(n),[n]),b=f.useMemo(()=>_s(n)??"",[n]),w=f.useMemo(()=>x==="preview"?qt(p.body):"",[x,p.body]),C=(A,J)=>{const P=x===A;return s.jsx("button",{type:"button","data-testid":`skill-view-${A}`,"aria-pressed":P,onClick:()=>v(A),className:`h-6 inline-flex items-center px-[11px] rounded-[5px] text-xs ${P?"bg-bg-hi shadow-sm font-semibold text-fg":"text-fg-faint hover:text-fg"}`,children:J})};return s.jsxs("div",{ref:u,"data-testid":"skill-detail",className:"h-full min-h-0 flex flex-col",children:[s.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-[22px] pt-4",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs("span",{"data-testid":"skill-detail-name",className:"min-w-0 truncate font-mono text-[18px] font-semibold text-fg",children:["/",e.name]}),s.jsx("span",{"data-testid":"skill-detail-kind",className:Pe,children:e.kind==="commands"?"COMMAND":"SKILL"}),e.plugin?s.jsxs("span",{"data-testid":"skill-detail-plugin",className:Pe,children:["from ",e.plugin]}):s.jsx("span",{"data-testid":"skill-detail-scope",className:Pe,children:e.scope.toUpperCase()}),g&&s.jsx("span",{"data-testid":"skill-detail-readonly",className:Pe,children:"READ-ONLY"}),s.jsxs("div",{role:"group","aria-label":"View",className:"ml-auto flex gap-0.5 p-0.5 bg-bg-elev border border-line rounded-[7px]",children:[C("source","Source"),C("preview","Preview")]})]}),s.jsxs("div",{className:"grid grid-cols-[84px_minmax(0,1fr)] items-baseline gap-x-3 gap-y-2.5 mt-3.5",children:[g?s.jsx("span",{className:ze,children:"Description"}):s.jsx("label",{htmlFor:`skill-desc-${e.path}`,className:ze,children:"Description"}),g?s.jsx("span",{id:`skill-desc-${e.path}`,"data-testid":"skill-detail-description-text",className:"text-[13px] leading-[1.45] text-fg-dim",children:b||s.jsx("span",{className:"text-fg-faint",children:"No description"})}):s.jsx("input",{id:`skill-desc-${e.path}`,"data-testid":"skill-detail-description",type:"text",value:b,onChange:A=>o(As(n,A.target.value)),placeholder:"What this does and when Claude should use it",className:"px-2.5 py-[7px] bg-bg-hi border border-line rounded-md text-[13px] leading-[1.45] text-fg outline-none focus:border-accent"}),s.jsx("span",{className:ze,children:"File"}),s.jsxs("div",{className:"min-w-0 flex items-baseline gap-3 text-xs",children:[s.jsx("span",{"data-testid":"skill-detail-path",title:e.path,className:"min-w-0 truncate font-mono text-[11.5px] text-fg-dim",children:tn(e.path,t)}),s.jsx("button",{type:"button","data-testid":"skill-detail-reveal",onClick:()=>Gt(e.path),className:"shrink-0 font-medium text-accent hover:underline",children:"Reveal in File Explorer"})]})]}),s.jsx("div",{className:"flex-1 min-h-0 mt-3.5 border border-line border-b-0 rounded-t-[7px] bg-bg-hi overflow-hidden",children:x==="source"?s.jsx(Xs,{path:e.path,theme:"paper",value:p.body,readOnly:g,onChange:A=>{g||o(Ns(p.frontmatter,A))}}):s.jsx("div",{className:"h-full overflow-auto",children:s.jsx("div",{"data-testid":"skill-preview",className:en,dangerouslySetInnerHTML:{__html:w}})})})]}),!g&&s.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:s.jsx($t,{dirty:a,busy:l,parseError:i,lastSavedAt:r,onSave:h,onRevert:m,cleanLabel:"Saved — matches the file on disk",shortcutHint:!0,scopeRef:u})})]})}const ht=e=>e instanceof Error?e.message:String(e),gt=(e,t,n)=>`${e} ${e===1?t:n}`,bt=(e,t)=>e.name.localeCompare(t.name);async function sn(e,t){const[n,{manifest:a}]=await Promise.all([Pt(t),tt(t)]),[l,r]=await Promise.all([n?Mt(n):Promise.resolve([]),Ot(t,a)]),i=await Os(r.commandFiles);return[...l.map(o=>({kind:"skills",plugin:e,name:o.name??o.id,path:o.path,description:o.description??void 0})).sort(bt),...i.map(o=>({kind:"commands",plugin:e,name:o.name??o.id,path:o.id,description:o.description??void 0})).sort(bt)]}function nn(e,t){const[n,a]=f.useState([]),l=f.useRef(0),r=f.useCallback(async()=>{const i=++l.current;if(!t){a([]);return}let o=[];try{const h=(await window.api.plugins.list()).filter(m=>m.enabled&&m.installPath);o=await Promise.all(h.map(async m=>{try{return{key:m.key,name:m.name,items:await sn(m.name,m.installPath)}}catch(g){return{key:m.key,name:m.name,items:[],error:ht(g)}}}))}catch(h){console.warn(`[skills] could not list plugins: ${ht(h)}`)}l.current===i&&(o.sort((h,m)=>h.name.localeCompare(m.name)),a(o))},[t]);return f.useEffect(()=>{r()},[r]),f.useEffect(()=>()=>{l.current+=1},[]),Nt(t&&e?[`${e}/.claude/plugins/installed_plugins.json`,`${e}/.claude/settings.json`]:[],()=>{r()}),n}function an(e){const t=e.filter(a=>a.kind==="skills").length,n=e.length-t;return[t?gt(t,"skill","skills"):"",n?gt(n,"command","commands"):""].filter(Boolean).join(" · ")}function rn({open:e}){return s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-faint/60 transition-transform ${e?"rotate-90":""}`,"aria-hidden":!0,children:s.jsx("path",{d:"m9 18 6-6-6-6"})})}function ln({plugins:e,needle:t,selectedPath:n,onSelect:a}){const[l,r]=f.useState(()=>new Set),i=e.map(m=>{if(!t||m.name.toLowerCase().includes(t))return{p:m,items:m.items};const g=m.items.filter(u=>{var x;return u.name.toLowerCase().includes(t)||!!((x=u.description)!=null&&x.toLowerCase().includes(t))});return{p:m,items:g}}).filter(({p:m,items:g})=>!t||g.length>0||m.name.toLowerCase().includes(t)),o=i.reduce((m,g)=>m+g.items.length,0),h=m=>r(g=>{const u=new Set(g);return u.has(m)?u.delete(m):u.add(m),u});return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"skills-section-plugins",className:"flex items-center gap-2 mt-3 mx-1.5 mb-1 text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",children:["From plugins",s.jsx("span",{"data-testid":"skills-section-plugins-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:o}),s.jsx("span",{"data-testid":"skills-section-plugins-readonly",title:"Plugin files are managed by the plugin — open them to read, not edit",className:"ml-auto px-[5px] border border-line rounded-[3px] text-[9.5px] font-medium tracking-normal text-fg-faint",children:"READ-ONLY"})]}),e.length===0&&s.jsx("div",{className:"mx-1.5 mb-1 text-xs text-fg-faint",children:"No enabled plugin adds skills or commands"}),i.map(({p:m,items:g})=>{const u=!m.error&&(l.has(m.key)||!!t&&g.length>0);return s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("button",{type:"button","data-testid":"plugin-skills-row","data-plugin":m.name,"aria-expanded":u,onClick:()=>h(m.key),className:"flex items-center gap-2 px-2.5 py-[7px] border border-transparent rounded-[7px] text-left text-[12.5px] text-fg-dim hover:bg-bg-hi",children:[s.jsx("span",{className:"min-w-0 truncate",children:m.name}),m.error?s.jsx("span",{"data-testid":"plugin-skills-row-error",title:m.error,className:"ml-auto shrink-0 text-[11px] text-red-400",children:"Could not read plugin"}):s.jsx("span",{"data-testid":"plugin-skills-row-counts",className:"ml-auto shrink-0 font-mono text-[11px] text-fg-faint",children:an(m.items)||"nothing to list"}),s.jsx(rn,{open:u})]}),u&&g.map(x=>{const v=n===x.path;return s.jsxs("button",{type:"button","data-testid":"plugin-skills-item","data-path":x.path,"aria-current":v?"true":void 0,onClick:()=>a(x.path),className:`ml-3 mb-0.5 flex flex-col gap-[2px] px-2.5 py-1.5 border rounded-[7px] text-left ${v?"border-accent bg-bg-hi":"border-transparent hover:bg-bg-hi"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsxs("span",{"data-testid":"plugin-skills-item-name",className:"min-w-0 truncate font-mono text-[12px] font-semibold text-fg",children:["/",x.name]}),s.jsx("span",{className:"ml-auto shrink-0 text-[9.5px] tracking-[0.04em] text-fg-faint",children:x.kind==="commands"?"COMMAND":"SKILL"})]}),x.description&&s.jsx("span",{title:x.description,className:"truncate text-[11px] text-fg-faint",children:x.description})]},x.path)})]},m.key)})]})}const on=250,cn=2e3,dn=6;function un(e,t){return{user:{skills:`${e}/.claude/skills`,commands:`${e}/.claude/commands`},project:t?{skills:`${t}/.claude/skills`,commands:`${t}/.claude/commands`}:null}}const De=e=>e instanceof Error?e.message:String(e);async function mn(e,t){const n=e.map(()=>{});let a=0;const l=async()=>{for(let r=a++;r<e.length;r=a++)try{const i=await window.api.config.readText(e[r]);i.error?t.push({path:e[r],error:i.error}):i.exists&&(n[r]=Oe(i.text).description??void 0)}catch(i){t.push({path:e[r],error:De(i)})}};return await Promise.all(Array.from({length:Math.min(dn,e.length)},l)),n}const pn=/^[a-z0-9][a-z0-9-]{0,63}$/,fn="Use lowercase letters, digits and hyphens (max 64), starting with a letter or digit",xn=(e,t)=>e==="skills"?["---",`name: ${t}`,'description: ""',"---","",`# ${t}`,""].join(`
22
+ `;return`---${x}${n}${x}---${x}${e}`}const{open:l,lines:r,texts:i,pad:o,rest:h}=a,[m,...g]=Ge(a,_t);if(m){for(const x of g.reverse())r.splice(x.start,x.end-x.start);const u=r[m.start];r.splice(m.start,m.end-m.start,u.slice(0,de(u))+n+dt(u))}else{const[u]=Ge(a,js);let x=u?u.end:i.length;if(!u)for(;x>0&&i[x-1].trim()==="";)x--;r.splice(x,0,o+n+dt(x>0?r[x-1]:l))}return l+r.join("")+h}const Ls={0:"\0",a:"\x07",b:"\b",t:" "," ":" ",n:`
23
+ `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function _s(e){const t=e.trim(),n=/^"((?:[^"\\]|\\[\s\S])*)"/.exec(t);if(n)return n[1].replace(/\\(x[\da-fA-F]{2}|u[\da-fA-F]{4}|U[\da-fA-F]{8}|[\s\S])/g,(r,i)=>{if(i.length===1)return Ls[i]??r;const o=parseInt(i.slice(1),16);return o<=1114111?String.fromCodePoint(o):r});const a=/^'((?:[^']|'')*)'/.exec(t);if(a)return a[1].replace(/''/g,"'");const l=t.search(/(?:^|\s)#/);return l===-1?t:t.slice(0,l).trimEnd()}function Rs(e){const t=Rt(e),n=t?Ge(t,_t)[0]:void 0;if(!t||!n)return null;const[a,...l]=t.texts.slice(n.start,n.end),r=a.slice(a.indexOf(":")+1).trim().replace(/^#.*/,""),i=l.map(o=>o.trim()).filter(Boolean);return ys.test(r)?i.join(" "):_s([r,...i].join(" "))}async function Pt(e){const t=`${e}/skills`;return await window.api.config.exists(t)?t:null}async function Mt(e){const{entries:t}=await jt(e,{nested:!1});return t.map(n=>{const a=Oe(n.text);return{id:n.name,name:a.name,description:a.description,dir:n.dir,path:n.path,body:a.body}})}function wn(e){const t=[],n=new Set;for(const a of e)for(const l of e){if(a.id===l.id)continue;const r=l.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=[`/${r}\\b`,`\`${r}\``];if(l.id.length>=4&&i.push(`\\b${r}\\b`),!i.some(m=>new RegExp(m,"i").test(a.body)))continue;const h=`${a.id}->${l.id}`;n.has(h)||(n.add(h),t.push({from:a.id,to:l.id}))}return t}function Nn(e,t){return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,mcpServers:0,error:t}}async function Sn(e){const{hasManifest:t,manifest:n}=await tt(e.path),[a,l]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let r=0;if(l){const u=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(u.data)?r=u.data.length:u.data&&typeof u.data=="object"&&Array.isArray(u.data.monitors)&&(r=u.data.monitors.length)}const[i,o,h]=await Promise.all([Ot(e.path,n),It(`${e.path}/bin`,{filesOnly:!0}),Pt(e.path)]),m=o.length,g=h?(await Mt(h)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:t,manifest:n,hasLsp:a,monitors:r,hooks:i.hooks,agents:i.agentFiles.length,commands:i.commandFiles.length,skills:g,binCount:m,hasMcp:i.mcpServers.length>0,mcpServers:i.mcpServers.length}}function $n(e){return{skills:e.skills,commands:e.commands,agents:e.agents,hooks:e.hooks,mcpServers:e.mcpServers}}async function tt(e){let t=`${e}/.claude-plugin/plugin.json`,n=await window.api.config.exists(t);if(n||(t=`${e}/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 Q=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Ps(e,t){const n=t.startsWith("/")?t.startsWith(`${e}/`)?t.slice(e.length+1):null:t;if(n===null)return ut(t);const a=[];for(const l of n.split("/"))if(!(l===""||l===".")){if(l!=="..")a.push(l);else if(a.pop()===void 0)return ut(t)}return a.length>0?`${e}/${a.join("/")}`:e}function ut(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Ms(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Fs(e){if(!Q(e))return null;if(Q(e.mcpServers))return e.mcpServers;const t=Object.values(e);return t.length>0&&t.every(a=>Q(a)&&(typeof a.command=="string"||typeof a.url=="string"))?e:null}function Ds(e){if(!Q(e))return 0;const t=Q(e.hooks)?e.hooks:e;return Object.values(t).reduce((n,a)=>Array.isArray(a)?n+a.reduce((l,r)=>l+(Q(r)&&Array.isArray(r.hooks)?r.hooks.length:0),0):n,0)}function Me(e,t,n){const a=new Set;for(const l of Ms(t)){const r=Ps(e,l);r&&a.add(r)}return a.add(`${e}/${n}`),[...a]}async function Ft(e){try{const t=await window.api.config.readJson(e);return t.exists&&!t.parseError?t.data:null}catch{return null}}function Dt(e,t){return Me(e,typeof t=="string"||Array.isArray(t)?t:void 0,".mcp.json")}async function Tt(e,t){const n=await Promise.all(t.map(Ft)),a=new Map;for(const l of[...Q(e)?[e]:[],...n])for(const[r,i]of Object.entries(Fs(l)??{})){if(a.has(r))continue;const o=Q(i)?i.command:void 0,h=Q(i)?i.url:void 0;a.set(r,{id:r,name:r,description:typeof o=="string"?o:typeof h=="string"?h:null})}return[...a.values()]}async function Ot(e,t){const n=async p=>{const b=new Set;for(const w of p)if(w.endsWith(".md"))b.add(w);else for(const C of await It(w,{filesOnly:!0}))C.endsWith(".md")&&b.add(`${w}/${C}`);return[...b]},a=Me(e,t==null?void 0:t.commands,"commands"),l=Me(e,t==null?void 0:t.agents,"agents"),r=t==null?void 0:t.hooks,i=Me(e,typeof r=="string"||Array.isArray(r)?r:void 0,"hooks/hooks.json"),o=t==null?void 0:t.mcpServers,h=Dt(e,o),[m,g,u,x]=await Promise.all([n(a),n(l),Promise.all(i.map(Ft)),Tt(o,h)]),v=[...Q(r)?[r]:[],...u].reduce((p,b)=>p+Ds(b),0);return{commandFiles:m,agentFiles:g,hooks:v,mcpServers:x,sourcePaths:[...a,...l,...i,...h]}}async function Ts(e){const{manifest:t}=await tt(e),n=t==null?void 0:t.mcpServers;return Tt(n,Dt(e,n))}async function Os(e){const t=await Promise.all(e.map(a=>window.api.config.readText(a))),n=[];return e.forEach((a,l)=>{if(!t[l].exists)return;const r=a.slice(a.lastIndexOf("/")+1),i=Oe(t[l].text);n.push({id:a,name:i.name??r.replace(/\.md$/,""),description:i.description})}),n}async function It(e,t){try{return(await window.api.config.listDir(e,t)).entries.map(a=>a.name)}catch{return[]}}const Fe=(e,t)=>({type:"mcp",name:e,command:t.command,args:t.args,url:t.url}),Is=["stdio","http","streamable-http","sse","ws"],Bs=new Set(["workspace"]),Ks=new Set(["ide","tasks"]);function Ws(e,t,n){return e==="user"?`${t}/.claude.json`:n?`${n}/.mcp.json`:null}function Hs(e){if(e.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(e),n=t.mcpServers??{};return{full:t,servers:n,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Us(e,t){const n={};for(const[a,l]of Object.entries(t)){const{enabled:r,...i}=l;n[a]=i}return JSON.stringify({...e,mcpServers:n},null,2)+`
24
+ `}function Js(e,t){const n=[];for(const[a,l]of Object.entries(t)){if(JSON.stringify(l)===JSON.stringify(e[a]))continue;const{enabled:r,...i}=l;n.push({name:a,value:i})}for(const a of Object.keys(e))a in t||n.push({name:a,value:void 0});return n}function Ys(e){let t=Object.keys(e).length+1,n=`server-${t}`;for(;e[n];)t+=1,n=`server-${t}`;return n}const Ve=e=>({source:"plugin",name:e.name,pluginKey:e.pluginKey});async function Vs(){var r,i;const t=(await((i=(r=window.api.plugins)==null?void 0:r.list)==null?void 0:i.call(r))??[]).filter(o=>o.enabled&&!!o.installPath),n=await Promise.allSettled(t.map(o=>Ts(o.installPath))),a=[],l=[];return n.forEach((o,h)=>{const m=t[h];if(o.status==="rejected"){l.push(m.name);return}for(const g of o.value){const u=g.description??"",x=/^[a-z][a-z0-9+.-]*:\/\//i.test(u)?{type:"http",url:u}:{command:u||void 0};a.push({id:`${m.key}/${g.name}`,pluginKey:m.key,plugin:m.name,name:g.name,server:x})}}),l.length>0&&q.error(`Could not read the MCP servers of plugin ${l.join(", ")}`),a.sort((o,h)=>o.plugin.localeCompare(h.plugin)||o.name.localeCompare(h.name))}const zs={anthropic:"text-accent-dark",community:"text-honey-dark",local:""};function mt(e){if(!e)return"not checked";if(e.status==="connected"){const t=e.tools.length;return`connected · ${t} tool${t===1?"":"s"}`}return e.status==="needs-auth"?"needs auth":"failed"}function qs(e,t,n){return e==="user"?{source:"user",name:n}:t?{source:"project",name:n,cwd:t}:null}function pt({result:e,checking:t,testId:n}){const a=(e==null?void 0:e.status)??"unchecked";return s.jsx("span",{"aria-hidden":"true","data-testid":n,"data-status":a,title:e&&!e.ok?`${qe[a]}: ${e.error}`:qe[a],className:`w-2 h-2 shrink-0 box-border rounded-full ${Et[a]}${t?" animate-pulse":""}`})}function Gs({onAdd:e,scope:t="user"}={}){const n=yt(),a=wt(),l=(a==null?void 0:a.cwd)??null,[r,i]=f.useState(null),[o,h]=f.useState(null),[m,g]=f.useState(""),[u,x]=f.useState(null),v=f.useRef(null),p=f.useMemo(()=>n?Ws(t,n,l):null,[n,t,l]),b=T(d=>d.files),w=T(d=>d.loadJson),C=T(d=>d.setDraft),A=T(d=>d.revert),J=T(d=>d.watchFile),P=T(d=>d.unwatchFile);f.useEffect(()=>{if(p)return b[p]||w(p),J(p),()=>P(p)},[p]);const[B,N]=f.useState(null),[L,G]=f.useState([]);f.useEffect(()=>{if(t!=="user"){G([]);return}let d=!0;return Vs().then(k=>{d&&G(k)}).catch(k=>{d&&q.error(`Could not list plugin MCP servers: ${k instanceof Error?k.message:String(k)}`)}),()=>{d=!1}},[t]);const ae=ve(rs),ee=ve(ls),$e=ve(d=>d.checkAll),ue=lt(d=>d.overrides),_=lt(d=>d.load);if(f.useEffect(()=>{n&&_(n)},[n,_]),!n)return s.jsx(ne,{title:"loading…"});if(t==="project"&&!l)return s.jsx(Te,{toolbar:s.jsx(s.Fragment,{}),children:s.jsx(ne,{title:"no active project"})});if(!p)return s.jsx(ne,{title:"loading…"});const W=b[p],{full:me,servers:D,err:Ce}=W?Hs(W.draftRaw):{full:{},servers:{},err:null},K=Object.keys(D).sort(),Y=m.trim().toLowerCase(),H=Y?K.filter(d=>d.toLowerCase().includes(Y)):K,V=Y?L.filter(d=>d.name.toLowerCase().includes(Y)):L,ke=o!==null?L.find(d=>d.id===o)??null:null,Ee=r!==null&&K.includes(r)?r:null,re=H[0]??(V.length>0?null:K[0]??null),O=ke??(Ee===null&&re===null?V[0]??L[0]??null:null),M=O?null:Ee??re,pe=d=>qs(t,l,d),Ae=d=>{const k=pe(d);return k?ae[be(k)]:void 0},Le=d=>{const k=pe(d);return k?ee[be(k)]===!0:!1},fe=d=>be(Ve(d)),_e=[...H.map(pe).filter(d=>d!==null),...V.map(Ve)],Ie=[`${K.length} server${K.length===1?"":"s"}`,...L.length>0?[`${L.length} from plugins`]:[]],Be=K.filter(d=>Ae(d)!==void 0).length+L.filter(d=>ae[fe(d)]!==void 0).length,le=H.some(Le)||V.some(d=>ee[fe(d)]===!0),ie=t==="user"?"~/.claude.json":".mcp.json",oe=d=>{N(null),C(p,Us(me,d))},je=()=>{const d=Ys(D);oe({...D,[d]:{type:"stdio",command:"",args:[]}}),i(d),h(null),x(d)},Ke=d=>{d!==M&&x(null),i(d),h(null)},z=d=>{x(null),h(d)},te=d=>{const k=H.includes(d)?H:K,E=k.indexOf(d),R=k.filter(Z=>Z!==d),I={...D};delete I[d],oe(I),i(R[Math.min(E,R.length-1)]??null),x(null)},Re=(d,k)=>{if(!k||k===d||D[k])return;const E={};for(const R of Object.keys(D))E[R===d?k:R]=D[R];oe(E),i(k),x(R=>R===d?k:R)},ce=(d,k)=>{oe({...D,[d]:k})},ye=[{label:"New server",testId:"mcp-new-server",onSelect:je}];return e&&ye.push({label:"Browse catalog…",testId:"mcp-browse-catalog",onSelect:()=>e({scope:t,cwd:l})}),s.jsxs("div",{ref:v,className:"h-full flex flex-col",children:[s.jsx(Ct,{filter:m,onFilterChange:g,placeholder:"Filter servers",summary:[...Ie,`${Be} checked`].join(" · "),primary:{label:"+ Add server",testId:"mcp-add-server",items:ye},children:s.jsx("button",{type:"button","data-testid":"mcp-check-all",onClick:()=>void $e(_e),disabled:_e.length===0||le,className:"shrink-0 h-7 inline-flex items-center px-[11px] bg-bg-hi border border-line rounded-md text-[12.5px] text-fg hover:border-rule disabled:opacity-50 disabled:hover:border-line",children:le?"Checking…":"Check all"})}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsxs(Te,{footer:W&&!O?s.jsx($t,{dirty:W.dirty,busy:W.busy,parseError:B||Ce||W.parseError,lastSavedAt:W.lastSavedAt,onSave:async()=>{var k;N(null);const d=((k=W.diskData)==null?void 0:k.mcpServers)??{};for(const[E,R]of Object.entries(D)){if(JSON.stringify(R)===JSON.stringify(d[E]))continue;const I=rt(R);if(I.length>0){Jt.getState().show("error",`Not saved: "${E}" still contains placeholder ${I.map(Z=>Z.token).join(", ")} — replace it with a real value`);return}}try{for(const E of Js(d,D))await window.api.claudeConfig.patch({...Qt(t,l),keyPath:["mcpServers",E.name],value:E.value});await w(p)}catch(E){N(E.message||"save failed")}},onRevert:()=>{N(null),A(p)},cleanLabel:`Saved — matches ${ie}`,shortcutHint:!0,scopeRef:v}):null,children:[t==="project"&&l&&s.jsx(Zs,{cwd:l,names:K}),s.jsx(St,{sidebarWidth:"300px",sidebar:s.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1",children:[s.jsxs("div",{"data-testid":"mcp-list-header",className:"flex items-center gap-2 mx-1.5 mt-3 mb-1 text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",children:[`In ${ie}`,s.jsx("span",{className:"font-mono font-medium tracking-normal text-fg-faint/60",children:H.length})]}),K.length===0?s.jsx("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:L.length>0?`No servers in ${ie} yet.`:"No servers yet."}):H.length===0?s.jsxs("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:["No servers match “",m.trim(),"”."]}):H.map(d=>{var we;const k=D[d],E=d===M,R=Ae(d),I=Le(d),Z=ue[Zt("mcp",t,d)]??Xt(Fe(d,k)).provenance,xe=rt(k).map(We=>We.token).join(", ");return s.jsxs("button",{type:"button","data-testid":`mcp-row-${d}`,"aria-current":E?"true":void 0,title:((we=k.description)==null?void 0:we.trim())||void 0,onClick:()=>Ke(d),className:`w-full text-left grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-x-2.5 px-2.5 py-1.5 rounded-[7px] border ${E?"bg-bg-hi border-line":"border-transparent hover:bg-bg-hi/60"}`,children:[s.jsx(pt,{result:R,checking:I,testId:`mcp-dot-${d}`}),s.jsx("span",{className:`truncate text-[13px] text-fg${E?" font-semibold":""}`,children:d}),s.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint/80",children:k.type??"stdio"}),s.jsxs("span",{"data-testid":`mcp-status-${d}`,className:"col-start-2 col-span-2 truncate text-[11px] text-fg-faint",children:[s.jsx("span",{className:zs[Z],children:es[Z]})," · ",I?"checking…":mt(R)]}),xe?s.jsxs("span",{className:"col-start-2 col-span-2 truncate text-[11px] text-honey-dark",title:`${t} scope · ${p} — replace ${xe} with a real value; Save refuses it until then`,children:["⚠ unconfigured placeholder: ",xe]}):null]},d)}),L.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"mcp-plugins-header",className:"flex items-center gap-2 mx-1.5 mt-3 mb-1 text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",children:["From plugins",s.jsx("span",{"data-testid":"mcp-plugins-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:V.length}),s.jsx("span",{"data-testid":"mcp-plugins-readonly",className:"ml-auto px-[5px] border border-line rounded-[3px] text-[9.5px] font-medium tracking-normal text-fg-faint/80",children:"READ-ONLY"})]}),V.length===0?s.jsxs("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:["No plugin servers match “",m.trim(),"”."]}):V.map(d=>{const k=(O==null?void 0:O.id)===d.id,E=fe(d),R=ae[E],I=ee[E]===!0;return s.jsxs("button",{type:"button","data-testid":`mcp-plugin-row-${d.id}`,"aria-current":k?"true":void 0,onClick:()=>z(d.id),className:`w-full text-left grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-x-2.5 px-2.5 py-1.5 rounded-[7px] border ${k?"bg-bg-hi border-line":"border-transparent hover:bg-bg-hi/60"}`,children:[s.jsx(pt,{result:R,checking:I,testId:`mcp-plugin-dot-${d.id}`}),s.jsx("span",{className:`truncate text-[13px] text-fg${k?" font-semibold":""}`,children:d.name}),s.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint/80",children:"plugin"}),s.jsxs("span",{"data-testid":`mcp-plugin-status-${d.id}`,className:"col-start-2 col-span-2 truncate text-[11px] text-fg-faint",children:["via the ",d.plugin," plugin · ",I?"checking…":mt(R)]})]},d.id)})]}):null]}),detail:O?s.jsx(ot,{name:O.name,server:O.server,scope:"user",plugin:O.plugin,checkRequest:Ve(O),provenance:Fe(O.name,O.server)},`plugin:${O.id}`):M!==null?s.jsx(ot,{name:M,server:D[M],scope:t,fileLabel:ie,checkRequest:pe(M),provenance:Fe(M,D[M]),onChange:d=>ce(M,d),editing:u===M,onEditingChange:d=>x(d?M:null),editor:u===M?s.jsx(Qs,{name:M,server:D[M],scope:t,onRename:d=>Re(M,d),onChange:d=>ce(M,d),onRemove:()=>te(M)}):null},M):s.jsx(ne,{title:"No MCP servers yet",hint:e?"+ Add server starts a new one or browses the catalog.":"+ Add server starts a new one."})})]})})]})}const Cn=f.memo(Gs);function Qs({name:e,server:t,scope:n,onRename:a,onChange:l,onRemove:r}){var v;const i=t.type??"stdio",o=Bs.has(e),h=Ks.has(e),m=(v=t.permissions)==null?void 0:v.tools,g=m===void 0?"inherit":m==="allow"?"allow":m==="deny"?"deny":"list",u=Array.isArray(m)?m:[],x=(t.disabledTools??[]).join(", ");return s.jsxs("div",{"data-testid":"mcp-json-form",className:"space-y-4 max-w-2xl",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-fg-faint w-20",children:"origin"}),s.jsx(Qe,{scope:n,input:Fe(e,t)}),s.jsx("span",{className:"text-xs text-fg-faint",children:"click to change"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),s.jsx("input",{"aria-label":"Server name",defaultValue:e,onBlur:p=>a(p.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),s.jsx("button",{onClick:r,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),s.jsx(Ne,{label:"description",value:t.description??"",onChange:p=>l({...t,description:p||void 0}),placeholder:"what this server does…"}),o?s.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",s.jsx("span",{className:"font-mono",children:e})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):h?s.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",s.jsx("span",{className:"font-mono",children:e})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),s.jsx("select",{value:i,onChange:p=>l({...t,type:p.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:Is.map(p=>s.jsx("option",{value:p,children:p},p))}),i==="sse"?s.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),i==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(Ne,{label:"command",value:t.command??"",onChange:p=>l({...t,command:p}),placeholder:"npx / node / python …"}),s.jsx(Ne,{label:"args",value:(t.args??[]).join(" "),onChange:p=>l({...t,args:p.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),s.jsx(ft,{label:"env",value:t.env??{},onChange:p=>l({...t,env:p})})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ne,{label:"url",value:t.url??"",onChange:p=>l({...t,url:p}),placeholder:"https://…"}),s.jsx(ft,{label:"headers",value:t.headers??{},onChange:p=>l({...t,headers:p})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[s.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:p=>l({...t,alwaysLoad:p.target.checked||void 0})}),s.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),s.jsx(Ne,{label:"disabledTools",value:x,onChange:p=>{const b=p.split(",").map(w=>w.trim()).filter(Boolean);l({...t,disabledTools:b.length?b:void 0})},placeholder:"comma-separated tool names to hide"}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsxs("select",{value:g,onChange:p=>{const b=p.target.value,w={...t};if(b==="inherit"){if(w.permissions){const{tools:C,...A}=w.permissions;w.permissions=Object.keys(A).length?A:void 0}}else b==="list"?w.permissions={...w.permissions??{},tools:[]}:w.permissions={...w.permissions??{},tools:b};l(w)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[s.jsx("option",{value:"inherit",children:"inherit (default)"}),s.jsx("option",{value:"allow",children:"allow all tools"}),s.jsx("option",{value:"deny",children:"deny all tools"}),s.jsx("option",{value:"list",children:"allowlist…"})]}),g==="list"?s.jsx("input",{value:u.join(", "),onChange:p=>{const b=p.target.value.split(",").map(w=>w.trim()).filter(Boolean);l({...t,permissions:{...t.permissions??{},tools:b}})},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:e,value:t,onChange:n,placeholder:a}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:e}),s.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 ft({label:e,value:t,onChange:n}){const[a,l]=f.useState(""),[r,i]=f.useState(""),o=Object.entries(t);return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:e}),s.jsxs("div",{className:"flex-1 space-y-1",children:[o.map(([h,m])=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:h,onChange:g=>{const u={...t};delete u[h],u[g.target.value]=m,n(u)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),s.jsx("input",{value:m,onChange:g=>n({...t,[h]:g.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),s.jsx("button",{onClick:()=>{const g={...t};delete g[h],n(g)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},h)),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:a,onChange:h=>l(h.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"}),s.jsx("input",{value:r,onChange:h=>i(h.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"}),s.jsx("button",{onClick:()=>{a.trim()&&(n({...t,[a.trim()]:r}),l(""),i(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}function Zs({cwd:e,names:t}){const n={fileId:"settings",scope:"project",cwd:e},[a,l]=f.useState([]),[r,i]=f.useState(!1),[o,h]=f.useState(!1);f.useEffect(()=>{var p,b;let u=!0;const x=()=>window.api.claudeConfig.read(n).then(w=>{if(!u)return;const C=w.data;l(Array.isArray(C==null?void 0:C.disabledMcpjsonServers)?C.disabledMcpjsonServers:[]),i((C==null?void 0:C.enableAllProjectMcpServers)===!0)}).catch(()=>{});x();const v=(b=(p=window.api.config)==null?void 0:p.onChanged)==null?void 0:b.call(p,()=>{x()});return()=>{u=!1,v==null||v()}},[e]);const m=async(u,x)=>{h(!0);try{await window.api.claudeConfig.patch({...n,keyPath:[u],value:x})}catch(v){q.error(v.message||"save failed")}finally{h(!1)}},g=async(u,x)=>{const v=x?a.filter(p=>p!==u):[...new Set([...a,u])];l(v),await m("disabledMcpjsonServers",v.length?v:void 0)};return s.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:[s.jsxs("span",{children:["Gating · ",e,"/.claude/settings.json"]}),s.jsxs("label",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"checkbox","data-testid":"mcp-enable-all",checked:r,disabled:o,onChange:u=>{i(u.target.checked),m("enableAllProjectMcpServers",u.target.checked?!0:void 0)}}),"enableAllProjectMcpServers"]}),t.map(u=>s.jsxs("label",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"checkbox","data-testid":`mcp-gate-${u}`,checked:!a.includes(u),disabled:o,onChange:x=>g(u,x.target.checked)}),u]},u))]})}function Xs({value:e,onChange:t,path:n,readOnly:a,theme:l="dark"}){const r=l==="paper";return s.jsx(Yt,{path:`file://${n}`,defaultLanguage:"markdown",value:e,onChange:i=>t(i??""),beforeMount:r?zt:void 0,theme:r?Vt:"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 Pe="h-4 inline-flex items-center px-1.5 bg-bg-elev border border-line rounded-[3px] text-[10px] tracking-[0.04em] text-fg-dim",ze="text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",en=["prose-chat max-w-[720px] px-[26px] py-4 text-[14px] leading-[1.6] text-fg","[&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_h4]:font-serif","[&_h1]:text-[24px] [&_h2]:text-[20px] [&_h3]:text-[18px] [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold","[&_h1]:mb-1.5 [&_h2]:mb-1.5 [&_h3]:mb-1.5 [&_p]:mb-3.5 [&_ul]:mb-3.5 [&_ul]:pl-5 [&_ul]:list-disc [&_ol]:pl-5 [&_ol]:list-decimal","[&_pre]:!bg-bg-elev [&_code]:!bg-bg-elev"].join(" ");function tn(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function xt({item:e,home:t,draft:n,dirty:a,busy:l,lastSavedAt:r,saveError:i,onDraftChange:o,onSave:h,onRevert:m,readOnly:g=!1}){const u=f.useRef(null),[x,v]=f.useState("source"),p=f.useMemo(()=>ws(n),[n]),b=f.useMemo(()=>Rs(n)??"",[n]),w=f.useMemo(()=>x==="preview"?qt(p.body):"",[x,p.body]),C=(A,J)=>{const P=x===A;return s.jsx("button",{type:"button","data-testid":`skill-view-${A}`,"aria-pressed":P,onClick:()=>v(A),className:`h-6 inline-flex items-center px-[11px] rounded-[5px] text-xs ${P?"bg-bg-hi shadow-sm font-semibold text-fg":"text-fg-faint hover:text-fg"}`,children:J})};return s.jsxs("div",{ref:u,"data-testid":"skill-detail",className:"h-full min-h-0 flex flex-col",children:[s.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-[22px] pt-4",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs("span",{"data-testid":"skill-detail-name",className:"min-w-0 truncate font-mono text-[18px] font-semibold text-fg",children:["/",e.name]}),s.jsx("span",{"data-testid":"skill-detail-kind",className:Pe,children:e.kind==="commands"?"COMMAND":"SKILL"}),e.plugin?s.jsxs("span",{"data-testid":"skill-detail-plugin",className:Pe,children:["from ",e.plugin]}):s.jsx("span",{"data-testid":"skill-detail-scope",className:Pe,children:e.scope.toUpperCase()}),g&&s.jsx("span",{"data-testid":"skill-detail-readonly",className:Pe,children:"READ-ONLY"}),s.jsxs("div",{role:"group","aria-label":"View",className:"ml-auto flex gap-0.5 p-0.5 bg-bg-elev border border-line rounded-[7px]",children:[C("source","Source"),C("preview","Preview")]})]}),s.jsxs("div",{className:"grid grid-cols-[84px_minmax(0,1fr)] items-baseline gap-x-3 gap-y-2.5 mt-3.5",children:[g?s.jsx("span",{className:ze,children:"Description"}):s.jsx("label",{htmlFor:`skill-desc-${e.path}`,className:ze,children:"Description"}),g?s.jsx("span",{id:`skill-desc-${e.path}`,"data-testid":"skill-detail-description-text",className:"text-[13px] leading-[1.45] text-fg-dim",children:b||s.jsx("span",{className:"text-fg-faint",children:"No description"})}):s.jsx("input",{id:`skill-desc-${e.path}`,"data-testid":"skill-detail-description",type:"text",value:b,onChange:A=>o(As(n,A.target.value)),placeholder:"What this does and when Claude should use it",className:"px-2.5 py-[7px] bg-bg-hi border border-line rounded-md text-[13px] leading-[1.45] text-fg outline-none focus:border-accent"}),s.jsx("span",{className:ze,children:"File"}),s.jsxs("div",{className:"min-w-0 flex items-baseline gap-3 text-xs",children:[s.jsx("span",{"data-testid":"skill-detail-path",title:e.path,className:"min-w-0 truncate font-mono text-[11.5px] text-fg-dim",children:tn(e.path,t)}),s.jsx("button",{type:"button","data-testid":"skill-detail-reveal",onClick:()=>Gt(e.path),className:"shrink-0 font-medium text-accent hover:underline",children:"Reveal in File Explorer"})]})]}),s.jsx("div",{className:"flex-1 min-h-0 mt-3.5 border border-line border-b-0 rounded-t-[7px] bg-bg-hi overflow-hidden",children:x==="source"?s.jsx(Xs,{path:e.path,theme:"paper",value:p.body,readOnly:g,onChange:A=>{g||o(Ns(p.frontmatter,A))}}):s.jsx("div",{className:"h-full overflow-auto",children:s.jsx("div",{"data-testid":"skill-preview",className:en,dangerouslySetInnerHTML:{__html:w}})})})]}),!g&&s.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:s.jsx($t,{dirty:a,busy:l,parseError:i,lastSavedAt:r,onSave:h,onRevert:m,cleanLabel:"Saved — matches the file on disk",shortcutHint:!0,scopeRef:u})})]})}const ht=e=>e instanceof Error?e.message:String(e),gt=(e,t,n)=>`${e} ${e===1?t:n}`,bt=(e,t)=>e.name.localeCompare(t.name);async function sn(e,t){const[n,{manifest:a}]=await Promise.all([Pt(t),tt(t)]),[l,r]=await Promise.all([n?Mt(n):Promise.resolve([]),Ot(t,a)]),i=await Os(r.commandFiles);return[...l.map(o=>({kind:"skills",plugin:e,name:o.name??o.id,path:o.path,description:o.description??void 0})).sort(bt),...i.map(o=>({kind:"commands",plugin:e,name:o.name??o.id,path:o.id,description:o.description??void 0})).sort(bt)]}function nn(e,t){const[n,a]=f.useState([]),l=f.useRef(0),r=f.useCallback(async()=>{const i=++l.current;if(!t){a([]);return}let o=[];try{const h=(await window.api.plugins.list()).filter(m=>m.enabled&&m.installPath);o=await Promise.all(h.map(async m=>{try{return{key:m.key,name:m.name,items:await sn(m.name,m.installPath)}}catch(g){return{key:m.key,name:m.name,items:[],error:ht(g)}}}))}catch(h){console.warn(`[skills] could not list plugins: ${ht(h)}`)}l.current===i&&(o.sort((h,m)=>h.name.localeCompare(m.name)),a(o))},[t]);return f.useEffect(()=>{r()},[r]),f.useEffect(()=>()=>{l.current+=1},[]),Nt(t&&e?[`${e}/.claude/plugins/installed_plugins.json`,`${e}/.claude/settings.json`]:[],()=>{r()}),n}function an(e){const t=e.filter(a=>a.kind==="skills").length,n=e.length-t;return[t?gt(t,"skill","skills"):"",n?gt(n,"command","commands"):""].filter(Boolean).join(" · ")}function rn({open:e}){return s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-faint/60 transition-transform ${e?"rotate-90":""}`,"aria-hidden":!0,children:s.jsx("path",{d:"m9 18 6-6-6-6"})})}function ln({plugins:e,needle:t,selectedPath:n,onSelect:a}){const[l,r]=f.useState(()=>new Set),i=e.map(m=>{if(!t||m.name.toLowerCase().includes(t))return{p:m,items:m.items};const g=m.items.filter(u=>{var x;return u.name.toLowerCase().includes(t)||!!((x=u.description)!=null&&x.toLowerCase().includes(t))});return{p:m,items:g}}).filter(({p:m,items:g})=>!t||g.length>0||m.name.toLowerCase().includes(t)),o=i.reduce((m,g)=>m+g.items.length,0),h=m=>r(g=>{const u=new Set(g);return u.has(m)?u.delete(m):u.add(m),u});return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"skills-section-plugins",className:"flex items-center gap-2 mt-3 mx-1.5 mb-1 text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",children:["From plugins",s.jsx("span",{"data-testid":"skills-section-plugins-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:o}),s.jsx("span",{"data-testid":"skills-section-plugins-readonly",title:"Plugin files are managed by the plugin — open them to read, not edit",className:"ml-auto px-[5px] border border-line rounded-[3px] text-[9.5px] font-medium tracking-normal text-fg-faint",children:"READ-ONLY"})]}),e.length===0&&s.jsx("div",{className:"mx-1.5 mb-1 text-xs text-fg-faint",children:"No enabled plugin adds skills or commands"}),i.map(({p:m,items:g})=>{const u=!m.error&&(l.has(m.key)||!!t&&g.length>0);return s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("button",{type:"button","data-testid":"plugin-skills-row","data-plugin":m.name,"aria-expanded":u,onClick:()=>h(m.key),className:"flex items-center gap-2 px-2.5 py-[7px] border border-transparent rounded-[7px] text-left text-[12.5px] text-fg-dim hover:bg-bg-hi",children:[s.jsx("span",{className:"min-w-0 truncate",children:m.name}),m.error?s.jsx("span",{"data-testid":"plugin-skills-row-error",title:m.error,className:"ml-auto shrink-0 text-[11px] text-red-400",children:"Could not read plugin"}):s.jsx("span",{"data-testid":"plugin-skills-row-counts",className:"ml-auto shrink-0 font-mono text-[11px] text-fg-faint",children:an(m.items)||"nothing to list"}),s.jsx(rn,{open:u})]}),u&&g.map(x=>{const v=n===x.path;return s.jsxs("button",{type:"button","data-testid":"plugin-skills-item","data-path":x.path,"aria-current":v?"true":void 0,onClick:()=>a(x.path),className:`ml-3 mb-0.5 flex flex-col gap-[2px] px-2.5 py-1.5 border rounded-[7px] text-left ${v?"border-accent bg-bg-hi":"border-transparent hover:bg-bg-hi"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsxs("span",{"data-testid":"plugin-skills-item-name",className:"min-w-0 truncate font-mono text-[12px] font-semibold text-fg",children:["/",x.name]}),s.jsx("span",{className:"ml-auto shrink-0 text-[9.5px] tracking-[0.04em] text-fg-faint",children:x.kind==="commands"?"COMMAND":"SKILL"})]}),x.description&&s.jsx("span",{title:x.description,className:"truncate text-[11px] text-fg-faint",children:x.description})]},x.path)})]},m.key)})]})}const on=250,cn=2e3,dn=6;function un(e,t){return{user:{skills:`${e}/.claude/skills`,commands:`${e}/.claude/commands`},project:t?{skills:`${t}/.claude/skills`,commands:`${t}/.claude/commands`}:null}}const De=e=>e instanceof Error?e.message:String(e);async function mn(e,t){const n=e.map(()=>{});let a=0;const l=async()=>{for(let r=a++;r<e.length;r=a++)try{const i=await window.api.config.readText(e[r]);i.error?t.push({path:e[r],error:i.error}):i.exists&&(n[r]=Oe(i.text).description??void 0)}catch(i){t.push({path:e[r],error:De(i)})}};return await Promise.all(Array.from({length:Math.min(dn,e.length)},l)),n}const pn=/^[a-z0-9][a-z0-9-]{0,63}$/,fn="Use lowercase letters, digits and hyphens (max 64), starting with a letter or digit",xn=(e,t)=>e==="skills"?["---",`name: ${t}`,'description: ""',"---","",`# ${t}`,""].join(`
25
25
  `):["---",'description: ""',"---",""].join(`
26
- `),vt=(e,t,n)=>`${e} ${e===1?t:n}`;function kt({label:e,count:t,testId:n}){return s.jsxs("div",{"data-testid":n,className:"flex items-center gap-2 mt-3 mx-1.5 mb-1 text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",children:[e,s.jsx("span",{"data-testid":`${n}-count`,className:"font-mono font-medium tracking-normal text-fg-faint/60",children:t})]})}function Se({children:e,testId:t,title:n}){return s.jsx("div",{"data-testid":t,title:n,className:"mx-1.5 mb-1 text-xs text-fg-faint",children:e})}function hn({onAdd:e,scope:t="user"}={}){const n=yt(),a=wt(),l=(a==null?void 0:a.cwd)??null,[r,i]=f.useState([]),[o,h]=f.useState(null),[m,g]=f.useState(""),[u,x]=f.useState([]),[v,p]=f.useState(null),[b,w]=f.useState(!1),[C,A]=f.useState(null),[J,P]=f.useState(""),[B,N]=f.useState(null),L=f.useRef(null),G=f.useRef(null),ae=nn(n,t==="user"),ee=f.useMemo(()=>ae.flatMap(c=>c.items),[ae]),$e=f.useRef(ee);$e.current=ee;const ue=f.useMemo(()=>n?un(n,l):null,[n,l]),R=f.useMemo(()=>ue?t==="user"?ue.user:ue.project:null,[t,ue]),W=f.useRef(0),me=f.useCallback(async()=>{const c=++W.current;if(!R){i([]),x([]),w(!0);return}const j=[],S=[];try{const y=await jt(R.skills);S.push(...y.errors);for(const $ of y.entries)j.push({kind:"skills",scope:t,name:$.name,path:$.path,dir:$.dir,disabled:bs($.text),description:Oe($.text).description??void 0})}catch(y){S.push({path:R.skills,error:De(y)})}try{const y=await window.api.config.listDir(R.commands,{filesOnly:!0});y.ok||S.push({path:R.commands,error:y.error??"failed to list directory"});const $=y.entries.filter(U=>U.name.endsWith(".md")),F=await mn($.map(U=>U.path),S);$.forEach((U,X)=>{j.push({kind:"commands",scope:t,name:U.name.replace(/\.md$/,""),path:U.path,dir:null,disabled:!1,description:F[X]})})}catch(y){S.push({path:R.commands,error:De(y)})}if(W.current===c){for(const y of S)q.error(`Could not read ${y.path}: ${y.error}`);x(S),j.sort((y,$)=>y.kind===$.kind?y.name.localeCompare($.name):y.kind==="skills"?-1:1),i(j),w(!0),h(y=>{var $;return j.find(F=>F.path===y)||$e.current.some(F=>F.path===y)?y:(($=j[0])==null?void 0:$.path)??null})}},[R,t]);f.useEffect(()=>{me()},[me]),f.useEffect(()=>()=>{W.current+=1},[]);const D=f.useRef(me);D.current=me;const Ce=f.useRef(r);Ce.current=r;const K=f.useRef(o);K.current=o;const Y=f.useRef(null),H=f.useRef(!1),V=f.useRef(!1),ke=f.useCallback(async()=>{if(H.current){V.current=!0;return}H.current=!0;try{await D.current()}finally{H.current=!1}V.current&&(V.current=!1,ke())},[]);f.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const Ee=f.useCallback(c=>{var $;const j=K.current,S=j?Ce.current.find(F=>F.path===j):null,y=j?($=T.getState().files[j])==null?void 0:$.lastSavedAt:null;S!=null&&S.dir&&y&&Date.now()-y<cn&&(c===S.dir||S.dir.startsWith(`${c}/`))||(Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{Y.current=null,ke()},on))},[ke]);Nt(R?[R.skills,R.commands]:[],Ee);const re=T(c=>c.files),O=T(c=>c.loadText),M=T(c=>c.setDraft),pe=T(c=>c.saveText),Ae=T(c=>c.revert),Le=T(c=>c.watchFile),fe=T(c=>c.unwatchFile);async function Re(c,j){const S=await window.api.config.readText(c.path);if(!S.exists)return;const y=ks(S.text,j);if(y===S.text)return;const $=await window.api.config.writeText(c.path,y);if(!$.ok){q.error($.error??"failed to update skill");return}i(F=>F.map(U=>U.path===c.path?{...U,disabled:j}:U)),T.getState().files[c.path]&&T.getState().loadText(c.path,!0)}async function Ie(c){if(!c.dir)return;p(null);const j=await window.api.files.delete(c.dir);if(!j.ok){q.error(j.error??"failed to remove skill");return}q.info(`Removed "${c.name}" — moved to trash`),fe(c.path),i(S=>{const y=S.filter($=>$.path!==c.path);return h($=>{var F;return $!==c.path?$:((F=y[0])==null?void 0:F.path)??null}),y})}f.useEffect(()=>{if(o)return re[o]||O(o),Le(o),()=>fe(o)},[o]);const[Be,le]=f.useState(null),ie=!!(o&&re[o]);f.useEffect(()=>{var j;if(!ie||!o||L.current!==o)return;const c=(j=G.current)==null?void 0:j.querySelector('[data-testid="skill-detail-description"]');c&&(L.current=null,c.focus())},[ie,o]);function oe(c){g(""),P(""),N(null),A(c)}function je(){A(null),P(""),N(null)}async function Ke(c,j){if(!R)return;const S=j.trim();if(!pn.test(S)){N(fn);return}const y=c==="skills"?"skill":"command";if(r.some(X=>X.kind===c&&X.name===S)){N(`A ${y} named "${S}" already exists`);return}const $=c==="skills"?`${R.skills}/${S}`:null,F=c==="skills"?`${$}/SKILL.md`:`${R.commands}/${S}.md`;try{if((await window.api.config.readText(F)).exists){N(`A ${y} named "${S}" already exists`);return}const se=await window.api.config.writeText(F,xn(c,S));if(!se.ok)throw new Error(se.error??"write failed")}catch(X){q.error(`Could not create ${y} "${S}": ${De(X)}`),je(),h(null);return}je();const U={kind:c,scope:t,name:S,path:F,dir:$,disabled:!1,description:""};i(X=>[...X.filter(se=>se.path!==F),U].sort((se,at)=>se.kind===at.kind?se.name.localeCompare(at.name):se.kind==="skills"?-1:1)),L.current=F,h(F)}if(!n)return s.jsx(ne,{title:"loading…"});if(t==="project"&&!l)return s.jsx(Te,{toolbar:s.jsx(s.Fragment,{}),children:s.jsx(ne,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const z=o?re[o]:null,te=o?r.find(c=>c.path===o)??null:null,_e=!te&&o?ee.find(c=>c.path===o)??null:null,ce=m.trim().toLowerCase().replace(/^\//,""),ye=c=>{var j;return!ce||c.name.toLowerCase().includes(ce)||!!((j=c.description)!=null&&j.toLowerCase().includes(ce))},d=r.filter(c=>c.kind==="skills"),k=r.filter(c=>c.kind==="commands"),E=d.filter(ye),_=k.filter(ye),I=c=>c?u.filter(j=>j.path===c||j.path.startsWith(`${c}/`)):[],Z=I(R==null?void 0:R.skills),xe=I(R==null?void 0:R.commands),we=()=>oe("skills"),We=[{label:"New skill",testId:"skills-new-skill",onSelect:we},{label:"New command",testId:"skills-new-command",onSelect:()=>oe("commands")},...e?[{label:"Browse catalog…",testId:"skills-new-browse-catalog",onSelect:e}]:[]],st=c=>C!==c?null:s.jsxs("div",{"data-testid":`skills-new-row-${c}`,className:"mx-0.5 mb-1 flex flex-col gap-1",children:[s.jsx("input",{autoFocus:!0,"data-testid":`skills-new-name-${c}`,"aria-label":c==="skills"?"New skill name":"New command name","aria-invalid":B?"true":void 0,placeholder:c==="skills"?"skill-name":"command-name",value:J,spellCheck:!1,onChange:j=>{P(j.target.value),N(null)},onKeyDown:j=>{j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),je()):j.key==="Enter"&&(j.preventDefault(),Ke(c,J))},className:`h-7 px-2.5 bg-bg-hi border rounded-[7px] font-mono text-[12.5px] text-fg outline-none ${B?"border-red-400":"border-accent"}`}),B&&s.jsx("div",{"data-testid":`skills-new-error-${c}`,role:"alert",className:"mx-1 text-[11px] text-red-400",children:B})]}),nt=c=>{var y;const j=o===c.path,S=!!((y=re[c.path])!=null&&y.dirty);return s.jsxs("div",{"data-testid":"skills-item","data-path":c.path,onClick:()=>h(c.path),className:`flex flex-col gap-[3px] px-2.5 py-2 bg-bg-hi border rounded-[7px] cursor-pointer ${j?"border-accent":"border-line hover:border-rule"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button","data-testid":"skills-item-name","aria-current":j?"true":void 0,title:c.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,className:`flex-1 min-w-0 truncate text-left font-mono text-[12.5px] font-semibold text-fg ${c.disabled?"line-through opacity-50":""}`,children:["/",c.name]}),s.jsx(Qe,{interactive:!1,scope:c.scope,input:{type:c.kind==="commands"?"command":"skill",name:c.name}}),S&&s.jsx("span",{"data-testid":"skills-item-dirty",title:"Unsaved edits",className:"shrink-0 w-1 h-1 rounded-full bg-accent"}),c.kind==="skills"&&s.jsxs("span",{className:"shrink-0 flex items-center gap-2",onClick:$=>$.stopPropagation(),children:[s.jsx("span",{title:S?"This skill has unsaved edits — save or revert before toggling":void 0,children:s.jsx(ts,{checked:!c.disabled,disabled:S,onChange:$=>void Re(c,!$)})}),v===c.path?s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>void Ie(c),title:`Remove ${c.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),s.jsx("button",{type:"button",onClick:()=>p(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):s.jsx("button",{type:"button",onClick:()=>p(c.path),title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${c.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]}),c.description&&s.jsx("div",{"data-testid":"skills-item-desc",title:c.description,className:"truncate text-[11.5px] text-fg-faint",children:c.description})]},c.path)};let he=null;E.length>0?he=E.map(nt):b?d.length>0?he=s.jsx(Se,{children:"No skills match the filter"}):Z.length>0?he=s.jsx(Se,{testId:"skills-list-skills-error",title:Z.map(c=>`${c.path}: ${c.error}`).join(`
27
- `),children:"Could not list skills"}):he=s.jsxs("div",{"data-testid":"skills-empty",className:"mx-0.5 mb-1 px-3 py-[11px] flex flex-col gap-[5px] border border-dashed border-rule rounded-[7px] text-xs leading-[1.45] text-fg-dim",children:[s.jsx("span",{className:"font-semibold text-fg",children:"No skills yet"}),s.jsx("span",{children:"A skill is a folder with a SKILL.md that Claude loads when a task calls for it."}),s.jsx("button",{type:"button","data-testid":"skills-create-link",onClick:()=>we(),className:"self-start font-semibold text-accent hover:underline",children:"Create a skill →"})]}):he=null;let ge=null;return _.length>0?ge=_.map(nt):b?k.length>0?ge=s.jsx(Se,{children:"No commands match the filter"}):xe.length>0?ge=s.jsx(Se,{testId:"skills-list-commands-error",title:xe.map(c=>`${c.path}: ${c.error}`).join(`
28
- `),children:"Could not list slash commands"}):ge=s.jsx(Se,{children:"No slash commands"}):ge=null,s.jsxs("div",{ref:G,className:"h-full flex flex-col",children:[s.jsx(Ct,{filter:m,onFilterChange:g,placeholder:"Filter skills and commands",summary:[vt(d.length,"skill","skills"),vt(k.length,"command","commands"),...t==="user"?[`${ee.length} from plugins`]:[]].join(" · "),primary:{label:"+ New",testId:"skills-new",items:We}}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(Te,{children:s.jsx(St,{sidebarWidth:"300px",sidebar:s.jsxs("div",{"data-testid":"skills-list",className:"flex flex-col gap-1 px-2 py-1",children:[s.jsx(kt,{label:"Skills",count:E.length,testId:"skills-section-skills"}),st("skills"),he,s.jsx(kt,{label:"Slash commands",count:_.length,testId:"skills-section-commands"}),st("commands"),ge,t==="user"&&b&&s.jsx(ln,{plugins:ae,needle:ce,selectedPath:o,onSelect:h})]}),detail:te&&z?s.jsx(xt,{item:te,home:n,draft:z.draftRaw,dirty:z.dirty,busy:z.busy,lastSavedAt:z.lastSavedAt,saveError:Be,onDraftChange:c=>{le(null),M(te.path,c)},onSave:async()=>{le(null);const c=await pe(te.path);c.ok||le(c.error??"save failed")},onRevert:()=>{le(null),Ae(te.path)}}):_e&&z?s.jsx(xt,{readOnly:!0,item:{..._e,scope:t},home:n,draft:z.draftRaw,dirty:!1,busy:z.busy,lastSavedAt:z.lastSavedAt,saveError:null,onDraftChange:()=>{},onSave:()=>{},onRevert:()=>{}}):r.length===0&&u.length>0?s.jsx("div",{"data-testid":"skills-list-error",children:s.jsx(ne,{title:"could not list skills or commands",hint:u.map(c=>`${c.path}: ${c.error}`).join(`
26
+ `),vt=(e,t,n)=>`${e} ${e===1?t:n}`;function kt({label:e,count:t,testId:n}){return s.jsxs("div",{"data-testid":n,className:"flex items-center gap-2 mt-3 mx-1.5 mb-1 text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",children:[e,s.jsx("span",{"data-testid":`${n}-count`,className:"font-mono font-medium tracking-normal text-fg-faint/60",children:t})]})}function Se({children:e,testId:t,title:n}){return s.jsx("div",{"data-testid":t,title:n,className:"mx-1.5 mb-1 text-xs text-fg-faint",children:e})}function hn({onAdd:e,scope:t="user"}={}){const n=yt(),a=wt(),l=(a==null?void 0:a.cwd)??null,[r,i]=f.useState([]),[o,h]=f.useState(null),[m,g]=f.useState(""),[u,x]=f.useState([]),[v,p]=f.useState(null),[b,w]=f.useState(!1),[C,A]=f.useState(null),[J,P]=f.useState(""),[B,N]=f.useState(null),L=f.useRef(null),G=f.useRef(null),ae=nn(n,t==="user"),ee=f.useMemo(()=>ae.flatMap(c=>c.items),[ae]),$e=f.useRef(ee);$e.current=ee;const ue=f.useMemo(()=>n?un(n,l):null,[n,l]),_=f.useMemo(()=>ue?t==="user"?ue.user:ue.project:null,[t,ue]),W=f.useRef(0),me=f.useCallback(async()=>{const c=++W.current;if(!_){i([]),x([]),w(!0);return}const j=[],S=[];try{const y=await jt(_.skills);S.push(...y.errors);for(const $ of y.entries)j.push({kind:"skills",scope:t,name:$.name,path:$.path,dir:$.dir,disabled:bs($.text),description:Oe($.text).description??void 0})}catch(y){S.push({path:_.skills,error:De(y)})}try{const y=await window.api.config.listDir(_.commands,{filesOnly:!0});y.ok||S.push({path:_.commands,error:y.error??"failed to list directory"});const $=y.entries.filter(U=>U.name.endsWith(".md")),F=await mn($.map(U=>U.path),S);$.forEach((U,X)=>{j.push({kind:"commands",scope:t,name:U.name.replace(/\.md$/,""),path:U.path,dir:null,disabled:!1,description:F[X]})})}catch(y){S.push({path:_.commands,error:De(y)})}if(W.current===c){for(const y of S)q.error(`Could not read ${y.path}: ${y.error}`);x(S),j.sort((y,$)=>y.kind===$.kind?y.name.localeCompare($.name):y.kind==="skills"?-1:1),i(j),w(!0),h(y=>{var $;return j.find(F=>F.path===y)||$e.current.some(F=>F.path===y)?y:(($=j[0])==null?void 0:$.path)??null})}},[_,t]);f.useEffect(()=>{me()},[me]),f.useEffect(()=>()=>{W.current+=1},[]);const D=f.useRef(me);D.current=me;const Ce=f.useRef(r);Ce.current=r;const K=f.useRef(o);K.current=o;const Y=f.useRef(null),H=f.useRef(!1),V=f.useRef(!1),ke=f.useCallback(async()=>{if(H.current){V.current=!0;return}H.current=!0;try{await D.current()}finally{H.current=!1}V.current&&(V.current=!1,ke())},[]);f.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const Ee=f.useCallback(c=>{var $;const j=K.current,S=j?Ce.current.find(F=>F.path===j):null,y=j?($=T.getState().files[j])==null?void 0:$.lastSavedAt:null;S!=null&&S.dir&&y&&Date.now()-y<cn&&(c===S.dir||S.dir.startsWith(`${c}/`))||(Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{Y.current=null,ke()},on))},[ke]);Nt(_?[_.skills,_.commands]:[],Ee);const re=T(c=>c.files),O=T(c=>c.loadText),M=T(c=>c.setDraft),pe=T(c=>c.saveText),Ae=T(c=>c.revert),Le=T(c=>c.watchFile),fe=T(c=>c.unwatchFile);async function _e(c,j){const S=await window.api.config.readText(c.path);if(!S.exists)return;const y=ks(S.text,j);if(y===S.text)return;const $=await window.api.config.writeText(c.path,y);if(!$.ok){q.error($.error??"failed to update skill");return}i(F=>F.map(U=>U.path===c.path?{...U,disabled:j}:U)),T.getState().files[c.path]&&T.getState().loadText(c.path,!0)}async function Ie(c){if(!c.dir)return;p(null);const j=await window.api.files.delete(c.dir);if(!j.ok){q.error(j.error??"failed to remove skill");return}q.info(`Removed "${c.name}" — moved to trash`),fe(c.path),i(S=>{const y=S.filter($=>$.path!==c.path);return h($=>{var F;return $!==c.path?$:((F=y[0])==null?void 0:F.path)??null}),y})}f.useEffect(()=>{if(o)return re[o]||O(o),Le(o),()=>fe(o)},[o]);const[Be,le]=f.useState(null),ie=!!(o&&re[o]);f.useEffect(()=>{var j;if(!ie||!o||L.current!==o)return;const c=(j=G.current)==null?void 0:j.querySelector('[data-testid="skill-detail-description"]');c&&(L.current=null,c.focus())},[ie,o]);function oe(c){g(""),P(""),N(null),A(c)}function je(){A(null),P(""),N(null)}async function Ke(c,j){if(!_)return;const S=j.trim();if(!pn.test(S)){N(fn);return}const y=c==="skills"?"skill":"command";if(r.some(X=>X.kind===c&&X.name===S)){N(`A ${y} named "${S}" already exists`);return}const $=c==="skills"?`${_.skills}/${S}`:null,F=c==="skills"?`${$}/SKILL.md`:`${_.commands}/${S}.md`;try{if((await window.api.config.readText(F)).exists){N(`A ${y} named "${S}" already exists`);return}const se=await window.api.config.writeText(F,xn(c,S));if(!se.ok)throw new Error(se.error??"write failed")}catch(X){q.error(`Could not create ${y} "${S}": ${De(X)}`),je(),h(null);return}je();const U={kind:c,scope:t,name:S,path:F,dir:$,disabled:!1,description:""};i(X=>[...X.filter(se=>se.path!==F),U].sort((se,at)=>se.kind===at.kind?se.name.localeCompare(at.name):se.kind==="skills"?-1:1)),L.current=F,h(F)}if(!n)return s.jsx(ne,{title:"loading…"});if(t==="project"&&!l)return s.jsx(Te,{toolbar:s.jsx(s.Fragment,{}),children:s.jsx(ne,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const z=o?re[o]:null,te=o?r.find(c=>c.path===o)??null:null,Re=!te&&o?ee.find(c=>c.path===o)??null:null,ce=m.trim().toLowerCase().replace(/^\//,""),ye=c=>{var j;return!ce||c.name.toLowerCase().includes(ce)||!!((j=c.description)!=null&&j.toLowerCase().includes(ce))},d=r.filter(c=>c.kind==="skills"),k=r.filter(c=>c.kind==="commands"),E=d.filter(ye),R=k.filter(ye),I=c=>c?u.filter(j=>j.path===c||j.path.startsWith(`${c}/`)):[],Z=I(_==null?void 0:_.skills),xe=I(_==null?void 0:_.commands),we=()=>oe("skills"),We=[{label:"New skill",testId:"skills-new-skill",onSelect:we},{label:"New command",testId:"skills-new-command",onSelect:()=>oe("commands")},...e?[{label:"Browse catalog…",testId:"skills-new-browse-catalog",onSelect:e}]:[]],st=c=>C!==c?null:s.jsxs("div",{"data-testid":`skills-new-row-${c}`,className:"mx-0.5 mb-1 flex flex-col gap-1",children:[s.jsx("input",{autoFocus:!0,"data-testid":`skills-new-name-${c}`,"aria-label":c==="skills"?"New skill name":"New command name","aria-invalid":B?"true":void 0,placeholder:c==="skills"?"skill-name":"command-name",value:J,spellCheck:!1,onChange:j=>{P(j.target.value),N(null)},onKeyDown:j=>{j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),je()):j.key==="Enter"&&(j.preventDefault(),Ke(c,J))},className:`h-7 px-2.5 bg-bg-hi border rounded-[7px] font-mono text-[12.5px] text-fg outline-none ${B?"border-red-400":"border-accent"}`}),B&&s.jsx("div",{"data-testid":`skills-new-error-${c}`,role:"alert",className:"mx-1 text-[11px] text-red-400",children:B})]}),nt=c=>{var y;const j=o===c.path,S=!!((y=re[c.path])!=null&&y.dirty);return s.jsxs("div",{"data-testid":"skills-item","data-path":c.path,onClick:()=>h(c.path),className:`flex flex-col gap-[3px] px-2.5 py-2 bg-bg-hi border rounded-[7px] cursor-pointer ${j?"border-accent":"border-line hover:border-rule"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button","data-testid":"skills-item-name","aria-current":j?"true":void 0,title:c.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,className:`flex-1 min-w-0 truncate text-left font-mono text-[12.5px] font-semibold text-fg ${c.disabled?"line-through opacity-50":""}`,children:["/",c.name]}),s.jsx(Qe,{interactive:!1,scope:c.scope,input:{type:c.kind==="commands"?"command":"skill",name:c.name}}),S&&s.jsx("span",{"data-testid":"skills-item-dirty",title:"Unsaved edits",className:"shrink-0 w-1 h-1 rounded-full bg-accent"}),c.kind==="skills"&&s.jsxs("span",{className:"shrink-0 flex items-center gap-2",onClick:$=>$.stopPropagation(),children:[s.jsx("span",{title:S?"This skill has unsaved edits — save or revert before toggling":void 0,children:s.jsx(ts,{checked:!c.disabled,disabled:S,onChange:$=>void _e(c,!$)})}),v===c.path?s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>void Ie(c),title:`Remove ${c.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),s.jsx("button",{type:"button",onClick:()=>p(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):s.jsx("button",{type:"button",onClick:()=>p(c.path),title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${c.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]}),c.description&&s.jsx("div",{"data-testid":"skills-item-desc",title:c.description,className:"truncate text-[11.5px] text-fg-faint",children:c.description})]},c.path)};let he=null;E.length>0?he=E.map(nt):b?d.length>0?he=s.jsx(Se,{children:"No skills match the filter"}):Z.length>0?he=s.jsx(Se,{testId:"skills-list-skills-error",title:Z.map(c=>`${c.path}: ${c.error}`).join(`
27
+ `),children:"Could not list skills"}):he=s.jsxs("div",{"data-testid":"skills-empty",className:"mx-0.5 mb-1 px-3 py-[11px] flex flex-col gap-[5px] border border-dashed border-rule rounded-[7px] text-xs leading-[1.45] text-fg-dim",children:[s.jsx("span",{className:"font-semibold text-fg",children:"No skills yet"}),s.jsx("span",{children:"A skill is a folder with a SKILL.md that Claude loads when a task calls for it."}),s.jsx("button",{type:"button","data-testid":"skills-create-link",onClick:()=>we(),className:"self-start font-semibold text-accent hover:underline",children:"Create a skill →"})]}):he=null;let ge=null;return R.length>0?ge=R.map(nt):b?k.length>0?ge=s.jsx(Se,{children:"No commands match the filter"}):xe.length>0?ge=s.jsx(Se,{testId:"skills-list-commands-error",title:xe.map(c=>`${c.path}: ${c.error}`).join(`
28
+ `),children:"Could not list slash commands"}):ge=s.jsx(Se,{children:"No slash commands"}):ge=null,s.jsxs("div",{ref:G,className:"h-full flex flex-col",children:[s.jsx(Ct,{filter:m,onFilterChange:g,placeholder:"Filter skills and commands",summary:[vt(d.length,"skill","skills"),vt(k.length,"command","commands"),...t==="user"?[`${ee.length} from plugins`]:[]].join(" · "),primary:{label:"+ New",testId:"skills-new",items:We}}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(Te,{children:s.jsx(St,{sidebarWidth:"300px",sidebar:s.jsxs("div",{"data-testid":"skills-list",className:"flex flex-col gap-1 px-2 py-1",children:[s.jsx(kt,{label:"Skills",count:E.length,testId:"skills-section-skills"}),st("skills"),he,s.jsx(kt,{label:"Slash commands",count:R.length,testId:"skills-section-commands"}),st("commands"),ge,t==="user"&&b&&s.jsx(ln,{plugins:ae,needle:ce,selectedPath:o,onSelect:h})]}),detail:te&&z?s.jsx(xt,{item:te,home:n,draft:z.draftRaw,dirty:z.dirty,busy:z.busy,lastSavedAt:z.lastSavedAt,saveError:Be,onDraftChange:c=>{le(null),M(te.path,c)},onSave:async()=>{le(null);const c=await pe(te.path);c.ok||le(c.error??"save failed")},onRevert:()=>{le(null),Ae(te.path)}}):Re&&z?s.jsx(xt,{readOnly:!0,item:{...Re,scope:t},home:n,draft:z.draftRaw,dirty:!1,busy:z.busy,lastSavedAt:z.lastSavedAt,saveError:null,onDraftChange:()=>{},onSave:()=>{},onRevert:()=>{}}):r.length===0&&u.length>0?s.jsx("div",{"data-testid":"skills-list-error",children:s.jsx(ne,{title:"could not list skills or commands",hint:u.map(c=>`${c.path}: ${c.error}`).join(`
29
29
  `)})}):s.jsx(ne,{title:r.length===0?"no skills or commands":"select an item"})})})})]})}const En=f.memo(hn);export{Ct as E,Xs as M,En as S,Cn as a,Mt as b,tt as c,wn as d,Pt as e,Nn as f,Ot as g,Sn as i,It as l,Os as r,$n as s};
@@ -1 +1 @@
1
- import{bf as p,aN as d,an as g,ax as o,bd as b}from"./index-BLORXCcT.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function w({path:e,keyPath:t,note:l}){const u=p(),[n,r]=d.useState(void 0);d.useEffect(()=>{let i=!0;const c=()=>{window.api.config.readText(e,{maxBytes:1}).then(s=>{i&&r(s.exists?s.mtimeMs:null)}).catch(()=>{i&&r(void 0)})};c();const x=window.api.config.onChanged(s=>{s.path===e&&c()});return()=>{i=!1,x()}},[e]);const f=h(e,u)+(t&&t.length?` › ${t.join(".")}`:""),a=n===void 0?"":n===null?"created on first save":g(n),m=()=>{b.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return o.jsxs("button",{type:"button","data-testid":"source-chip",title:l??`Open ${e} in the editor`,onClick:m,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[o.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),a&&o.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",a]})]})}export{w as S,h as s};
1
+ import{bh as p,aO as d,ao as g,ay as o,bf as b}from"./index-Cznhnxhq.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function w({path:e,keyPath:t,note:l}){const u=p(),[n,r]=d.useState(void 0);d.useEffect(()=>{let i=!0;const c=()=>{window.api.config.readText(e,{maxBytes:1}).then(s=>{i&&r(s.exists?s.mtimeMs:null)}).catch(()=>{i&&r(void 0)})};c();const x=window.api.config.onChanged(s=>{s.path===e&&c()});return()=>{i=!1,x()}},[e]);const f=h(e,u)+(t&&t.length?` › ${t.join(".")}`:""),a=n===void 0?"":n===null?"created on first save":g(n),m=()=>{b.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return o.jsxs("button",{type:"button","data-testid":"source-chip",title:l??`Open ${e} in the editor`,onClick:m,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[o.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),a&&o.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",a]})]})}export{w as S,h as s};
@@ -1 +1 @@
1
- import{aN as i,b9 as d,ax as e,a8 as E,b5 as O,bf as _,C as B,l as C,ag as P}from"./index-BLORXCcT.js";import{P as $}from"./Panel-D7NX5iP8.js";import{S as z,I as H}from"./Library-COr79GyT.js";import{D as W}from"./DocumentEditorPane-CgB5IuOY.js";import{S as q}from"./SourceChip-DC5XD8KC.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-CObXxw7b.js";const G=300;function J({activePath:o,selectedPath:r,onSelect:s}){const[f,n]=i.useState([]),x=i.useRef(0),j=i.useRef(s);j.current=s;const h=d(a=>{var l;return o?(l=a.files[o])==null?void 0:l.diskRaw:void 0}),u=i.useRef(null);if(i.useEffect(()=>{j.current(null)},[o]),i.useEffect(()=>{if(x.current+=1,!o){u.current=null,n([]);return}const a=u.current!==o;u.current=o;let l=!1;const m=()=>{x.current+=1;const y=x.current;window.api.config.parseImports(o).then(p=>{l||x.current!==y||(p.ok?n(p.imports):(n([]),O.error(p.error||"failed to parse @-imports")))})},v=a?null:setTimeout(m,G);return a&&m(),()=>{l=!0,v&&clearTimeout(v)}},[o,h]),f.length===0||!o)return null;const b=r===o||r===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",f.length+1]}),e.jsxs("button",{type:"button",onClick:()=>s(null),"aria-current":b,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${b?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:E(o)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:o,children:"this system prompt"})]}),f.map(a=>{const l=!a.ok||!a.exists,m=r===a.path;return e.jsxs("button",{type:"button",onClick:()=>s(a),"aria-current":m,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${m?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:E(a.path)}),l&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:a.path,children:a.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[a.sizeBytes.toLocaleString()," bytes · ~",a.tokenEstimate.toLocaleString()," tokens"]})]},a.path)})]})}const R={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function K(){const o=_(),r=i.useMemo(()=>o?B.resolve("user",o,null):null,[o]),[s,f]=i.useState(null),n=(s==null?void 0:s.path)??r,[x,j]=i.useState({});i.useEffect(()=>{const t=s==null?void 0:s.path;if(!t||!s.ok||!s.exists)return;let k=!0;return Promise.resolve().then(()=>window.api.config.canWrite(t)).then(I=>{k&&j(M=>({...M,[t]:I===!1}))}).catch(()=>{}),()=>{k=!1}},[s]);const h=!!s&&x[s.path]===!0,u=!!s&&(!s.ok||!s.exists||h),b=d(t=>t.files),a=d(t=>t.loadText),l=d(t=>t.setDraft),m=d(t=>t.saveText),v=d(t=>t.revert),y=d(t=>t.watchFile),p=d(t=>t.unwatchFile);i.useEffect(()=>{if(r)return a(r,!0),y(r),()=>{p(r)}},[r]),i.useEffect(()=>{if(!(!n||n===r))return a(n,!0),y(n),()=>{p(n)}},[n,r]);const[D,g]=i.useState(null),T=i.useCallback(t=>{g(null),f(t)},[]);if(!o)return e.jsx(C,{title:"loading…"});const L=r?b[r]:null,c=n?b[n]:null,N=(c==null?void 0:c.draftRaw)??"",U=P(N),A=N.length,F=u&&!h,S=u,w=async()=>{if(!n)return;g(null);const t=await m(n);t.ok||g(t.error??"save failed")};return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[r&&e.jsx(H,{path:r,disabled:!!s}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:n??"—"}),r&&e.jsx("span",{className:"ml-3",children:e.jsx(q,{path:r})}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[A.toLocaleString()," chars · ~",U.toLocaleString()," tokens"]})]}),footer:n&&c&&!S?e.jsx(z,{dirty:c.dirty,busy:c.busy,parseError:D,lastSavedAt:c.lastSavedAt,leading:c.exists?s?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:w,onRevert:()=>{g(null),v(n)}}):null,children:r&&L?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:R.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:R.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:r})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(J,{activePath:r,selectedPath:n,onSelect:T}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[F&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),h&&s&&e.jsxs("div",{"data-testid":"system-prompt-readonly-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:["Read-only: ",e.jsx("span",{className:"font-mono",children:s.path})," is outside the folders Session Manager may write to."]}),n&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(W,{path:n,value:N,readOnly:S,defaultMode:"split",onChange:t=>{g(null),l(n,t)},onSave:()=>{w()}},n)})]})]})]}):e.jsx(C,{title:"resolving…"})})}const se=i.memo(K);export{se as SystemPrompt};
1
+ import{aO as i,bb as d,ay as e,a9 as E,b7 as M,bh as _,C as B,m as C,ah as P}from"./index-Cznhnxhq.js";import{P as $}from"./Panel-DP8eSKSs.js";import{S as z,I as H}from"./Library-I37dQ6pB.js";import{D as W}from"./DocumentEditorPane-DaX4xag_.js";import{S as q}from"./SourceChip-DUxulNOp.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-BHvploNk.js";const G=300;function J({activePath:o,selectedPath:r,onSelect:s}){const[f,n]=i.useState([]),x=i.useRef(0),j=i.useRef(s);j.current=s;const h=d(a=>{var l;return o?(l=a.files[o])==null?void 0:l.diskRaw:void 0}),u=i.useRef(null);if(i.useEffect(()=>{j.current(null)},[o]),i.useEffect(()=>{if(x.current+=1,!o){u.current=null,n([]);return}const a=u.current!==o;u.current=o;let l=!1;const m=()=>{x.current+=1;const y=x.current;window.api.config.parseImports(o).then(p=>{l||x.current!==y||(p.ok?n(p.imports):(n([]),M.error(p.error||"failed to parse @-imports")))})},v=a?null:setTimeout(m,G);return a&&m(),()=>{l=!0,v&&clearTimeout(v)}},[o,h]),f.length===0||!o)return null;const b=r===o||r===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",f.length+1]}),e.jsxs("button",{type:"button",onClick:()=>s(null),"aria-current":b,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${b?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:E(o)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:o,children:"this system prompt"})]}),f.map(a=>{const l=!a.ok||!a.exists,m=r===a.path;return e.jsxs("button",{type:"button",onClick:()=>s(a),"aria-current":m,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${m?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:E(a.path)}),l&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:a.path,children:a.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[a.sizeBytes.toLocaleString()," bytes · ~",a.tokenEstimate.toLocaleString()," tokens"]})]},a.path)})]})}const R={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function K(){const o=_(),r=i.useMemo(()=>o?B.resolve("user",o,null):null,[o]),[s,f]=i.useState(null),n=(s==null?void 0:s.path)??r,[x,j]=i.useState({});i.useEffect(()=>{const t=s==null?void 0:s.path;if(!t||!s.ok||!s.exists)return;let k=!0;return Promise.resolve().then(()=>window.api.config.canWrite(t)).then(O=>{k&&j(I=>({...I,[t]:O===!1}))}).catch(()=>{}),()=>{k=!1}},[s]);const h=!!s&&x[s.path]===!0,u=!!s&&(!s.ok||!s.exists||h),b=d(t=>t.files),a=d(t=>t.loadText),l=d(t=>t.setDraft),m=d(t=>t.saveText),v=d(t=>t.revert),y=d(t=>t.watchFile),p=d(t=>t.unwatchFile);i.useEffect(()=>{if(r)return a(r,!0),y(r),()=>{p(r)}},[r]),i.useEffect(()=>{if(!(!n||n===r))return a(n,!0),y(n),()=>{p(n)}},[n,r]);const[D,g]=i.useState(null),T=i.useCallback(t=>{g(null),f(t)},[]);if(!o)return e.jsx(C,{title:"loading…"});const L=r?b[r]:null,c=n?b[n]:null,N=(c==null?void 0:c.draftRaw)??"",U=P(N),A=N.length,F=u&&!h,S=u,w=async()=>{if(!n)return;g(null);const t=await m(n);t.ok||g(t.error??"save failed")};return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[r&&e.jsx(H,{path:r,disabled:!!s}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:n??"—"}),r&&e.jsx("span",{className:"ml-3",children:e.jsx(q,{path:r})}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[A.toLocaleString()," chars · ~",U.toLocaleString()," tokens"]})]}),footer:n&&c&&!S?e.jsx(z,{dirty:c.dirty,busy:c.busy,parseError:D,lastSavedAt:c.lastSavedAt,leading:c.exists?s?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:w,onRevert:()=>{g(null),v(n)}}):null,children:r&&L?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:R.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:R.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:r})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(J,{activePath:r,selectedPath:n,onSelect:T}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[F&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),h&&s&&e.jsxs("div",{"data-testid":"system-prompt-readonly-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:["Read-only: ",e.jsx("span",{className:"font-mono",children:s.path})," is outside the folders Session Manager may write to."]}),n&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(W,{path:n,value:N,readOnly:S,defaultMode:"split",onChange:t=>{g(null),l(n,t)},onSave:()=>{w()}},n)})]})]})]}):e.jsx(C,{title:"resolving…"})})}const se=i.memo(K);export{se as SystemPrompt};