claude-code-session-manager 0.116.1 → 0.118.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.
- package/dist/assets/{AgentLibrary-CkS69HnN.js → AgentLibrary-CEI6vsmu.js} +2 -2
- package/dist/assets/{Button-BQxkfIbW.js → Button-BuyzGzO8.js} +1 -1
- package/dist/assets/{DataModel-YVgdJTZF.js → DataModel-CbXI_rEf.js} +1 -1
- package/dist/assets/{History-DneHh4jI.js → History-axy4nJyY.js} +2 -2
- package/dist/assets/{Hooks-Bt4xIjfo.js → Hooks-D5ghOppL.js} +3 -3
- package/dist/assets/{Library-DoP5FdXq.js → Library-wBI4Fwh3.js} +7 -7
- package/dist/assets/{ListDetail-BYxyl13e.js → ListDetail-CY5hhwn9.js} +1 -1
- package/dist/assets/{McpServers-CKm_iZsf.js → McpServers-CwEVZqfu.js} +2 -2
- package/dist/assets/Memory-Beh2r4Xk.js +25 -0
- package/dist/assets/{Panel-Cv8aYElQ.js → Panel-yOYf80ax.js} +1 -1
- package/dist/assets/{Permissions-CFmWwqyV.js → Permissions-DA-SMXO3.js} +3 -3
- package/dist/assets/{Plugins-CuYNgf_d.js → Plugins-qfKt6BxH.js} +2 -2
- package/dist/assets/ProvenanceBadge-DFyBe7Po.js +1 -0
- package/dist/assets/RemoteMachines-AG0K7kqS.js +3 -0
- package/dist/assets/{SaveBar-Cb4Q8TBK.js → SaveBar-35Nw2YsZ.js} +1 -1
- package/dist/assets/{Scheduler-ysJHQvW4.js → Scheduler-BPBAU0TO.js} +8 -8
- package/dist/assets/{ScopeSwitcher-BTOWfifI.js → ScopeSwitcher-BCXNrrrs.js} +1 -1
- package/dist/assets/{Settings-C6fH8diZ.js → Settings-C4yhzfZI.js} +4 -4
- package/dist/assets/{SkillReferenceGraph-esAcniTQ.js → SkillReferenceGraph-Ca5z2avC.js} +1 -1
- package/dist/assets/{Skills-4_vqzrSF.js → Skills-5WWusmKG.js} +1 -1
- package/dist/assets/SystemPrompt-ofVCdHAW.js +1 -0
- package/dist/assets/TagLibrary-rSrpD-Bz.js +1 -0
- package/dist/assets/{TiptapBody-EkZlmD9k.js → TiptapBody-DAYcdcVt.js} +1 -1
- package/dist/assets/{Toggle-CpR97XGM.js → Toggle-BzHdpXZI.js} +1 -1
- package/dist/assets/{ViewTabs-ekJfFek8.js → ViewTabs-D82jJ4VS.js} +1 -1
- package/dist/assets/{historyTotals-Bg0GVcsF.js → historyTotals-DMGFqK5h.js} +1 -1
- package/dist/assets/{index-CZsDDyLy.css → index-DAMBm3UN.css} +1 -1
- package/dist/assets/{index-DQSEUdx0.js → index-DZ5TJKNI.js} +501 -500
- package/dist/assets/{settingsSchema-BG5jZbhn.js → settingsSchema-BfnNE6ne.js} +1 -1
- package/dist/assets/{skillFrontmatter-DF6xI6Wb.js → skillFrontmatter-ED1DjPE1.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-Dox-xCx9.js → useAgentsDirWatch-CbpQIu3P.js} +1 -1
- package/dist/assets/{useRemotePeers-DHo62LbA.js → useRemotePeers-Dy_o0WlY.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/develop/SKILL.md +23 -10
- package/scripts/scheduler-mcp-server.cjs +16 -1
- package/src/main/build-info.json +4 -4
- package/src/main/lib/epic/epicSettle.cjs +105 -0
- package/src/main/lib/epic/epicSweepValidator.cjs +74 -0
- package/src/main/lib/epic/epicValidationHook.cjs +171 -141
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +2 -1
- package/src/main/lib/git/gitWorktree.cjs +7 -0
- package/src/main/lib/git/worktreeDeps.cjs +77 -0
- package/src/main/lib/mcpToolCatalog.cjs +6 -2
- package/src/main/lib/memoryMdNetwork.cjs +121 -0
- package/src/main/lib/memoryRefResolve.cjs +64 -0
- package/src/main/lib/memoryStale.cjs +27 -11
- package/src/main/lib/persona-macro/macroLibrary.cjs +49 -2
- package/src/main/lib/scheduler/baselineGate.cjs +128 -0
- package/src/main/lib/scheduler/definitionOfDone.cjs +9 -3
- package/src/main/lib/scheduler/needsReviewLedger.cjs +1 -1
- package/src/main/lib/scheduler/reviewNotice.cjs +53 -0
- package/src/main/memoryAssist.cjs +71 -31
- package/src/main/memoryTool.cjs +18 -6
- package/src/main/promptSessionEvents.cjs +6 -2
- package/src/main/runVerify.cjs +39 -3
- package/src/main/scheduler/reviewLadder.cjs +25 -6
- package/src/main/scheduler.cjs +121 -62
- package/src/main/templates/PRD_AUTHORING.md +2 -0
- package/src/preload/api.d.ts +24 -2
- package/dist/assets/Memory-BWMQuAoC.js +0 -18
- package/dist/assets/ProvenanceBadge-BMLVPyHr.js +0 -1
- package/dist/assets/RemoteMachines-D04Mby_W.js +0 -3
- package/dist/assets/SystemPrompt-CdUq4KXx.js +0 -1
- package/dist/assets/TagLibrary-CVFIphBv.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ap as e}from"./index-DZ5TJKNI.js";function o({sidebar:r,detail:s,sidebarWidth:i="18rem"}){return e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"shrink-0 border-r border-line overflow-y-auto",style:{width:i},children:r}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:s})]})}export{o as L};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`}function Te(l){let t=Object.keys(l).length+1,a=`server-${t}`;for(;l[a];)t+=1,a=`server-${t}`;return a}function Re(){const l=xe(),t=ue(),a=(t==null?void 0:t.cwd)??null,d=pe(s=>s.navFace),f=c.useRef(!1),b=c.useRef(d),[o,j]=c.useState(()=>d==="project"&&a?"project":"user"),[r,g]=c.useState(null),[x,u]=c.useState("installed"),[C,B]=c.useState("");c.useEffect(()=>{if(b.current!==d){if(b.current=d,f.current){f.current=!1;return}j(d==="project"&&a?"project":"user")}},[d,a]);const p=c.useMemo(()=>l?Ce(o,l,a):null,[l,o,a]),k=S(s=>s.files),n=S(s=>s.loadJson),v=S(s=>s.setDraft),m=S(s=>s.saveJson),K=S(s=>s.revert),R=S(s=>s.watchFile),se=S(s=>s.unwatchFile);c.useEffect(()=>{if(p)return k[p]||n(p),R(p),()=>se(p)},[p]);const[ae,F]=c.useState(null),[q,Y]=c.useState(null),[D,Z]=c.useState(!1),A=c.useRef(0),L=c.useRef(!0);c.useEffect(()=>()=>{L.current=!1},[]);const V=async()=>{const s=++A.current;Z(!0);try{const i=await window.api.mcp.status();if(!L.current||s!==A.current)return;Y(i),i.ok||G.error(i.error??"MCP status probe failed")}catch(i){if(!L.current||s!==A.current)return;Y(null),G.error(i.message||"MCP status probe failed")}finally{L.current&&s===A.current&&Z(!1)}};if(c.useEffect(()=>{V()},[]),!l)return e.jsx(_,{title:"loading…"});if(x==="library")return e.jsx(J,{toolbar:e.jsx(I,{active:x,onChange:u}),children:e.jsx(ge,{})});if(o==="project"&&!a)return e.jsx(J,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(I,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(H,{scopes:["user","project"],active:o,onChange:s=>{f.current=!0,j(s)}})]}),children:e.jsx(_,{title:"no active project"})});if(!p)return e.jsx(_,{title:"loading…"});const w=k[p],{full:ne,servers:h,err:le}=w?ke(w.draftRaw):{full:{},servers:{},err:null},M=Object.keys(h).sort(),O=r?h[r]:null,P=s=>{F(null),v(p,Ee(ne,s))},re=()=>{const s=Te(h);P({...h,[s]:{type:"stdio",command:"",args:[]}}),g(s)},oe=s=>{const i={...h};delete i[s],P(i),r===s&&g(null)},ie=(s,i)=>{if(!i||i===s||h[i])return;const y={};for(const N of Object.keys(h))y[N===s?i:N]=h[N];P(y),g(i)},ce=(s,i)=>{P({...h,[s]:i})};return e.jsx(J,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(I,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(H,{scopes:["user","project"],active:o,onChange:s=>{f.current=!0,j(s)}}),e.jsxs("span",{className:"ml-3 px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-faint",children:[M.length," server",M.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:p}),e.jsx("div",{className:"flex-1"}),r&&O&&e.jsx(U,{scope:o,input:Q(r,O),className:"mr-2"}),e.jsx("button",{onClick:V,disabled:D,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50 mr-2",children:D?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:re,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ new server"})]}),footer:w?e.jsx(he,{dirty:w.dirty,busy:w.busy,parseError:ae||le||w.parseError,lastSavedAt:w.lastSavedAt,onSave:async()=>{var y;F(null);const s=((y=w.diskData)==null?void 0:y.mcpServers)??{};for(const[N,E]of Object.entries(h)){if(JSON.stringify(E)===JSON.stringify(s[N]))continue;const $=W(E);if($.length>0){fe.getState().show("error",`Not saved: "${N}" still contains placeholder ${$.map(de=>de.token).join(", ")} — replace it with a real value`);return}}const i=await m(p);i.ok||F(i.error??"save failed")},onRevert:()=>{F(null),K(p)}}):null,children:e.jsx(me,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:C,onChange:s=>B(s.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),M.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):M.filter(s=>!C||s.toLowerCase().includes(C.toLowerCase())).map(s=>{var N;const i=X(s,q),y=(N=h[s].description)==null?void 0:N.trim();return e.jsxs("button",{onClick:()=>g(s),className:`w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 ${r===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(te,{state:i.dotState,title:i.label}),e.jsx("span",{className:"truncate",children:s})]}),e.jsxs("span",{className:"ml-2 flex items-center gap-2 shrink-0",children:[(()=>{const E=W(h[s]);return E.length>0?e.jsxs(z,{tone:"warn",title:`${o} scope · ${p}`,children:["unconfigured placeholder: ",E.map($=>$.token).join(", ")]}):null})(),e.jsx(z,{tone:i.badgeTone,children:i.label}),e.jsx(U,{interactive:!1,scope:o,input:Q(s,h[s])}),e.jsx("span",{className:"text-fg-faint",children:h[s].type??"stdio"})]})]}),y?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:y,children:y}):null]},s)})]}),detail:r&&O?e.jsx(Fe,{name:r,server:O,connection:X(r,q),onTestConnection:V,testing:D,onRename:s=>ie(r,s),onChange:s=>ce(r,s),onRemove:()=>oe(r)}):e.jsx(_,{title:"select a server or click + new"})})})}const Je=c.memo(Re);function Fe({name:l,server:t,connection:a,onTestConnection:d,testing:f,onRename:b,onChange:o,onRemove:j}){var k;const r=t.type??"stdio",g=we.has(l),x=Se.has(l),u=(k=t.permissions)==null?void 0:k.tools,C=u===void 0?"inherit":u==="allow"?"allow":u==="deny"?"deny":"list",B=Array.isArray(u)?u:[],p=(t.disabledTools??[]).join(", ");return e.jsxs("div",{className:"p-4 space-y-4 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{state:a.dotState,size:"md",title:a.label}),e.jsx(z,{tone:a.badgeTone,children:a.label}),e.jsx("button",{onClick:d,disabled:f,className:"ml-auto px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50",children:f?"checking…":"test connection"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),e.jsx("input",{defaultValue:l,onBlur:n=>b(n.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("button",{onClick:j,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),e.jsx(T,{label:"description",value:t.description??"",onChange:n=>o({...t,description:n||void 0}),placeholder:"what this server does…"}),g?e.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:l})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):x?e.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:l})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),e.jsx("select",{value:r,onChange:n=>o({...t,type:n.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:Ne.map(n=>e.jsx("option",{value:n,children:n},n))}),r==="sse"?e.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),r==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"command",value:t.command??"",onChange:n=>o({...t,command:n}),placeholder:"npx / node / python …"}),e.jsx(T,{label:"args",value:(t.args??[]).join(" "),onChange:n=>o({...t,args:n.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(ee,{label:"env",value:t.env??{},onChange:n=>o({...t,env:n})})]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"url",value:t.url??"",onChange:n=>o({...t,url:n}),placeholder:"https://…"}),e.jsx(ee,{label:"headers",value:t.headers??{},onChange:n=>o({...t,headers:n})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:n=>o({...t,alwaysLoad:n.target.checked||void 0})}),e.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"enabled"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.enabled!==!1,onChange:n=>o({...t,enabled:n.target.checked?void 0:!1})}),e.jsx("span",{className:"text-fg-dim",children:"load this server in new sessions"})]})]}),e.jsx(T,{label:"disabledTools",value:p,onChange:n=>{const v=n.split(",").map(m=>m.trim()).filter(Boolean);o({...t,disabledTools:v.length?v:void 0})},placeholder:"comma-separated tool names to hide"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("select",{value:C,onChange:n=>{const v=n.target.value,m={...t};if(v==="inherit"){if(m.permissions){const{tools:K,...R}=m.permissions;m.permissions=Object.keys(R).length?R:void 0}}else v==="list"?m.permissions={...m.permissions??{},tools:[]}:m.permissions={...m.permissions??{},tools:v};o(m)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"inherit",children:"inherit (default)"}),e.jsx("option",{value:"allow",children:"allow all tools"}),e.jsx("option",{value:"deny",children:"deny all tools"}),e.jsx("option",{value:"list",children:"allowlist…"})]}),C==="list"?e.jsx("input",{value:B.join(", "),onChange:n=>{const v=n.target.value.split(",").map(m=>m.trim()).filter(Boolean);o({...t,permissions:{...t.permissions??{},tools:v}})},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 T({label:l,value:t,onChange:a,placeholder:d}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:l}),e.jsx("input",{value:t,onChange:f=>a(f.target.value),placeholder:d,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function ee({label:l,value:t,onChange:a}){const[d,f]=c.useState(""),[b,o]=c.useState(""),j=Object.entries(t);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:l}),e.jsxs("div",{className:"flex-1 space-y-1",children:[j.map(([r,g])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:r,onChange:x=>{const u={...t};delete u[r],u[x.target.value]=g,a(u)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("input",{value:g,onChange:x=>a({...t,[r]:x.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:()=>{const x={...t};delete x[r],a(x)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},r)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:d,onChange:r=>f(r.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("input",{value:b,onChange:r=>o(r.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("button",{onClick:()=>{d.trim()&&(a({...t,[d.trim()]:b}),f(""),o(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}export{Je as McpServers,Te as nextServerName};
|
|
1
|
+
import{ap as e,aF as c,b4 as xe,aY as ue,b6 as pe,a_ as S,n as _,a as z,bf as fe,aX as H}from"./index-DZ5TJKNI.js";import{P as J}from"./Panel-yOYf80ax.js";import{L as me}from"./ListDetail-CY5hhwn9.js";import{S as he}from"./SaveBar-35Nw2YsZ.js";import{S as U}from"./ScopeSwitcher-BCXNrrrs.js";import{P as X}from"./ProvenanceBadge-DFyBe7Po.js";import{M as ge,V as I,g as Z}from"./Library-wBI4Fwh3.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-BuyzGzO8.js";import"./listSkills-C1aWKf0T.js";const be={live:"bg-emerald-400",idle:"bg-amber-400",offline:"bg-fg-faint",attention:"bg-accent",paused:"bg-zinc-500"},je={sm:"w-1.5 h-1.5",md:"w-2 h-2"},ve={on:"live",off:"offline",warn:"attention",live:"live",idle:"idle"};function te({state:l,kind:t,pulse:a=!1,size:d="sm",className:f="",title:b,"aria-label":o}){const j=l??(t?ve[t]:"idle"),r=be[j],g=je[d],x=a?"animate-pulse":"",u=o??b??j;return e.jsx("span",{role:"img","aria-label":u,className:`inline-block rounded-full ${g} ${r} ${x} ${f}`.trim(),title:b})}const ye={failed:"Failed","needs-auth":"Needs auth",pending:"Pending approval"};function Q(l,t){const a=t!=null&&t.ok?t.servers.find(d=>d.name===l):void 0;return!a||a.status==="unknown"?{state:"unprobed",label:"Not checked",probeStatus:(a==null?void 0:a.status)??null,badgeTone:"dim",dotState:"offline"}:a.status==="connected"?{state:"ready",label:"Ready",probeStatus:a.status,badgeTone:"good",dotState:"live"}:{state:"not-ready",label:ye[a.status],probeStatus:a.status,badgeTone:"warn",dotState:"attention"}}const W=(l,t)=>({type:"mcp",name:l,command:t.command,args:t.args,url:t.url}),Ne=["stdio","http","streamable-http","sse","ws"],we=new Set(["workspace"]),Se=new Set(["ide","tasks"]);function Ce(l,t,a){return l==="user"?`${t}/.claude.json`:a?`${a}/.mcp.json`:null}function ke(l){if(l.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(l),a=t.mcpServers??{};return{full:t,servers:a,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Ee(l,t){return JSON.stringify({...l,mcpServers:t},null,2)+`
|
|
2
|
+
`}function Te(l){let t=Object.keys(l).length+1,a=`server-${t}`;for(;l[a];)t+=1,a=`server-${t}`;return a}function Re(){const l=xe(),t=ue(),a=(t==null?void 0:t.cwd)??null,d=pe(s=>s.navFace),f=c.useRef(!1),b=c.useRef(d),[o,j]=c.useState(()=>d==="project"&&a?"project":"user"),[r,g]=c.useState(null),[x,u]=c.useState("installed"),[C,B]=c.useState("");c.useEffect(()=>{if(b.current!==d){if(b.current=d,f.current){f.current=!1;return}j(d==="project"&&a?"project":"user")}},[d,a]);const p=c.useMemo(()=>l?Ce(o,l,a):null,[l,o,a]),k=S(s=>s.files),n=S(s=>s.loadJson),v=S(s=>s.setDraft),m=S(s=>s.saveJson),K=S(s=>s.revert),R=S(s=>s.watchFile),se=S(s=>s.unwatchFile);c.useEffect(()=>{if(p)return k[p]||n(p),R(p),()=>se(p)},[p]);const[ae,F]=c.useState(null),[Y,q]=c.useState(null),[D,G]=c.useState(!1),A=c.useRef(0),L=c.useRef(!0);c.useEffect(()=>()=>{L.current=!1},[]);const V=async()=>{const s=++A.current;G(!0);try{const i=await window.api.mcp.status();if(!L.current||s!==A.current)return;q(i),i.ok||H.error(i.error??"MCP status probe failed")}catch(i){if(!L.current||s!==A.current)return;q(null),H.error(i.message||"MCP status probe failed")}finally{L.current&&s===A.current&&G(!1)}};if(c.useEffect(()=>{V()},[]),!l)return e.jsx(_,{title:"loading…"});if(x==="library")return e.jsx(J,{toolbar:e.jsx(I,{active:x,onChange:u}),children:e.jsx(ge,{})});if(o==="project"&&!a)return e.jsx(J,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(I,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(U,{scopes:["user","project"],active:o,onChange:s=>{f.current=!0,j(s)}})]}),children:e.jsx(_,{title:"no active project"})});if(!p)return e.jsx(_,{title:"loading…"});const w=k[p],{full:ne,servers:h,err:le}=w?ke(w.draftRaw):{full:{},servers:{},err:null},M=Object.keys(h).sort(),O=r?h[r]:null,P=s=>{F(null),v(p,Ee(ne,s))},re=()=>{const s=Te(h);P({...h,[s]:{type:"stdio",command:"",args:[]}}),g(s)},oe=s=>{const i={...h};delete i[s],P(i),r===s&&g(null)},ie=(s,i)=>{if(!i||i===s||h[i])return;const y={};for(const N of Object.keys(h))y[N===s?i:N]=h[N];P(y),g(i)},ce=(s,i)=>{P({...h,[s]:i})};return e.jsx(J,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(I,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(U,{scopes:["user","project"],active:o,onChange:s=>{f.current=!0,j(s)}}),e.jsxs("span",{className:"ml-3 px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-faint",children:[M.length," server",M.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:p}),e.jsx("div",{className:"flex-1"}),r&&O&&e.jsx(X,{scope:o,input:W(r,O),className:"mr-2"}),e.jsx("button",{onClick:V,disabled:D,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50 mr-2",children:D?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:re,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ new server"})]}),footer:w?e.jsx(he,{dirty:w.dirty,busy:w.busy,parseError:ae||le||w.parseError,lastSavedAt:w.lastSavedAt,onSave:async()=>{var y;F(null);const s=((y=w.diskData)==null?void 0:y.mcpServers)??{};for(const[N,E]of Object.entries(h)){if(JSON.stringify(E)===JSON.stringify(s[N]))continue;const $=Z(E);if($.length>0){fe.getState().show("error",`Not saved: "${N}" still contains placeholder ${$.map(de=>de.token).join(", ")} — replace it with a real value`);return}}const i=await m(p);i.ok||F(i.error??"save failed")},onRevert:()=>{F(null),K(p)}}):null,children:e.jsx(me,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:C,onChange:s=>B(s.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),M.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):M.filter(s=>!C||s.toLowerCase().includes(C.toLowerCase())).map(s=>{var N;const i=Q(s,Y),y=(N=h[s].description)==null?void 0:N.trim();return e.jsxs("button",{onClick:()=>g(s),className:`w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 ${r===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(te,{state:i.dotState,title:i.label}),e.jsx("span",{className:"truncate",children:s})]}),e.jsxs("span",{className:"ml-2 flex items-center gap-2 shrink-0",children:[(()=>{const E=Z(h[s]);return E.length>0?e.jsxs(z,{tone:"warn",title:`${o} scope · ${p}`,children:["unconfigured placeholder: ",E.map($=>$.token).join(", ")]}):null})(),e.jsx(z,{tone:i.badgeTone,children:i.label}),e.jsx(X,{interactive:!1,scope:o,input:W(s,h[s])}),e.jsx("span",{className:"text-fg-faint",children:h[s].type??"stdio"})]})]}),y?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:y,children:y}):null]},s)})]}),detail:r&&O?e.jsx(Fe,{name:r,server:O,connection:Q(r,Y),onTestConnection:V,testing:D,onRename:s=>ie(r,s),onChange:s=>ce(r,s),onRemove:()=>oe(r)}):e.jsx(_,{title:"select a server or click + new"})})})}const Je=c.memo(Re);function Fe({name:l,server:t,connection:a,onTestConnection:d,testing:f,onRename:b,onChange:o,onRemove:j}){var k;const r=t.type??"stdio",g=we.has(l),x=Se.has(l),u=(k=t.permissions)==null?void 0:k.tools,C=u===void 0?"inherit":u==="allow"?"allow":u==="deny"?"deny":"list",B=Array.isArray(u)?u:[],p=(t.disabledTools??[]).join(", ");return e.jsxs("div",{className:"p-4 space-y-4 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{state:a.dotState,size:"md",title:a.label}),e.jsx(z,{tone:a.badgeTone,children:a.label}),e.jsx("button",{onClick:d,disabled:f,className:"ml-auto px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50",children:f?"checking…":"test connection"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),e.jsx("input",{defaultValue:l,onBlur:n=>b(n.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("button",{onClick:j,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),e.jsx(T,{label:"description",value:t.description??"",onChange:n=>o({...t,description:n||void 0}),placeholder:"what this server does…"}),g?e.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:l})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):x?e.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:l})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),e.jsx("select",{value:r,onChange:n=>o({...t,type:n.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:Ne.map(n=>e.jsx("option",{value:n,children:n},n))}),r==="sse"?e.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),r==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"command",value:t.command??"",onChange:n=>o({...t,command:n}),placeholder:"npx / node / python …"}),e.jsx(T,{label:"args",value:(t.args??[]).join(" "),onChange:n=>o({...t,args:n.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(ee,{label:"env",value:t.env??{},onChange:n=>o({...t,env:n})})]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"url",value:t.url??"",onChange:n=>o({...t,url:n}),placeholder:"https://…"}),e.jsx(ee,{label:"headers",value:t.headers??{},onChange:n=>o({...t,headers:n})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:n=>o({...t,alwaysLoad:n.target.checked||void 0})}),e.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"enabled"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.enabled!==!1,onChange:n=>o({...t,enabled:n.target.checked?void 0:!1})}),e.jsx("span",{className:"text-fg-dim",children:"load this server in new sessions"})]})]}),e.jsx(T,{label:"disabledTools",value:p,onChange:n=>{const v=n.split(",").map(m=>m.trim()).filter(Boolean);o({...t,disabledTools:v.length?v:void 0})},placeholder:"comma-separated tool names to hide"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("select",{value:C,onChange:n=>{const v=n.target.value,m={...t};if(v==="inherit"){if(m.permissions){const{tools:K,...R}=m.permissions;m.permissions=Object.keys(R).length?R:void 0}}else v==="list"?m.permissions={...m.permissions??{},tools:[]}:m.permissions={...m.permissions??{},tools:v};o(m)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"inherit",children:"inherit (default)"}),e.jsx("option",{value:"allow",children:"allow all tools"}),e.jsx("option",{value:"deny",children:"deny all tools"}),e.jsx("option",{value:"list",children:"allowlist…"})]}),C==="list"?e.jsx("input",{value:B.join(", "),onChange:n=>{const v=n.target.value.split(",").map(m=>m.trim()).filter(Boolean);o({...t,permissions:{...t.permissions??{},tools:v}})},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 T({label:l,value:t,onChange:a,placeholder:d}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:l}),e.jsx("input",{value:t,onChange:f=>a(f.target.value),placeholder:d,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function ee({label:l,value:t,onChange:a}){const[d,f]=c.useState(""),[b,o]=c.useState(""),j=Object.entries(t);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:l}),e.jsxs("div",{className:"flex-1 space-y-1",children:[j.map(([r,g])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:r,onChange:x=>{const u={...t};delete u[r],u[x.target.value]=g,a(u)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("input",{value:g,onChange:x=>a({...t,[r]:x.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:()=>{const x={...t};delete x[r],a(x)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},r)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:d,onChange:r=>f(r.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("input",{value:b,onChange:r=>o(r.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("button",{onClick:()=>{d.trim()&&(a({...t,[d.trim()]:b}),f(""),o(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}export{Je as McpServers,Te as nextServerName};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{aF as i,aX as E,ap as e,$ as K,ae as vt,aK as kt,_ as Nt,ad as wt,L as jt,b4 as Ct,aY as St,n as $t}from"./index-DZ5TJKNI.js";import"./monaco-editor-BsIlgG7c.js";function Mt(s){return!s||!s.trim()?"default":s.replace(/[^a-zA-Z0-9]/g,"-")}const De=["bg-accent","bg-sage-dark","bg-honey","bg-fg-dim","bg-fg-faint","bg-hive-teal","bg-butter","bg-delta-bad"],ze=864e5,Et="MEMORY.md",Ie=2e3,we=s=>s.replace(/\.md$/,"");function At(s,t,n,l){var v,k,f;const x=new Map(((t==null?void 0:t.entries)??[]).map(o=>[o.name,o])),a=new Set(((v=t==null?void 0:t.index)==null?void 0:v.orphans)??[]),p=new Map;for(const o of(n==null?void 0:n.clusters)??[])for(const b of o.memberSlugs)p.has(b)||p.set(b,o.id);const m=s.filter(o=>o.name!==Et),c=new Map;for(const o of m){const b=we(o.name),u=((k=x.get(o.name))==null?void 0:k.outLinks)??((f=x.get(b))==null?void 0:f.outLinks)??[];for(const j of u){const M=we(j),y=c.get(M)??[];y.includes(b)||y.push(b),c.set(M,y)}}return m.map(o=>{const b=we(o.name),u=x.get(o.name)??x.get(b),j=(u==null?void 0:u.deadRefs)??[],M=(u==null?void 0:u.danglingLinks)??[],y=(u==null?void 0:u.stale)??!1;return{name:o.name,slug:b,path:o.path,description:(u==null?void 0:u.description)??"",bytes:o.bytes,mtimeMs:o.mtimeMs,ageDays:Math.floor((l-o.mtimeMs)/ze),stale:y,staleReasons:(u==null?void 0:u.reasons)??[],ageOnlyStale:y&&j.length===0,deadRefs:j,broken:j.length>0||M.length>0,danglingLinks:M,outLinks:(u==null?void 0:u.outLinks)??[],inLinks:c.get(b)??[],notIndexed:a.has(o.name)||a.has(b),clusterId:p.get(b)??null,type:(u==null?void 0:u.type)??null,originSessionId:(u==null?void 0:u.originSessionId)??null}})}function Lt(s,t){const n=new Set(t.filter(l=>l.stale).map(l=>l.slug));return((s==null?void 0:s.clusters)??[]).map((l,x)=>({id:l.id,name:l.name,summary:l.summary,memberSlugs:l.memberSlugs,linkCount:l.links.length,retireCount:l.links.filter(a=>/retire/i.test(a.label??"")).length,staleCount:l.memberSlugs.filter(a=>n.has(a)).length,dotClass:De[x%De.length]}))}function Ge(s,t,n){const l=t.trim().toLowerCase(),x=l?s.filter(a=>a.slug.toLowerCase().includes(l)||a.description.toLowerCase().includes(l)):s;return n===void 0?x:x.slice(0,n)}function de(s,t,n){let l;return t==="ask"||t==="clusters"||t==="archived"?[]:(t==="all"?l=s:t==="stale"?l=s.filter(x=>x.stale):t==="broken"?l=s.filter(x=>x.broken):t==="recent"?l=s.filter(x=>Date.now()-x.mtimeMs<=7*ze):t==="unindexed"?l=s.filter(x=>x.notIndexed):t==="cluster:unclustered"?l=s.filter(x=>x.clusterId===null):t.startsWith("cluster:")?l=s.filter(x=>x.clusterId===t.slice(8)):l=s,Ge(l,n))}function qe(s,t){const n=[...s];return t==="recent"?n.sort((l,x)=>x.mtimeMs-l.mtimeMs):t==="name"?n.sort((l,x)=>l.slug<x.slug?-1:l.slug>x.slug?1:0):n.sort((l,x)=>x.bytes-l.bytes),n}function Rt(s){return{all:s.length,stale:de(s,"stale","").length,broken:de(s,"broken","").length,recent:de(s,"recent","").length,unindexed:de(s,"unindexed","").length}}function Xe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"untitled_memory"}function Dt(s,t){const n=s===""?[]:s.split(`
|
|
2
|
+
`),l=t===""?[]:t.split(`
|
|
3
|
+
`);if(n.length>Ie||l.length>Ie)return[...n.map(k=>({sign:"−",text:k})),...l.map(k=>({sign:"+",text:k}))];const x=n.length,a=l.length,p=Array.from({length:x+1},()=>new Array(a+1).fill(0));for(let k=x-1;k>=0;k--)for(let f=a-1;f>=0;f--)p[k][f]=n[k]===l[f]?p[k+1][f+1]+1:Math.max(p[k+1][f],p[k][f+1]);const m=[];let c=0,v=0;for(;c<x&&v<a;)n[c]===l[v]?(c++,v++):p[c+1][v]>=p[c][v+1]?m.push({sign:"−",text:n[c++]}):m.push({sign:"+",text:l[v++]});for(;c<x;)m.push({sign:"−",text:n[c++]});for(;v<a;)m.push({sign:"+",text:l[v++]});return m}const F=s=>s instanceof Error?s.message:String(s);function Te(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return t?{front:t[0],body:s.slice(t[0].length)}:{front:"",body:s}}function It(s){return s.split(`
|
|
4
|
+
`).map(t=>t.trim()).find(t=>t.length>0)??""}function Tt(s,t){const n=s.kind==="agent"?s.agent:null,l=n?`${n.name}|${n.memoryScope??""}`:"",x=n!==null&&n.memoryScope===null,a=i.useMemo(()=>x?null:n&&n.memoryScope?{agent:{name:n.name,scope:n.memoryScope},...t?{cwd:t}:{}}:{workspace:Mt(t),...t?{cwd:t}:{}},[l,x,t]),p=n===null,[m,c]=i.useState(!0),[v,k]=i.useState([]),[f,o]=i.useState(null),[b,u]=i.useState(null),[j,M]=i.useState(!1),[y,C]=i.useState(""),[I,W]=i.useState(!0),[ee,xe]=i.useState([]),[q,A]=i.useState([]),[U,L]=i.useState({}),[me,ye]=i.useState(()=>Date.now()),X=i.useRef(a);X.current=a;const T=i.useCallback(async()=>{if(!a){k([]),o(null),u(null),xe([]),C(""),c(!1);return}try{const h=await window.api.memory.list(a);if(X.current!==a)return;k(h.entries??[]),C(h.dir??""),W(h.autoMemoryEnabled!==!1),h.error&&E.error(`Memory list failed: ${h.error}`);const[d,N]=await Promise.all([window.api.memory.stale(a).catch(w=>(E.error(`Memory staleness check failed: ${F(w)}`),null)),window.api.memory.listArchived(a).catch(()=>({names:[],error:null}))]);if(X.current!==a)return;o(d),xe(N.names??[]),ye(Date.now())}catch(h){E.error(`Memory list failed: ${F(h)}`)}finally{c(!1)}},[a]);i.useEffect(()=>{c(!0),u(null),T(),a&&p&&a.workspace&&window.api.memory.aggregate(a.workspace,!1,t??void 0).then(h=>{X.current===a&&u(h)}).catch(h=>E.error(`Memory clusters failed: ${F(h)}`))},[T]),i.useEffect(()=>{let h=!1;return(async()=>{try{const{agents:d}=await window.api.memory.agents(t??void 0);if(h)return;A(d);const N={};await Promise.all(d.filter(w=>w.memoryScope).map(async w=>{const z=await window.api.memory.list({agent:{name:w.name,scope:w.memoryScope},...t?{cwd:t}:{}});N[w.name]=(z.entries??[]).filter(O=>O.name!=="MEMORY.md").length})),h||L(N)}catch(d){h||E.error(`Memory agents failed: ${F(d)}`)}})(),()=>{h=!0}},[t]),i.useEffect(()=>{if(!y)return;const h=y;window.api.config.watch([h]);const d=window.api.config.onChanged(({path:N})=>{(N===h||N.startsWith(h+"/"))&&T()});return()=>{d(),window.api.config.unwatch([h])}},[y,T]);const _=i.useMemo(()=>At(v,f,b,me),[v,f,b,me]),te=i.useMemo(()=>Lt(b,_),[b,_]),ve=i.useMemo(()=>({generatedAt:(b==null?void 0:b.generatedAt)??null,running:j}),[b,j]),R=i.useCallback(async h=>{if(!a)return null;try{const d=await window.api.memory.read(h,a);return d.error?(E.error(`Memory read failed: ${d.error}`),null):d.content}catch(d){return E.error(`Memory read failed: ${F(d)}`),null}},[a]),$=i.useCallback(async(h,d)=>{try{const N=await d();return N.ok?(await T(),!0):(E.error(`${h} failed: ${N.error??"unknown error"}`),!1)}catch(N){return E.error(`${h} failed: ${F(N)}`),!1}},[T]),Q=i.useCallback(async(h,d)=>{if(!a)return!1;const N=await R(h);if(N===null)return!1;const{front:w}=Te(N);return $("Memory save",()=>window.api.memory.write(h,w+d,a))},[a,R,$]),V=i.useCallback(async(h,d)=>{if(!a)return null;const N=Xe(h),w=It(d);if(!await $("Memory create",()=>window.api.memory.create(N,w,a)))return null;const O=`---
|
|
5
|
+
name: ${N}
|
|
6
|
+
description: ${w}
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
${d}
|
|
10
|
+
`;return await $("Memory create",()=>window.api.memory.write(N,O,a))?N:null},[a,$]),H=i.useCallback(async h=>{var z,O;if(!a)return null;const d=await R(h);if(d===null||!await $("Memory delete",()=>window.api.memory.delete(h,a)))return null;const w=((O=(z=Te(d).front.match(/^description:\s*(.*)$/m))==null?void 0:z[1])==null?void 0:O.trim())??"";return async()=>{await $("Memory undo",()=>window.api.memory.create(h,w,a))&&await $("Memory undo",()=>window.api.memory.write(h,d,a))}},[a,R,$]),ue=i.useCallback(h=>a?$("Memory archive",()=>window.api.memory.archive(h,a)):Promise.resolve(!1),[a,$]),se=i.useCallback(h=>a?$("Memory restore",()=>window.api.memory.restore(h,a)):Promise.resolve(!1),[a,$]),ne=i.useCallback(h=>a?$("Memory verify",()=>window.api.memory.verify(h,a)):Promise.resolve(!1),[a,$]),re=i.useCallback(async(h,d)=>{if(!a)return!1;const N=await R(h);if(N===null)return!1;const w=N.split(`[[${d}]]`).join(d);return $("Memory link removal",()=>window.api.memory.write(h,w,a))},[a,R,$]),Z=i.useCallback(async()=>{if(!(!a||!p||!a.workspace)){M(!0);try{const h=await window.api.memory.aggregate(a.workspace,!0,t??void 0);h.error?E.error(`Memory clustering failed: ${h.error}`):u(h)}catch(h){E.error(`Memory clustering failed: ${F(h)}`)}finally{M(!1)}}},[a,p,t]),pe=i.useCallback(async(h,d)=>{const N=w=>({ok:!1,answer:"",citations:[],error:w});if(!a)return N("no memory store");try{const w=await window.api.memory.ask({question:h,target:a,contextName:d});return w.ok||E.error(`Memory ask failed: ${w.error??"unknown error"}`),w}catch(w){return E.error(`Memory ask failed: ${F(w)}`),N(F(w))}},[a]),Y=i.useCallback(async h=>{const d=N=>({ok:!1,action:"keep",summary:"",reason:"",content:"",fold:null,error:N});if(!a)return d("no memory store");try{const N=await window.api.memory.proposeFix({name:h,target:a});return N.ok||E.error(`Memory fix failed: ${N.error??"unknown error"}`),N}catch(N){return E.error(`Memory fix failed: ${F(N)}`),d(F(N))}},[a]),ae=i.useMemo(()=>({refresh:T,read:R,saveBody:Q,create:V,remove:H,archive:ue,restore:se,verify:ne,removeLink:re,regenerateClusters:Z,ask:pe,proposeFix:Y}),[T,R,Q,V,H,ue,se,ne,re,Z,pe,Y]);return{loading:m,target:a,dir:y,autoMemoryEnabled:I,rows:_,clusters:te,clustersMeta:ve,index:f==null?void 0:f.index,archived:ee,agents:q,agentCounts:U,actions:ae}}const _t={user:"user — all projects",project:"project — shared via git",local:"local — this machine only"},J="text-[10px] tracking-[.08em] font-semibold text-fg-faint",Qe="flex items-center gap-2 h-7 px-2.5 rounded-[5px] text-[13px] cursor-pointer hover:bg-muteband text-left w-full";function _e(s,t){return s.memoryScope===null?"off":String(t[s.name]??0)}function je({id:s,label:t,count:n,dot:l,active:x,mono:a,onClick:p,check:m}){return e.jsxs("button",{type:"button","data-testid":`mx-nav-${s}`,onClick:p,className:`${Qe} ${x?"bg-bg font-semibold text-fg":"text-fg-dim"}`,children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-sm shrink-0 ${l||"bg-transparent"}`}),e.jsx("span",{className:`flex-1 min-w-0 truncate ${a?"font-mono text-xs":""}`,children:t}),n!==void 0&&e.jsx("span",{className:`font-mono text-[11px] ${m&&n===0?"text-sage-dark":x?"text-fg":"text-fg-faint"}`,children:m&&n===0?"✓":n})]})}function Oe({label:s,value:t,max:n,tone:l}){const x=Math.min(100,Math.round(t/Math.max(1,n)*100));return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:[s," ",t,"/",n]}),e.jsx("div",{className:"h-1 rounded-full bg-bg-muteband overflow-hidden",children:e.jsx("div",{className:`h-full ${l}`,style:{width:`${x}%`}})})]})}const Ot=i.memo(function(t){var k,f;const[n,l]=i.useState(!1),x=i.useRef(null),a=t.scope.kind==="agent";i.useEffect(()=>{if(!n)return;const o=u=>{u.key==="Escape"&&l(!1)},b=u=>{x.current&&!x.current.contains(u.target)&&l(!1)};return document.addEventListener("keydown",o),document.addEventListener("mousedown",b),()=>{document.removeEventListener("keydown",o),document.removeEventListener("mousedown",b)}},[n]);const p=o=>{l(!1),t.onScope(o)},m=(o,b,u,j,M)=>e.jsx(je,{id:o,label:b,dot:u,count:j,check:M,active:t.view===o,onClick:()=>t.onView(o)}),c=t.scope.kind==="agent"?t.scope.agent:null,v=(k=t.index)!=null&&k.overBudget?"bg-accent":(f=t.index)!=null&&f.nearBudget?"bg-honey":"bg-sage-dark";return e.jsxs("nav",{"data-testid":"mx-nav",className:"w-[232px] shrink-0 flex flex-col gap-4 bg-bg-elev border-r border-rule-structural px-2.5 py-3.5 overflow-y-auto",children:[e.jsxs("div",{ref:x,className:"relative",children:[e.jsxs("button",{type:"button","data-testid":"mx-scope-card",onClick:()=>l(o=>!o),className:"w-full flex flex-col gap-0.5 px-2.5 py-2 border border-rule-structural rounded-md bg-bg cursor-pointer text-left hover:border-fg-faint",children:[e.jsx("span",{className:J,children:c?"SUBAGENT":"WORKSPACE"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-xs text-fg flex-1 min-w-0 truncate",children:c?c.name:t.workspaceName}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"▾"})]}),e.jsx("span",{className:"font-mono text-[10px] text-fg-faint truncate",children:c?c.agentFile:t.workspacePath}),c&&c.memoryScope&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:_t[c.memoryScope]})]}),n&&e.jsxs("div",{"data-testid":"mx-scope-menu",className:`absolute left-0 right-0 top-full mt-1 ${K.dialog} bg-bg-hi border border-rule-structural rounded-[7px] shadow-lg p-1 flex flex-col`,children:[e.jsxs("button",{type:"button",onClick:()=>p({kind:"workspace"}),className:"flex items-center gap-2 px-2 py-1.5 rounded-[5px] text-left hover:bg-bg-elev",children:[e.jsx("span",{className:"w-3 text-[11px] text-sage-dark",children:c?"":"✓"}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs text-fg truncate",children:t.workspaceName}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:"workspace"})]}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:t.workspaceCount})]}),t.agents.map(o=>e.jsxs("button",{type:"button",onClick:()=>p({kind:"agent",agent:o}),className:"flex items-center gap-2 px-2 py-1.5 rounded-[5px] text-left hover:bg-bg-elev",children:[e.jsx("span",{className:"w-3 text-[11px] text-sage-dark",children:(c==null?void 0:c.name)===o.name?"✓":""}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs text-fg truncate",children:o.name}),e.jsxs("span",{className:"text-[10.5px] text-fg-faint",children:["subagent",o.memoryScope?` · ${o.memoryScope}`:""]})]}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:_e(o,t.agentCounts)})]},o.name))]})]}),e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"BROWSE"}),m("all","All memories","",t.counts.all),m("ask","Ask",""),m("clusters","Clusters","",t.clusters.length)]}),e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"REVIEW"}),m("stale","Stale","bg-honey",t.counts.stale,!0),m("broken","Broken references","bg-accent",t.counts.broken,!0),m("recent","Changed this week","",t.counts.recent),m("unindexed","Not in index","",t.counts.unindexed,!0),t.archivedCount>0&&m("archived","Archived","",t.archivedCount)]}),!a&&e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"CLUSTERS"}),t.clusters.map(o=>e.jsx(je,{id:`cluster:${o.id}`,label:o.name,dot:o.dotClass,count:t.clusterCounts[o.id]??0,active:t.view===`cluster:${o.id}`,onClick:()=>t.onView(`cluster:${o.id}`)},o.id)),t.unclusteredCount>0&&e.jsx(je,{id:"cluster:unclustered",label:"Unclustered",dot:"bg-rule",count:t.unclusteredCount,active:t.view==="cluster:unclustered",onClick:()=>t.onView("cluster:unclustered")})]}),t.agents.length>0&&e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"SUBAGENT SCOPES"}),t.agents.map(o=>e.jsxs("button",{type:"button","data-testid":`mx-nav-agent:${o.name}`,onClick:()=>t.onScope({kind:"agent",agent:o}),className:`${Qe} text-fg-dim ${(c==null?void 0:c.name)===o.name?"bg-bg font-semibold":""}`,children:[e.jsx("span",{className:"font-mono text-xs flex-1 truncate",children:o.name}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:_e(o,t.agentCounts)})]},o.name))]}),t.index&&e.jsxs("div",{"data-testid":"mx-index-footer",className:"mt-auto flex flex-col gap-1.5 pt-3 border-t border-rule-inner",children:[e.jsx("span",{className:J,children:"MEMORY.md"}),e.jsx(Oe,{label:"lines",value:t.index.lines,max:t.index.maxLines,tone:v}),e.jsx(Oe,{label:"KB",value:Math.round(t.index.bytes/1024),max:Math.round(t.index.maxBytes/1024),tone:v}),t.index.dangling.length>0&&e.jsxs("span",{className:"text-[10.5px] text-accent-dark",children:[t.index.dangling.length," index lines point at missing files"]})]})]})}),Ft={recent:"name",name:"size",size:"recent"},Bt={recent:"Recent",name:"Name",size:"Size"},Ce="text-[9.5px] font-semibold tracking-[.06em] px-[5px] py-px rounded-[3px]";function Pt(s){return`${vt(s.bytes)} · ${s.ageDays>0?`${s.ageDays}d ago`:"just now"}`}const Kt=i.memo(function(t){return e.jsxs("div",{"data-testid":"mx-list",className:"flex flex-col min-h-0 border-r border-rule-structural",children:[e.jsxs("div",{className:"flex flex-col gap-[10px] px-[14px] pt-[14px] pb-[10px] border-b border-rule-structural",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:t.title}),e.jsx("span",{className:"text-[12px] text-fg-dim",children:t.rows.length}),e.jsx("span",{className:"flex-1"}),e.jsx("button",{type:"button","data-testid":"mx-list-new",onClick:t.onNew,className:"text-[12px] font-medium h-[26px] px-[10px] border border-rule-structural rounded-[5px] bg-bg-hi text-fg flex-none hover:border-fg",children:"+ New"})]}),e.jsxs("div",{className:"flex gap-[6px] items-center",children:[e.jsx("input",{"data-testid":"mx-list-filter",value:t.query,onChange:n=>t.onQuery(n.target.value),placeholder:"Filter by name or content…",className:"flex-1 min-w-0 h-7 border border-rule-structural rounded-[5px] px-[9px] text-[12px] text-fg bg-bg-hi outline-none"}),e.jsx("button",{type:"button","data-testid":"mx-list-sort",onClick:()=>t.onSort(Ft[t.sort]),className:"h-7 px-[9px] border border-rule-structural rounded-[5px] flex items-center text-[12px] text-fg whitespace-nowrap hover:border-fg-faint",children:`${Bt[t.sort]} ⇅`})]})]}),e.jsxs("div",{className:"overflow-auto flex-1 p-[6px]",children:[t.rows.map(n=>e.jsxs("div",{"data-testid":`mx-list-row-${n.name}`,onClick:()=>t.onSelect(n.name),className:`px-[10px] py-2 rounded-md cursor-pointer flex flex-col gap-[3px] hover:bg-bg-elev ${t.selected===n.name?"bg-muteband":""}`,children:[e.jsxs("div",{className:"flex items-center gap-[7px]",children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-[2px] flex-none ${t.clusterDot(n.clusterId)}`}),e.jsx("span",{className:"text-[13px] font-medium flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:n.slug}),n.stale&&e.jsx("span",{className:`${Ce} bg-butter/40 text-honey-dark`,children:"STALE"}),n.broken&&!n.stale&&e.jsx("span",{className:`${Ce} bg-accent-muted/30 text-accent-dark`,children:"BROKEN"}),n.notIndexed&&e.jsx("span",{className:`${Ce} bg-rule-inner text-fg-dim`,children:"NOT INDEXED"})]}),e.jsx("div",{className:"text-[11.5px] text-fg-dim pl-[14px] overflow-hidden text-ellipsis whitespace-nowrap",children:n.description}),e.jsx("div",{className:"font-mono text-[10.5px] text-fg-dim pl-[14px]",children:Pt(n)})]},n.name)),t.empty&&t.rows.length===0&&e.jsxs("div",{"data-testid":"mx-list-empty",className:"px-[18px] py-10 flex flex-col gap-2 items-start",children:[e.jsx("span",{className:"font-serif text-[17px] text-fg",children:t.empty.title}),e.jsx("span",{className:"text-[12.5px] leading-normal text-fg-dim",children:t.empty.body}),e.jsx("button",{type:"button",onClick:t.empty.onAction,className:"mt-[6px] text-[12px] font-medium h-7 px-3 border border-rule-structural rounded-[5px] bg-bg-hi text-fg",children:t.empty.action})]})]})]})}),Se="text-xs font-medium h-[26px] px-2.5 border border-rule-structural rounded-[5px] bg-bg text-fg hover:border-fg",ge="px-[7px] py-0.5 rounded bg-bg-elev",be="px-2.5 py-[7px] rounded-[5px] text-left text-[12.5px] hover:bg-bg-elev",Wt="max-w-[640px] text-sm leading-[1.65] text-fg flex flex-col gap-3 [&_p]:m-0 [&_h4]:mt-1.5 [&_h4]:mb-0 [&_h4]:text-[11px] [&_h4]:tracking-[.08em] [&_h4]:font-semibold [&_h4]:text-accent [&_code]:font-mono [&_code]:text-[12.5px] [&_code]:bg-bg-elev [&_code]:px-1 [&_code]:rounded-[3px] [&_ul]:m-0 [&_ul]:pl-5 [&_ul]:list-disc [&_ol]:m-0 [&_ol]:pl-5 [&_ol]:list-decimal",Fe={update:{apply:"Apply",hint:"Writes the file"},delete:{apply:"Archive",hint:"Moves to .archive — undoable"},keep:{apply:"Mark verified",hint:"Touches the file, clears age staleness"},fold:{apply:"Copy for an Epic",hint:"Memory stays until the doc change lands"}};function Ut(s){var t;return s.action==="delete"?"Suggested: archive this memory":s.action==="fold"?`Suggested: move into ${((t=s.fold)==null?void 0:t.target)??"a doc"}`:s.action==="keep"?"Looks accurate — keep":"Suggested update"}function Vt(s){return s<1024?`${s} B`:`${(s/1024).toFixed(1)} KB`}function Ht(s){return s<=0?"just now":`${s}d ago`}function Yt(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return(t?s.slice(t[0].length):s).trim()}function zt(s){return s.replace(/^\*\*Why:\*\*[ \t]*/gim,`#### WHY
|
|
11
|
+
|
|
12
|
+
`).replace(/^\*\*How to apply:\*\*[ \t]*/gim,`#### HOW TO APPLY
|
|
13
|
+
|
|
14
|
+
`)}const Gt=i.memo(function(t){const{row:n,fix:l}=t,[x,a]=i.useState(!1),p=i.useMemo(()=>t.content===null||t.mode!=="read"?"":kt(zt(Yt(t.content))),[t.content,t.mode]),m=c=>()=>{a(!1),c()};return e.jsxs("div",{"data-testid":"mx-reader",className:"flex flex-col flex-1 min-w-0 min-h-0",children:[e.jsxs("div",{className:"px-[22px] pt-3.5 pb-3 border-b border-rule-structural flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-sm ${t.clusterDot}`}),e.jsx("span",{children:t.clusterName}),e.jsx("span",{className:"flex-1"}),!t.archived&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex border border-rule-structural rounded-[5px] overflow-hidden",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-mode-read",onClick:()=>t.onMode("read"),className:`px-2.5 py-[3px] text-fg ${t.mode==="read"?"bg-muteband":""}`,children:"Read"}),e.jsx("button",{type:"button","data-testid":"mx-reader-mode-source",onClick:()=>t.onMode("source"),className:`px-2.5 py-[3px] text-fg border-l border-rule-structural ${t.mode==="source"?"bg-muteband":""}`,children:"Source"})]}),e.jsx("button",{type:"button","data-testid":"mx-reader-edit",onClick:t.onEdit,className:Se,children:"Edit"}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-more",onClick:()=>a(c=>!c),className:`${Se} !px-2`,children:"⋯"}),x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`fixed inset-0 ${K.dialog}`,onClick:()=>a(!1)}),e.jsxs("div",{className:`absolute right-0 top-8 w-[200px] ${K.dialog} bg-bg-hi border border-rule-structural rounded-[7px] shadow-lg p-1 flex flex-col text-fg`,children:[e.jsx("button",{type:"button",className:be,onClick:m(t.onCopyPath),children:"Copy path"}),e.jsx("button",{type:"button",className:be,onClick:m(t.onReveal),children:"Reveal in folder"}),e.jsx("div",{className:"h-px bg-rule-inner mx-1.5 my-1"}),e.jsx("button",{type:"button",className:be,onClick:m(t.onArchive),children:"Archive"}),e.jsx("button",{type:"button",className:`${be} text-accent`,onClick:m(t.onAskDelete),children:"Delete…"})]})]})]})]})]}),e.jsx("div",{className:"font-mono text-[18px] font-medium text-fg break-all",children:n.slug}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11.5px] text-fg-dim",children:[n.type&&e.jsxs("span",{className:ge,children:["type · ",n.type]}),e.jsx("span",{className:ge,children:Vt(n.bytes)}),e.jsxs("span",{className:ge,children:["modified ",Ht(n.ageDays)]}),n.originSessionId&&e.jsxs("span",{className:`${ge} font-mono text-[10.5px]`,children:["session ",n.originSessionId.slice(0,8)]})]})]}),!t.archived&&!n.stale&&l.state==="idle"&&e.jsxs("div",{className:"mx-[22px] mt-3 flex items-center gap-2 text-[11px] text-fg-dim",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-fix",onClick:t.onFix,className:"text-xs font-medium h-[26px] px-2.5 rounded-[5px] border border-rule-structural text-fg hover:border-fg",children:"Review with assistant"}),e.jsx("span",{children:"uses Claude"})]}),t.archived&&e.jsxs("div",{className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-bg-elev flex items-center gap-2.5 text-[12.5px] text-fg-dim",children:[e.jsx("span",{className:"flex-1",children:"Archived — read-only. Claude no longer loads this memory."}),e.jsx("button",{type:"button","data-testid":"mx-reader-restore",onClick:t.onRestore,className:Se,children:"Restore"})]}),!t.archived&&n.stale&&l.state==="idle"&&e.jsxs("div",{"data-testid":"mx-reader-stale",className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-butter/40 text-honey-dark flex gap-2.5 items-center text-[12.5px]",children:[e.jsxs("div",{className:"flex-1 flex flex-col gap-0.5",children:[e.jsx("b",{className:"font-semibold",children:t.appliedStill?`Applied — still flagged: ${n.staleReasons[0]??"needs review"}`:`Stale — ${n.staleReasons[0]??"needs review"}`}),n.deadRefs.length>0&&e.jsx("span",{className:"font-mono text-[11px]",children:n.deadRefs.join(" · ")})]}),e.jsx("span",{className:"text-[11px]",children:"uses Claude"}),e.jsx("button",{type:"button","data-testid":"mx-reader-fix",onClick:t.onFix,className:"text-xs font-medium h-[26px] px-2.5 rounded-[5px] bg-fg text-bg",children:"Fix with assistant"}),n.ageOnlyStale&&e.jsx("button",{type:"button","data-testid":"mx-reader-verify",onClick:t.onVerify,className:"text-xs font-medium h-[26px] px-2.5 rounded-[5px] border border-honey text-honey-dark",children:"Mark verified"})]}),!t.archived&&l.state==="checking"&&e.jsxs("div",{className:"mx-[22px] mt-3 p-3 rounded-md border border-dashed border-honey bg-butter/20 text-[12.5px] text-honey-dark flex items-center gap-2.5",children:[e.jsx("span",{className:"font-mono text-accent",children:"●○○"}),"Assistant is checking ",n.deadRefs.length>0?`${n.deadRefs.length} references`:"this memory"," against the repo…"]}),!t.archived&&l.state==="proposed"&&e.jsxs("div",{className:"mx-[22px] mt-3 border border-honey rounded-md overflow-hidden bg-bg-hi",children:[e.jsx("div",{className:"px-3 py-[9px] bg-butter/40 text-[12.5px] text-honey-dark font-semibold",children:Ut(l)}),e.jsxs("div",{className:"px-3 py-2 text-[12.5px] text-fg flex flex-col gap-0.5",children:[e.jsx("span",{"data-testid":"mx-reader-summary",children:l.summary}),l.reason&&e.jsx("span",{"data-testid":"mx-reader-reason",className:"text-fg-dim",children:l.reason})]}),l.action==="fold"&&l.fold&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-1.5 border-t border-rule-inner text-[11.5px] text-fg-dim font-mono break-all",children:[l.fold.target," · ",l.fold.anchor||"append at end"]}),l.fold.insert.split(`
|
|
15
|
+
`).map((c,v)=>e.jsxs("div",{className:"grid grid-cols-[20px_1fr] px-3 py-1.5 font-mono text-xs leading-normal border-t border-rule-inner bg-sage/20 text-sage-dark",children:[e.jsx("span",{children:"+"}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:c})]},v))]}),l.action==="update"&&l.diff.map((c,v)=>e.jsxs("div",{className:`grid grid-cols-[20px_1fr] px-3 py-1.5 font-mono text-xs leading-normal border-t border-rule-inner ${c.sign==="−"?"bg-accent-muted/30 text-accent-dark":c.sign==="+"?"bg-sage/20 text-sage-dark":"text-fg-dim"}`,children:[e.jsx("span",{children:c.sign}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:c.text})]},v)),e.jsxs("div",{className:"flex gap-2 px-3 py-2.5 border-t border-rule-structural items-center",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-apply",onClick:t.onApplyFix,className:"text-xs font-medium h-7 px-3 rounded-[5px] bg-fg text-bg",children:Fe[l.action].apply}),e.jsx("button",{type:"button","data-testid":"mx-reader-discard",onClick:t.onDiscardFix,className:"text-xs font-medium h-7 px-3 rounded-[5px] border border-rule text-fg",children:"Discard"}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-[11.5px] text-fg-dim",children:Fe[l.action].hint})]})]}),n.broken&&!n.stale&&e.jsx("div",{className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-accent-muted/30 text-[12.5px] text-accent-dark",children:"Broken reference — a link or path in this memory points at nothing. See the red items in Links."}),n.notIndexed&&e.jsx("div",{className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-butter/40 text-[12.5px] text-honey-dark",children:"Claude won't load this — it has no line in MEMORY.md."}),e.jsx("div",{className:"flex-1 overflow-auto px-[22px] pt-4 pb-[22px]",children:t.content===null?e.jsx("div",{className:"text-xs text-fg-faint",children:"Loading…"}):t.mode==="source"?e.jsx("pre",{className:"m-0 px-4 py-3.5 bg-fg text-bg-elev rounded-md font-mono text-xs leading-[1.7] whitespace-pre-wrap",children:t.content}):e.jsxs("div",{className:Wt,children:[n.description&&e.jsx("p",{className:"font-serif text-[17px] leading-normal text-fg",children:n.description}),e.jsx("div",{className:"contents",dangerouslySetInnerHTML:{__html:p}})]})}),e.jsx("div",{className:"px-[22px] py-2 border-t border-rule-structural font-mono text-[10.5px] text-fg-dim whitespace-nowrap overflow-hidden text-ellipsis",children:n.path})]})});function qt({mode:s,name:t,title:n,onTitle:l,body:x,onBody:a,onSave:p,onCancel:m,saving:c,dirty:v}){if(s==="none")return e.jsxs("div",{"data-testid":"mx-editor-none",className:"flex-1 flex flex-col items-center justify-center text-center gap-1.5 p-10",children:[e.jsx("div",{className:"font-serif text-[18px] text-fg",children:"No memory selected"}),e.jsx("div",{className:"text-[13px] text-fg-dim",children:"Pick one from the list, or press /."})]});const k=c||s==="edit"&&!v,f=o=>{(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="s"?(o.preventDefault(),k||p()):o.key==="Escape"&&(o.preventDefault(),m())};return e.jsxs("div",{"data-testid":"mx-editor",className:"flex-1 min-h-0 flex flex-col",onKeyDown:f,children:[e.jsxs("div",{className:"flex items-center gap-2 px-[22px] pt-3.5 pb-3 border-b border-rule-structural",children:[e.jsx("h2",{className:"flex-1 min-w-0 truncate font-mono text-[15px] font-medium text-fg",children:s==="new"?"New memory":`Editing ${t??""}`}),e.jsx("button",{type:"button","data-testid":"mx-editor-cancel",onClick:m,className:"h-7 px-3 rounded-[5px] border border-rule-structural bg-bg text-xs font-medium text-fg",children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"mx-editor-save",disabled:k,onClick:p,className:"h-7 px-3.5 rounded-[5px] bg-accent text-white text-xs font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:"Save"})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col gap-2.5 px-[22px] py-4",children:[s==="new"&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{htmlFor:"mx-editor-name",className:"text-[11px] tracking-[.06em] font-semibold text-fg-faint",children:"NAME"}),e.jsx("input",{id:"mx-editor-name","data-testid":"mx-editor-name",value:n,onChange:o=>l(o.target.value),placeholder:"e.g. deploy freeze fridays",className:"h-8 px-2.5 rounded-[5px] border border-rule bg-bg-hi font-mono text-[13px] font-normal text-fg outline-none"}),n.trim()!==""&&e.jsxs("div",{className:"font-mono text-[11px] text-fg-faint",children:["→ ",Xe(n),".md"]})]}),e.jsx("textarea",{"data-testid":"mx-editor-body",value:x,onChange:o=>a(o.target.value),spellCheck:!1,className:"flex-1 min-h-0 w-full resize-none px-3.5 py-3 rounded-md border border-rule bg-bg-hi font-mono text-[13px] leading-[1.7] text-fg outline-none"}),e.jsxs("div",{className:"flex items-center gap-2 text-[11.5px] text-fg-faint",children:[e.jsx("span",{children:`Markdown. Frontmatter is ${s==="new"?"added":"kept"} on save. Saving marks the memory verified.`}),v&&s==="edit"&&e.jsx("span",{className:"text-accent font-semibold",children:"unsaved"})]})]})]})}const Be=i.memo(qt),Pe="text-[10px] tracking-[.08em] font-semibold text-fg-dim",Xt="flex flex-col gap-px px-2 py-[6px] rounded-[5px] cursor-pointer bg-bg border text-left hover:border-fg-faint";function Ke({testid:s,slug:t,sub:n,dangling:l,onClick:x}){return e.jsxs("button",{type:"button","data-testid":s,onClick:x,className:`${Xt} ${l?"border-accent-muted":"border-rule-inner"}`,children:[e.jsx("span",{className:`text-[12px] font-medium overflow-hidden text-ellipsis whitespace-nowrap ${l?"text-accent":""}`,children:t}),e.jsx("span",{className:`text-[10.5px] ${l?"text-accent":"text-fg-dim"}`,children:n})]})}const Qt=i.memo(function({row:t,onOpen:n,onRemoveLink:l,onAskAbout:x}){return e.jsx("aside",{"data-testid":"mx-links",className:"bg-bg-elev border-l border-rule-structural px-[14px] py-4 flex flex-col gap-[18px] overflow-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-[6px]",children:[e.jsxs("span",{className:Pe,children:["LINKS TO · ",t.outLinks.length]}),t.outLinks.map(a=>{const p=t.danglingLinks.includes(a);return e.jsx(Ke,{testid:`mx-link-out-${a}`,slug:a,dangling:p,sub:p?"missing · click to remove link":"wikilink",onClick:()=>p?l(a):n(a)},a)}),t.outLinks.length===0&&e.jsx("span",{className:"text-[12px] text-fg-dim",children:"No outgoing links."})]}),e.jsxs("div",{className:"flex flex-col gap-[6px]",children:[e.jsxs("span",{className:Pe,children:["LINKED FROM · ",t.inLinks.length]}),t.inLinks.map(a=>e.jsx(Ke,{testid:`mx-link-in-${a}`,slug:a,dangling:!1,sub:"wikilink",onClick:()=>n(a)},a)),t.inLinks.length===0&&e.jsx("span",{className:"text-[12px] text-fg-dim",children:"Nothing links here yet."})]}),e.jsxs("button",{type:"button","data-testid":"mx-links-ask",onClick:x,className:"mt-auto flex flex-col gap-[6px] p-[10px] border border-dashed border-rule rounded-[6px] cursor-pointer text-left hover:border-fg",children:[e.jsx("span",{className:"text-[12px] text-fg",children:"Ask about this memory"}),e.jsx("span",{className:"h-7 border border-rule-structural rounded-[5px] bg-bg-hi px-2 flex items-center text-[11.5px] text-fg-dim",children:"Is this still accurate?"})]})]})})}),Zt=["What changed this week?","Find contradictions","Summarize stale memories","remember …"],Jt=["Is this still accurate?","What links here?","Summarize it"],es=/^remember\b[\s:,-]*/i,We="text-xs font-medium h-[26px] px-2.5 rounded-[5px] bg-fg text-bg",ts=s=>s.charAt(0).toUpperCase()+s.slice(1),ss=i.memo(function({rows:t,context:n,onClearContext:l,onAsk:x,onOpen:a,onReverify:p,onDraft:m}){const[c,v]=i.useState(""),[k,f]=i.useState(!1),[o,b]=i.useState(null),u=async()=>{const y=c.trim();if(!y||k)return;if(/^remember\b/i.test(y)){b({kind:"draft",question:y,text:ts(y.replace(es,""))}),v("");return}f(!0);let C=null;try{C=await x(y,n)}catch{C=null}f(!1),!(!C||!C.ok)&&(b({kind:"answer",question:y,answer:C.answer,citations:C.citations}),v(""))},j=(o==null?void 0:o.kind)==="answer"?o.citations.map(y=>({slug:y,row:t.find(C=>C.slug===y||C.name===y)})):[],M=j.filter(y=>{var C;return(C=y.row)==null?void 0:C.stale}).length;return e.jsxs("div",{"data-testid":"mx-ask",className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"px-7 py-4 border-b border-rule-structural flex items-center gap-2.5",children:[e.jsx("span",{className:"font-serif text-[20px]",children:"Ask"}),e.jsx("span",{className:"text-xs text-fg-dim flex-1",children:"Search and edit this scope's memories in plain language. Answers cite the files they used."}),n&&e.jsxs("span",{"data-testid":"mx-ask-context",className:"flex items-center gap-1.5 pl-2 pr-1 py-[3px] border border-rule rounded-[5px] bg-bg-elev text-xs",children:["About ",e.jsx("span",{className:"font-mono text-[11.5px]",children:n}),e.jsx("button",{"aria-label":"Clear context",onClick:l,className:"px-1.5 text-fg-dim hover:text-accent",children:"×"})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-7 py-6 flex flex-col gap-5 max-w-[820px]",children:[!o&&!k&&e.jsxs("div",{className:"my-auto flex flex-col gap-1.5 text-fg-dim text-[13px]",children:[e.jsx("span",{className:"font-serif text-[20px] text-fg",children:"What do you want to know?"}),e.jsx("span",{children:'Ask about a symptom, a file or a past decision, or start with "remember" to save something new.'})]}),o&&e.jsx("div",{className:"self-end max-w-[520px] px-3.5 py-2.5 rounded-[10px] bg-fg text-bg text-[14px]",children:o.question}),(o==null?void 0:o.kind)==="answer"&&e.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px] leading-[1.65] text-fg max-w-[680px]",children:[e.jsx("p",{className:"m-0",children:o.answer}),e.jsx("div",{className:"flex flex-wrap gap-1.5 items-center",children:j.map((y,C)=>{var I;return e.jsxs("button",{"data-testid":`mx-ask-cite-${y.slug}`,onClick:()=>{var W;return a(((W=y.row)==null?void 0:W.name)??y.slug)},className:"flex items-center gap-1.5 px-[9px] py-1 border border-rule-structural rounded-[5px] bg-bg text-xs hover:border-fg",children:[e.jsxs("span",{className:"font-mono text-[10.5px] text-accent",children:["[",C+1,"]"]}),e.jsx("span",{children:y.slug}),y.row&&e.jsxs("span",{className:"text-fg-dim",children:[y.row.ageDays,"d"]}),((I=y.row)==null?void 0:I.stale)&&e.jsx("span",{className:"text-[9.5px] font-semibold px-1 rounded-[3px] bg-butter/40 text-honey-dark",children:"STALE"})]},y.slug)})}),M>0&&e.jsxs("div",{className:"px-3 py-2.5 rounded-md bg-butter/40 text-[12.5px] text-fg flex items-center gap-2.5",children:[e.jsxs("span",{className:"flex-1",children:[M," of these ",M===1?"is":"are"," flagged stale. Re-verify against the current code?"]}),e.jsx("button",{onClick:p,className:We,children:"Re-verify"})]})]}),(o==null?void 0:o.kind)==="draft"&&e.jsxs("div",{className:"max-w-[560px] border border-rule rounded-lg bg-bg-hi p-3.5 flex flex-col gap-2",children:[e.jsx("span",{"data-testid":"mx-ask-draft",className:"text-[10px] tracking-[.08em] text-sage-dark font-semibold",children:"DRAFT MEMORY · NOT SAVED YET"}),e.jsx("span",{className:"font-serif text-base",children:o.text}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>m(o.text),className:`${We} h-7 px-3`,children:"Review draft"}),e.jsx("span",{className:"text-xs text-fg-dim self-center",children:"Opens it in the editor before anything is written"})]})]}),k&&e.jsx("span",{className:"text-xs text-fg-dim",children:"Thinking…"})]}),e.jsxs("div",{className:"px-7 pt-3 pb-4 border-t border-rule-structural flex flex-col gap-2.5",children:[e.jsx("div",{className:"flex gap-1.5 flex-wrap items-center",children:(n?Jt:Zt).map(y=>e.jsx("button",{onClick:()=>v(y),className:"px-2.5 py-1 border border-rule-structural rounded-[14px] text-xs text-fg-dim hover:bg-bg-elev",children:y},y))}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{"data-testid":"mx-ask-input",value:c,onChange:y=>v(y.target.value),onKeyDown:y=>{y.key==="Enter"&&u()},placeholder:"Ask, or say “remember …” to add a memory",className:"flex-1 h-11 border border-rule rounded-md bg-bg-hi px-3 text-[13px] text-fg focus:outline-none focus:border-fg-faint"}),e.jsx(Nt,{}),e.jsx("button",{"data-testid":"mx-ask-send",onClick:()=>void u(),disabled:k,className:"h-11 px-4 rounded-md bg-accent text-white text-[13px] font-medium disabled:opacity-40",children:"Send"}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"uses Claude"})]})]})]})}),Ue="text-xs font-medium h-[26px] px-2.5 border border-rule-structural rounded-[5px] bg-bg text-fg hover:border-fg disabled:opacity-50 disabled:cursor-default",Ve="text-[11px] text-fg-faint",ns=i.memo(function({clusters:t,rows:n,generatedAt:l,running:x,unclusteredCount:a,available:p,onRegenerate:m,onOpenCluster:c,onOpen:v}){const k=i.useMemo(()=>new Map(n.map(f=>[f.slug,f])),[n]);return p?l===null&&t.length===0?e.jsxs("div",{"data-testid":"mx-clusters",className:"flex-1 flex flex-col items-center justify-center gap-2 p-6 text-center",children:[e.jsx("div",{className:"font-serif text-[20px] text-fg",children:"No clusters yet"}),e.jsx("button",{type:"button","data-testid":"mx-clusters-regenerate",className:Ue,disabled:x,onClick:m,children:x?"Generating…":"Generate"}),e.jsx("span",{className:Ve,children:"uses Claude · up to 3 min"})]}):e.jsxs("div",{"data-testid":"mx-clusters",className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-rule-structural flex items-center gap-2.5",children:[e.jsx("span",{className:"font-serif text-[20px] text-fg",children:"Clusters"}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["Generated ",wt(l,Date.now())," from shared references and links"]}),e.jsx("span",{className:"flex-1"}),a>0&&e.jsxs("span",{className:"text-xs text-honey-dark px-2 py-0.5 rounded bg-butter/40",children:[a," unclustered"]}),e.jsx("button",{type:"button","data-testid":"mx-clusters-regenerate",className:Ue,disabled:x,onClick:m,children:x?"Generating…":"Regenerate"}),e.jsx("span",{className:Ve,children:"uses Claude"})]}),e.jsx("div",{className:"flex-1 overflow-auto px-6 py-[18px] grid grid-cols-2 gap-4 content-start",children:t.map(f=>e.jsxs("div",{"data-testid":`mx-cluster-${f.id}`,className:"bg-bg-hi border border-rule-structural rounded-lg p-4 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-[9px] h-[9px] rounded-[2px] shrink-0 ${f.dotClass}`}),e.jsx("span",{className:"font-serif text-[17px] text-fg min-w-0 flex-1",children:f.name}),e.jsxs("button",{type:"button","data-testid":`mx-cluster-open-${f.id}`,className:"text-xs text-accent hover:text-fg",onClick:()=>c(f.id),children:["Open ",f.memberSlugs.length," →"]})]}),e.jsx("span",{className:"text-[12.5px] leading-normal text-fg-dim",children:f.summary}),e.jsx("div",{className:"flex flex-wrap gap-[5px] items-center",children:f.memberSlugs.map(o=>{const b=k.get(o);return e.jsx("button",{type:"button",className:`font-mono text-[11px] px-[7px] py-[3px] rounded border border-rule-inner text-fg hover:border-fg ${b!=null&&b.stale?"bg-butter/40":"bg-bg"}`,onClick:()=>v((b==null?void 0:b.name)??`${o}.md`),children:o},o)})}),e.jsxs("div",{className:"flex gap-3.5 text-[11.5px] text-fg-dim border-t border-rule-inner pt-[9px]",children:[e.jsxs("span",{children:[f.linkCount," links"]}),e.jsxs("span",{children:[f.retireCount," retires"]}),e.jsxs("span",{className:"text-honey-dark",children:[f.staleCount," stale"]})]})]},f.id))})]}):e.jsx("div",{"data-testid":"mx-clusters",className:"flex-1 p-6 text-[13px] text-fg-dim",children:"Clusters are available for workspace memory."})});function rs({open:s,rows:t,clusterDot:n,onPick:l,onAsk:x,onClose:a}){const[p,m]=i.useState(""),[c,v]=i.useState(0);if(i.useEffect(()=>{s&&(m(""),v(0))},[s]),!s)return null;const k=Ge(qe(t,"recent"),p,6),f=k.length,o=u=>{u===f?x(p):l(k[u].name)},b=u=>{u.key==="ArrowDown"?(u.preventDefault(),v(j=>Math.min(j+1,f))):u.key==="ArrowUp"?(u.preventDefault(),v(j=>Math.max(j-1,0))):u.key==="Enter"?(u.preventDefault(),o(Math.min(c,f))):u.key==="Escape"&&(u.preventDefault(),a())};return e.jsxs("div",{"data-testid":"mx-palette",children:[e.jsx("div",{className:`absolute inset-0 ${K.dialog} bg-fg/30`,onClick:a}),e.jsxs("div",{className:`absolute left-1/2 top-[84px] -translate-x-1/2 w-[580px] ${K.dialog} bg-bg-hi border border-rule rounded-[10px] shadow-2xl overflow-hidden`,children:[e.jsx("input",{"data-testid":"mx-palette-input",autoFocus:!0,value:p,onChange:u=>{m(u.target.value),v(0)},onKeyDown:b,placeholder:"Search memories or ask a question…",className:"w-full h-[50px] border-0 border-b border-rule-inner px-[18px] text-[15px] text-fg bg-transparent outline-none"}),e.jsxs("div",{className:"p-[6px] flex flex-col max-h-[380px] overflow-auto",children:[k.map((u,j)=>e.jsxs("div",{"data-testid":"mx-palette-row",onClick:()=>o(j),onMouseEnter:()=>v(j),className:`flex items-center gap-[9px] px-3 py-2 rounded-[6px] cursor-pointer ${j===c?"bg-bg-deep":""}`,children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-[2px] flex-none ${n(u.clusterId)}`}),e.jsx("span",{className:"font-mono text-[12.5px] text-fg flex-none",children:u.slug}),e.jsx("span",{className:"text-[12px] text-fg-dim overflow-hidden text-ellipsis whitespace-nowrap",children:u.description})]},u.name)),e.jsxs("div",{"data-testid":"mx-palette-ask",onClick:()=>o(f),onMouseEnter:()=>v(f),className:`flex items-center gap-[9px] px-3 py-[10px] mt-1 border-t border-rule-inner cursor-pointer text-[13px] text-accent ${c===f?"bg-bg-deep":""}`,children:[e.jsx("span",{className:"font-mono text-[11px]",children:"↵"}),"Ask “",p,"” …",e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-[11px] text-fg-dim",children:"opens Ask"})]})]}),e.jsxs("div",{className:"px-[14px] py-2 border-t border-rule-inner text-[11px] text-fg-dim flex gap-[14px]",children:[e.jsx("span",{children:"↑↓ move"}),e.jsx("span",{children:"↵ open"}),e.jsx("span",{children:"esc close"})]})]})]})}const $e="text-[12.5px] font-medium h-8 px-3 rounded-[5px] cursor-pointer text-fg";function as({open:s,name:t,inbound:n,onArchive:l,onCancel:x,onConfirm:a}){return i.useEffect(()=>{if(!s)return;const p=m=>{m.key==="Escape"&&x()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s,x]),s?e.jsxs("div",{"data-testid":"mx-delete-dialog",children:[e.jsx("div",{className:`absolute inset-0 ${K.dialog} bg-fg/30`,onClick:x}),e.jsxs("div",{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[440px] ${K.dialog} bg-bg-hi border border-rule rounded-[10px] shadow-lg p-5 flex flex-col gap-3`,children:[e.jsx("span",{className:"font-serif text-[20px] text-fg",children:"Delete this memory?"}),e.jsxs("span",{className:"font-mono text-[12.5px] text-fg",children:[t,".md"]}),n>0&&e.jsxs("div",{className:"px-3 py-[10px] rounded-[6px] bg-accent-muted/30 text-[12.5px] leading-normal text-accent-dark",children:[n," memories link here. Those links will show as broken until removed."]}),e.jsx("span",{className:"text-[12.5px] text-fg-dim",children:"The file is removed from disk. You can undo for a few seconds afterwards. To keep it out of sessions without deleting it, use Archive."}),e.jsxs("div",{className:"flex gap-2 justify-end mt-1",children:[e.jsx("button",{type:"button",onClick:l,className:`${$e} border border-rule mr-auto`,children:"Archive instead"}),e.jsx("button",{type:"button",onClick:x,className:`${$e} border border-rule bg-bg`,children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"mx-delete-confirm",onClick:a,className:`${$e} border-0 px-[14px] bg-accent text-white`,children:"Delete"})]})]})]}):null}const os=6e3;function ls({message:s,onUndo:t,onClose:n}){return i.useEffect(()=>{if(s===null)return;const l=setTimeout(n,os);return()=>clearTimeout(l)},[s]),s===null?null:e.jsxs("div",{"data-testid":"mx-undo-bar",className:`absolute bottom-[22px] left-1/2 -translate-x-1/2 ${K.dialog} flex items-center gap-[14px] py-[10px] pl-4 pr-3 rounded-lg bg-fg text-bg text-[13px] shadow-lg whitespace-nowrap`,children:[e.jsx("span",{children:s}),t&&e.jsx("button",{type:"button","data-testid":"mx-undo",onClick:t,className:"font-semibold text-accent-muted hover:text-white",children:"Undo"}),e.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss",className:"text-fg-faint hover:text-white px-1",children:"×"})]})}const Ze="sm.memoryTab.scope",ce="agent:",Me=`One-line summary of the fact or rule.
|
|
16
|
+
|
|
17
|
+
**Why:**
|
|
18
|
+
|
|
19
|
+
**How to apply:**`,B={state:"idle",diff:[],summary:"",action:"update",reason:"",fold:null},He=s=>s.replace(/\.md$/,""),Ye=s=>s?s.split(/[\\/]/).filter(Boolean).pop()??s:"workspace";function Ee(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return(t?s.slice(t[0].length):s).replace(/^\s*\n/,"")}function is(){try{const s=localStorage.getItem(Ze);return s&&s.startsWith(ce)?s:"workspace"}catch{return"workspace"}}function ds({cwd:s}){const[t,n]=i.useState(is),[l,x]=i.useState([]),[a,p]=i.useState(0),m=i.useMemo(()=>{if(!t.startsWith(ce))return"workspace";const f=t.slice(ce.length);return l.some(o=>o.name===f)?t:"workspace"},[t,l]),c=i.useMemo(()=>{if(m==="workspace")return{kind:"workspace"};const f=l.find(o=>o.name===m.slice(ce.length));return f?{kind:"agent",agent:f}:{kind:"workspace"}},[m]),v=i.useCallback(f=>{const o=f.kind==="agent"?`${ce}${f.agent.name}`:"workspace";try{localStorage.setItem(Ze,o)}catch{}n(o)},[]),k=i.useCallback(f=>{f.length>0&&x(f)},[]);return e.jsx(cs,{scope:c,cwd:s,onScope:v,onAgents:k,wsCount:a,onWsCount:p},m)}function cs({scope:s,cwd:t,onScope:n,onAgents:l,wsCount:x,onWsCount:a}){var Re;const p=Tt(s,t),{actions:m,rows:c,clusters:v}=p,k=s.kind==="agent"?s.agent:null,f=k!==null&&k.memoryScope===null,o=k?k.name:Ye(t),[b,u]=i.useState("all"),[j,M]=i.useState(null),[y,C]=i.useState("read"),[I,W]=i.useState(""),[ee,xe]=i.useState("recent"),[q,A]=i.useState(null),[U,L]=i.useState(B),[me,ye]=i.useState(""),[X,T]=i.useState(null),[_,te]=i.useState(null),[ve,R]=i.useState(null),[$,Q]=i.useState(""),[V,H]=i.useState(""),[ue,se]=i.useState(""),[ne,re]=i.useState(!1),[Z,pe]=i.useState(null);i.useEffect(()=>{l(p.agents)},[p.agents,l]),i.useEffect(()=>{!k&&!p.loading&&a(c.length)},[k,p.loading,c.length,a]);const Y=i.useMemo(()=>p.archived.map(r=>({name:r,slug:He(r),path:`${p.dir}/${r}`,description:"",bytes:0,mtimeMs:0,ageDays:0,stale:!1,staleReasons:[],ageOnlyStale:!1,deadRefs:[],broken:!1,danglingLinks:[],outLinks:[],inLinks:[],notIndexed:!1,clusterId:null,type:null,originSessionId:null})),[p.archived,p.dir]),ae=b!=="ask"&&b!=="clusters",h=i.useMemo(()=>{if(b==="archived"){const r=I.trim().toLowerCase();return Y.filter(g=>!r||g.slug.toLowerCase().includes(r))}return qe(de(c,b,I),ee)},[b,c,Y,I,ee]),d=i.useMemo(()=>c.find(r=>r.name===j)??Y.find(r=>r.name===j)??null,[c,Y,j]),N=d!==null&&!c.some(r=>r.name===d.name),w=i.useCallback(r=>{var g;return((g=v.find(S=>S.id===r))==null?void 0:g.dotClass)??"bg-rule"},[v]),z=r=>{var g;return((g=v.find(S=>S.id===r))==null?void 0:g.name)??"Unclustered"},O=i.useCallback(r=>{M(r),C("read"),L(B),T(null),A(null)},[]),P=i.useCallback(r=>{u(r),W(""),A(null),L(B),C(g=>g==="edit"||g==="new"?"read":g)},[]);i.useEffect(()=>{var r;p.loading||!ae||y==="new"||d&&h.some(g=>g.name===d.name)||M(((r=h[0])==null?void 0:r.name)??null)},[p.loading,ae,y,d,h]);const oe=d&&!N?d.name:null,Je=d==null?void 0:d.mtimeMs;i.useEffect(()=>{if(!oe)return;let r=!0;return m.read(oe).then(g=>{r&&pe({name:oe,text:g})}),()=>{r=!1}},[oe,Je,m.read]);const G=N?"":Z&&Z.name===oe?Z.text:null;i.useEffect(()=>{const r=g=>{var he,ie;if(g.key!=="/"||g.metaKey||g.ctrlKey||g.altKey)return;const S=g.target,fe=((he=S==null?void 0:S.tagName)==null?void 0:he.toLowerCase())??"";fe==="input"||fe==="textarea"||S!=null&&S.isContentEditable||(ie=S==null?void 0:S.closest)!=null&&ie.call(S,".monaco-editor")||(g.preventDefault(),A("palette"))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[]);const D=(r,g)=>te({message:r,undo:g}),ke=(r="")=>{f||((b==="ask"||b==="clusters")&&u("all"),M(null),Q(""),H(r),se(""),L(B),A(null),C("new"))},Ne=r=>{P("all"),O(r)},et=r=>{const g=c.find(S=>S.slug===r);g?O(g.name):E.error(`${r} is not in this scope`)},tt=()=>{if(G===null)return;const r=Ee(G);H(r),se(r),C("edit")},st=async()=>{if(!ne){re(!0);try{if(y==="new"){const r=await m.create($,V);if(!r)return;const g=r.endsWith(".md")?r:`${r}.md`;P("all"),O(g),D(`Created ${He(g)}`)}else if(y==="edit"&&d){if(!await m.saveBody(d.name,V))return;C("read"),D(`Saved ${d.slug}`)}}finally{re(!1)}}},nt=()=>{C("read"),d||M(null)},rt=async()=>{if(!d||G===null)return;const r=d;L({...B,state:"checking"});const g=await m.proposeFix(r.name);if(!g.ok){L(B);return}ye(g.content),L({state:"proposed",diff:g.action==="update"?Dt(G,g.content):[],summary:g.summary,action:g.action,reason:g.reason,fold:g.fold})},at=async()=>{if(!d||G===null)return;const r=d;if(U.action==="delete"){if(!await m.archive(r.name))return;L(B),D(`Archived ${r.slug}`,()=>{m.restore(r.name)})}else if(U.action==="keep"){if(!await m.verify(r.name))return;L(B),D(`Marked ${r.slug} verified`)}else if(U.action==="fold"){if(!U.fold)return;const{target:g,anchor:S,insert:fe}=U.fold,he=`Fold memory ${r.slug} into ${g}.
|
|
20
|
+
Insert after the line: ${S||"(append at end)"}
|
|
21
|
+
---
|
|
22
|
+
${fe}
|
|
23
|
+
---
|
|
24
|
+
Tread lightly: add only these lines, do not restructure the doc. Once committed, archive the memory ${r.slug} from the Memory page.
|
|
25
|
+
Memory file: ${r.path}`,ie=await window.api.clipboard.writeText(he);if(!ie.ok){E.error(`Copy failed: ${ie.error??"unknown error"}`);return}L(B),D("Fold copied — paste it into a New Epic")}else{const g=Ee(G);if(!await m.saveBody(r.name,Ee(me)))return;L(B),T(r.slug),D(`Applied fix to ${r.slug}`,()=>{m.saveBody(r.name,g)})}},ot=async()=>{if(!d)return;const r=d;await m.verify(r.name)&&D(`Marked ${r.slug} verified`)},Ae=async()=>{if(!d)return;const r=d;A(null),await m.archive(r.name)&&D(`Archived ${r.slug}`,()=>{m.restore(r.name)})},lt=async()=>{if(!d)return;const r=d;await m.restore(r.name)&&D(`Restored ${r.slug}`)},it=async()=>{if(!d)return;const r=d;A(null);const g=await m.remove(r.name);if(!g)return;const S=r.inLinks.length;D(`Deleted ${r.slug}${S>0?` · ${S} inbound links now broken`:""}`,()=>{g()})},dt=async()=>{if(!d)return;const r=await window.api.clipboard.writeText(d.path);r.ok?D("Path copied"):E.error(`Copy failed: ${r.error??"unknown error"}`)},ct=()=>{d&&window.api.shell.open({as:"revealPath",path:d.path})},xt=async r=>{if(!d)return;const g=d;await m.removeLink(g.name,r)&&D(`Dead link removed from ${g.slug}`)},mt=()=>{d&&(R(d.slug),P("ask"))},ut=r=>{var g;return r?((g=c.find(S=>S.slug===r))==null?void 0:g.name)??`${r}.md`:void 0},pt=i.useMemo(()=>Rt(c),[c]),ft=i.useMemo(()=>{const r={};for(const g of c)g.clusterId&&(r[g.clusterId]=(r[g.clusterId]??0)+1);return r},[c]),Le=i.useMemo(()=>c.filter(r=>r.clusterId===null).length,[c]),ht=i.useMemo(()=>new Set(c.map(r=>r.slug)),[c]),gt=b.startsWith("cluster:")?b==="cluster:unclustered"?"Unclustered":((Re=v.find(r=>r.id===b.slice(8)))==null?void 0:Re.name)??"Cluster":{all:"All memories",stale:"Stale",broken:"Broken references",recent:"Changed this week",unindexed:"Not in index",archived:"Archived"}[b]??"All memories";let le=null;h.length===0&&(f?le={title:`${o} has no persistent memory`,body:"Add `memory: project` (or user/local) to its frontmatter in the Agent Library to turn it on.",action:"Back to workspace",onAction:()=>n({kind:"workspace"})}:I.trim()?le={title:`No memories match “${I}”`,body:"Filter checks names and descriptions in this view.",action:"Clear filter",onAction:()=>W("")}:c.length===0&&b==="all"?le={title:`${o} has no memories yet`,body:"They appear when this subagent saves one, or add one now.",action:"+ New memory",onAction:()=>ke(Me)}:le={title:"All clear",body:b==="stale"?"Nothing is stale in this scope.":"Nothing in this view.",action:"Back to all memories",onAction:()=>P("all")});const bt=!p.autoMemoryEnabled,yt=jt.memory;return e.jsxs("div",{"data-testid":"mx-shell",className:"relative h-full flex flex-col bg-bg text-fg leading-[normal]",children:[e.jsxs("div",{className:"relative shrink-0 flex items-center gap-3 px-6 py-4 border-b border-rule-structural",children:[e.jsxs("div",{className:"flex items-baseline gap-3 pt-1",children:[e.jsx("span",{className:"text-[11px] tracking-[.08em] font-medium text-fg-dim",children:"CONFIGURE"}),e.jsx("span",{className:"font-serif text-[28px] leading-none",children:"Memory"}),e.jsx("span",{className:"text-xs text-fg-dim",children:"Claude Code's own memory files · stored on this machine"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{type:"button","data-testid":"mx-search-trigger",onClick:()=>A("palette"),className:"flex items-center gap-2 h-[30px] px-2.5 border border-rule-structural rounded-md bg-bg-elev w-[300px] text-xs text-fg-dim hover:border-fg-faint",children:[e.jsx("span",{children:"Search all memories, or ask a question…"}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"font-mono text-[10px] px-[5px] py-px border border-rule-structural rounded-[3px] text-fg-dim",children:"/"})]}),e.jsx("button",{type:"button","data-testid":"mx-learn",onClick:()=>A(r=>r==="learn"?null:"learn"),className:`text-[11px] tracking-[.08em] font-semibold px-1 py-1.5 hover:text-fg ${q==="learn"?"text-fg":"text-accent"}`,children:"LEARN"}),q==="learn"&&e.jsxs("div",{"data-testid":"mx-learn-popover",className:`absolute right-5 top-[58px] w-[360px] ${K.dialog} bg-bg-hi border border-rule-structural rounded-lg shadow-2xl p-4 flex flex-col gap-2.5 text-[13px] leading-[1.55] text-fg`,children:[e.jsx("span",{className:"font-serif text-[17px]",children:"How memory works"}),e.jsx("span",{children:yt.intro}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-testid":"mx-learn-close",onClick:()=>A(null),className:"text-xs font-medium h-7 px-3 rounded-[5px] bg-fg text-bg",children:"Got it"})})]})]}),bt&&e.jsx("div",{"data-testid":"mx-auto-off",className:"shrink-0 w-full px-6 py-2 bg-butter/40 text-honey-dark text-[12.5px]",children:"Auto memory is off — Claude Code is not reading or writing any of these files."}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(Ot,{scope:s,agents:p.agents,agentCounts:p.agentCounts,workspaceName:Ye(t),workspacePath:t??"",workspaceCount:k?x:c.length,onScope:n,view:b,onView:P,counts:pt,clusters:v,clusterCounts:ft,unclusteredCount:Le,archivedCount:p.archived.length,index:p.index}),e.jsxs("main",{className:"flex-1 min-w-0 min-h-0 flex",children:[b==="ask"&&e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ss,{rows:c,context:ve,onClearContext:()=>R(null),onAsk:(r,g)=>m.ask(r,ut(g)),onOpen:Ne,onReverify:()=>P("stale"),onDraft:r=>ke(r)})}),b==="clusters"&&e.jsx(ns,{clusters:v,rows:c,generatedAt:p.clustersMeta.generatedAt,running:p.clustersMeta.running,unclusteredCount:Le,available:!k,onRegenerate:()=>{m.regenerateClusters()},onOpenCluster:r=>P(`cluster:${r}`),onOpen:Ne}),ae&&e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 grid grid-cols-[316px_minmax(0,1fr)_236px]",children:[e.jsx(Kt,{title:gt,rows:h,clusterDot:w,selected:j,onSelect:O,query:I,onQuery:W,sort:ee,onSort:xe,onNew:()=>ke(Me),empty:le}),e.jsx("div",{className:"flex flex-col min-w-0 min-h-0",children:y==="edit"||y==="new"?e.jsx(Be,{mode:y,name:(d==null?void 0:d.slug)??null,title:$,onTitle:Q,body:V,onBody:H,onSave:()=>{st()},onCancel:nt,saving:ne,dirty:y==="new"?$.trim()!==""||V!==Me:V!==ue}):d?e.jsx(Gt,{row:d,content:G,clusterName:z(d.clusterId),clusterDot:w(d.clusterId),archived:N,mode:y,onMode:C,onEdit:tt,onCopyPath:()=>{dt()},onReveal:ct,onArchive:()=>{Ae()},onRestore:()=>{lt()},onAskDelete:()=>A("delete"),fix:U,appliedStill:X===d.slug&&d.stale,onFix:()=>{rt()},onApplyFix:()=>{at()},onDiscardFix:()=>L(B),onVerify:()=>{ot()}}):e.jsx(Be,{mode:"none",name:null,title:"",onTitle:Q,body:"",onBody:H,onSave:()=>{},onCancel:()=>{},saving:!1,dirty:!1})}),e.jsx(Qt,{row:N||y==="new"?null:d,known:ht,onOpen:et,onRemoveLink:r=>{xt(r)},onAskAbout:mt})]})]})]}),e.jsx(rs,{open:q==="palette",rows:c,clusterDot:w,onPick:Ne,onAsk:()=>{R(null),P("ask")},onClose:()=>A(null)}),e.jsx(as,{open:q==="delete"&&d!==null,name:(d==null?void 0:d.slug)??"",inbound:(d==null?void 0:d.inLinks.length)??0,onArchive:()=>{Ae()},onCancel:()=>A(null),onConfirm:()=>{it()}}),e.jsx(ls,{message:(_==null?void 0:_.message)??null,onUndo:_!=null&&_.undo?()=>{const r=_.undo;te(null),r==null||r()}:void 0,onClose:()=>te(null)})]})}function xs(){const s=Ct(),t=St();return s?e.jsx(ds,{cwd:(t==null?void 0:t.cwd)??null}):e.jsx($t,{title:"loading…"})}const ps=i.memo(xs);export{ps as Memory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ap as e}from"./index-DZ5TJKNI.js";function n({toolbar:s,footer:l,children:r}){return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:s}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:r}),l&&e.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:l})]})}export{n as P};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`}function ce(){const n=
|
|
3
|
-
`)};if(!n)return e.jsx(E,{title:"loading…"});if(l==="presets")return e.jsx(I,{toolbar:R,children:e.jsx(se,{})});const A=t=>t!=="user"&&!o,m=x?y[x]:null,{perms:p,full:B,err:h}=m?
|
|
1
|
+
import{aF as u,b4 as W,aY as X,b6 as Y,a_ as w,ar as q,aw as Q,al as U,ap as e,n as E,P as O,aX as J,aO as Z}from"./index-DZ5TJKNI.js";import{P as I}from"./Panel-yOYf80ax.js";import{S as ee}from"./ScopeSwitcher-BCXNrrrs.js";import{S as te}from"./SaveBar-35Nw2YsZ.js";import{P as se}from"./Library-wBI4Fwh3.js";import{u as re,E as ne,s as oe}from"./settingsSchema-BfnNE6ne.js";import{V as ae}from"./ViewTabs-D82jJ4VS.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-BuyzGzO8.js";import"./listSkills-C1aWKf0T.js";import"./claude-settings-schema-COigsajx.js";const ie=["allow","deny","ask"],k="This settings file has invalid JSON. Fix it in the Settings raw editor first; Permissions will not overwrite it.";function F(n){if(n.trim()==="")return{perms:{},full:{},err:null};try{const r=JSON.parse(n);if(r===null||typeof r!="object"||Array.isArray(r))return{perms:{},full:{},err:"settings file is not a JSON object"};const o=r;return{perms:o.permissions??{},full:o,err:null}}catch(r){return{perms:{},full:{},err:r.message}}}function le(n,r){const o={...n,permissions:r};return JSON.stringify(o,null,2)+`
|
|
2
|
+
`}function ce(){const n=W(),r=X(),o=(r==null?void 0:r.cwd)??null,s=Y(t=>t.navFace),f=u.useRef(!1),i=u.useRef(s),[c,v]=u.useState(()=>s==="project"&&o?"project":"user"),[l,b]=u.useState("effective");u.useEffect(()=>{if(i.current!==s){if(i.current=s,f.current){f.current=!1;return}v(s==="project"&&o?"project":"user")}},[s,o]),u.useEffect(()=>{s==="project"&&l==="presets"&&b("effective")},[s,l]);const M=t=>{f.current=!0,v(t)},j=re(O,n,o),x=j[c]??null,y=w(t=>t.files),C=w(t=>t.setDraft),_=w(t=>t.saveJson),L=w(t=>t.revert),[T,S]=u.useState(null),R=e.jsx(ae,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:l,onChange:b}),$=u.useMemo(()=>{const t=q(Q(y,j));return U(t,["permissions"])??{kind:"object",children:{}}},[y,j]),V=(t,d)=>{var D;const a=j[c];if(!a)return;const{full:g,err:P}=F(((D=y[a])==null?void 0:D.draftRaw)??"");if(P){J.error(k);return}S(null);const G=Z(g.permissions??{},t,d),H={...g,permissions:G};C(a,JSON.stringify(H,null,2)+`
|
|
3
|
+
`)};if(!n)return e.jsx(E,{title:"loading…"});if(l==="presets")return e.jsx(I,{toolbar:R,children:e.jsx(se,{})});const A=t=>t!=="user"&&!o,m=x?y[x]:null,{perms:p,full:B,err:h}=m?F(m.draftRaw):{perms:{},full:{},err:null},N=t=>{if(x){if(h){J.error(k);return}S(null),C(x,le(B,t))}},K=(t,d)=>{const a=d.trim();if(!a)return;const g=p[t]??[];g.includes(a)||N({...p,[t]:[...g,a]})},z=(t,d)=>{const a=p[t]??[];N({...p,[t]:a.filter((g,P)=>P!==d)})};return e.jsx(I,{toolbar:e.jsxs(e.Fragment,{children:[R,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(ee,{scopes:O.scopes,active:c,onChange:M,annotate:t=>{if(A(t))return{exists:!1};const d=j[t];if(!d)return null;const a=y[d];return{exists:(a==null?void 0:a.exists)??!1,dirty:(a==null?void 0:a.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:x??"—"}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings#permissions",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"rule syntax ↗"})]}),footer:x&&m?e.jsx(te,{dirty:m.dirty,busy:m.busy,parseError:T||h||m.parseError,lastSavedAt:m.lastSavedAt,onSave:async()=>{S(null);const t=await _(x);t.ok||S(t.error??"save failed")},onRevert:()=>{S(null),L(x)}}):null,children:A(c)?e.jsx(E,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):l==="effective"?e.jsx(ne,{node:$,targetScope:c,onOverride:V,schema:oe().rootedAt(["permissions"]),rootLabel:"permissions"}):x&&m?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[h&&e.jsxs("div",{role:"alert",className:"text-xs text-red-400 border border-red-400/40 rounded px-3 py-2",children:[k," (",h,")"]}),e.jsx(de,{value:p.defaultMode??"default",onChange:t=>N({...p,defaultMode:t})}),ie.map(t=>e.jsx(ue,{list:t,rules:p[t]??[],disabled:!!h,onAdd:d=>K(t,d),onRemove:d=>z(t,d)},t)),e.jsx(fe,{dirs:p.additionalDirectories??[],disabled:!!h,onChange:t=>N({...p,additionalDirectories:t})})]}):e.jsx(E,{title:"resolving…"})})}const we=u.memo(ce);function de({value:n,onChange:r}){const o=["default","acceptEdits","plan","bypassPermissions"];return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Default Mode"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:o.map(s=>e.jsx("button",{onClick:()=>r(s),className:`px-2.5 py-1 text-xs transition-colors ${n===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ue({list:n,rules:r,onAdd:o,onRemove:s,disabled:f}){const[i,c]=u.useState(""),v=n==="allow"?"text-green-400":n==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${v}`,children:n}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,disabled:f,onChange:l=>c(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(o(i),c(""))},placeholder:n==="allow"?"e.g. Bash(ls:*) or Read(~/.claude/**)":"e.g. Write(/etc/**)",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"}),e.jsx("button",{onClick:()=>{o(i),c("")},disabled:f||!i.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),r.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:r.map((l,b)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:l}),e.jsx("button",{onClick:()=>s(b),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${b}-${l}`))})]})}function fe({dirs:n,onChange:r,disabled:o}){const[s,f]=u.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:s,disabled:o,onChange:i=>f(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s.trim()&&(r([...n,s.trim()]),f(""))},placeholder:"/absolute/path/to/dir",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"})}),e.jsx("ul",{className:"space-y-0.5",children:n.map((i,c)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:i}),e.jsx("button",{onClick:()=>r(n.filter((v,l)=>l!==c)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${c}-${i}`))})]})}export{we as Permissions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-
|
|
2
|
-
import{ao as t,aE as c,n as S,b3 as pe,aW as q,a_ as ae,a as xe}from"./index-DQSEUdx0.js";import{P as ee}from"./Panel-Cv8aYElQ.js";import{P as re}from"./ProvenanceBadge-BMLVPyHr.js";import{e as ge}from"./Library-DoP5FdXq.js";import{p as le,M as je}from"./skillFrontmatter-DF6xI6Wb.js";import{l as be}from"./listSkills-C1aWKf0T.js";import{_ as ye}from"./monaco-editor-BsIlgG7c.js";import{L as ve}from"./ListDetail-BYxyl13e.js";import"./Button-BQxkfIbW.js";function ke({columns:e,rows:n,getKey:i,onRowClick:s,activeKey:a,empty:d}){return n.length===0?t.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:d??"no entries"}):t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:t.jsx("tr",{className:"border-b border-line",children:e.map(l=>t.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),t.jsx("tbody",{children:n.map(l=>{const h=i(l),o=a===h;return t.jsx("tr",{"data-row-key":h,onClick:()=>s==null?void 0:s(l),className:`border-b border-line/50 transition-colors ${s?"cursor-pointer":""} ${o?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:e.map(u=>t.jsx("td",{className:`px-3 py-1 ${u.className??""}`,children:u.render(l)},u.key))},h)})})]})}async function oe(e){const n=`${e}/skills`;return await window.api.config.exists(n)?n:null}async function ce(e){const{entries:n}=await be(e,{nested:!1});return n.map(i=>{const s=le(i.text);return{id:i.name,name:s.name,description:s.description,dir:i.dir,path:i.path,body:s.body}})}function Ne(e){const n=[],i=new Set;for(const s of e)for(const a of e){if(s.id===a.id)continue;const d=a.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${d}\\b`,`\`${d}\``];if(a.id.length>=4&&l.push(`\\b${d}\\b`),!l.some(u=>new RegExp(u,"i").test(s.body)))continue;const o=`${s.id}->${a.id}`;i.has(o)||(i.add(o),n.push({from:s.id,to:a.id}))}return n}const we=c.lazy(()=>ye(()=>import("./SkillReferenceGraph-esAcniTQ.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>({default:e.SkillReferenceGraph})));function Se({pluginName:e,skills:n,onBack:i,initialSelectedId:s}){var N;const[a,d]=c.useState(s??((N=n[0])==null?void 0:N.id)??null),l=a?n.find(m=>m.id===a)??null:null,h=c.useMemo(()=>Ne(n),[n]),[o,u]=c.useState("list");return t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsxs("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",e]}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),t.jsx("span",{className:"flex-1"}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[t.jsx("button",{onClick:()=>u("list"),className:`px-2 py-0.5 text-xs ${o==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),t.jsx("button",{onClick:()=>u("graph"),className:`px-2 py-0.5 text-xs ${o==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?t.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,t.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",h.length," ",h.length===1?"reference":"references"]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?t.jsx(S,{title:"no skills in this plugin"}):o==="graph"?t.jsx(c.Suspense,{fallback:t.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:t.jsx(we,{skills:n,edges:h,selectedId:a,onSelect:d})}):t.jsx(ve,{sidebar:t.jsx("div",{className:"py-1",children:n.map(m=>t.jsxs("button",{onClick:()=>d(m.id),className:`w-full px-3 py-1 text-xs text-left ${a===m.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("div",{className:"truncate",children:m.name??m.id}),m.description?t.jsx("div",{className:"truncate text-fg-faint",children:m.description}):null]},m.id))}),detail:l?t.jsx("div",{className:"h-full min-h-0",children:t.jsx(je,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):t.jsx(S,{title:"select a skill"})})})]})}const de=e=>{var n,i;return{type:"plugin",name:e.name,repository:(n=e.manifest)==null?void 0:n.repository,homepage:(i=e.manifest)==null?void 0:i.homepage}};function $e(){const e=pe(),[n,i]=c.useState([]),[s,a]=c.useState(!0),[d,l]=c.useState(null),[h,o]=c.useState(null),[u,N]=c.useState("installed"),[m,I]=c.useState(null),[D,F]=c.useState(new Set);c.useEffect(()=>{var g,k;let r=!1;return(k=(g=window.api.app).seedStatus)==null||k.call(g).then($=>{r||I($)}).catch(()=>{}),()=>{r=!0}},[]);const E=c.useRef(0),C=c.useRef(!1),b=c.useCallback(async()=>{const r=++E.current;if(!e)return;C.current||a(!0);const g=`${e}/.claude/plugins/installed_plugins.json`;let k=[],$=null;try{const x=await window.api.config.readJson(g);if(x.exists&&x.parseError)$=`could not parse installed_plugins.json${x.error?`: ${x.error}`:""}`;else if(x.exists&&x.data&&typeof x.data=="object"){const T=x.data,J=[];for(const[W,R]of Object.entries(T.plugins??{})){if(!Array.isArray(R))continue;const[_,O]=W.split("@");for(const j of R)j!=null&&j.installPath&&J.push({name:_,marketplace:O,entry:j})}k=await De(J,Le,async({name:W,marketplace:R,entry:_})=>{var H;const O={name:W,path:_.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let j;try{j=await _e(O)}catch(B){j=Re(O,B instanceof Error?B.message:String(B))}return(H=j.manifest)!=null&&H.version||(j.manifest={...j.manifest??{},version:_.version}),j.marketplace=R,j.scope=_.scope,j})}}catch(x){$=`could not read installed_plugins.json: ${x instanceof Error?x.message:String(x)}`}E.current===r&&(l($),$?q.error(`Plugins: ${$}`):(k.sort((x,T)=>x.name.localeCompare(T.name)),C.current=k.length>0,i(k)),a(!1))},[e]);c.useEffect(()=>{b()},[b]),c.useEffect(()=>()=>{E.current+=1},[]),ae(e?[`${e}/.claude/plugins/installed_plugins.json`]:[],b);const f=[{key:"name",header:"name",render:r=>{var g;return t.jsxs("div",{style:{maxWidth:"16rem"},children:[t.jsx("div",{className:"truncate",children:r.name}),(g=r.manifest)!=null&&g.description?t.jsx("div",{className:"truncate text-fg-faint",title:r.manifest.description,children:r.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:r=>t.jsx(re,{interactive:!1,input:de(r)}),width:"7rem"},{key:"scope",header:"scope",render:r=>r.scope?t.jsx("span",{"data-testid":"plugin-scope",children:r.scope}):t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:r=>{var g;return((g=r.manifest)==null?void 0:g.version)??t.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:r=>r.hasManifest?"plugin.json":t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:r=>t.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[r.agents>0?`${r.agents} agents`:null,r.commands>0?`${r.commands} commands`:null,r.skills>0?`${r.skills} skills`:null,r.hooks>0?`${r.hooks} hooks`:null,r.monitors>0?`${r.monitors} monitors`:null,r.binCount>0?`${r.binCount} bin`:null,r.hasLsp?"lsp":null,r.hasMcp?"mcp":null,r.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:r=>t.jsx("span",{className:"font-mono text-fg-faint truncate",children:r.path})}],p=c.useMemo(()=>m?Object.keys(m).filter(r=>m[r].status==="exhausted"&&!D.has(r)):[],[m,D]),w=p.length>0?t.jsx(Pe,{seeders:p,seedStatus:m,onDismiss:r=>F(g=>new Set(g).add(r)),onOpenLibrary:()=>N("library")}):null;if(u==="library")return t.jsxs(ee,{toolbar:t.jsx(ne,{active:u,onChange:N}),children:[w,t.jsx(ge,{})]});const y=h?n.find(r=>r.path===h)??null:null;return t.jsxs(ee,{toolbar:t.jsxs(t.Fragment,{children:[t.jsx(ne,{active:u,onChange:N}),t.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),t.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[w,d?t.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[d,n.length>0?" — showing the last known list":null]}):null,s&&n.length===0?t.jsx(S,{title:"scanning plugins…"}):d&&n.length===0?null:y?t.jsx(Ae,{row:y,home:e,onBack:()=>o(null)},y.path):t.jsx("div",{className:"flex flex-col h-full",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsx(ke,{columns:f,rows:n,getKey:r=>r.path,activeKey:h,onRowClick:r=>o(r.path),empty:t.jsxs(t.Fragment,{children:["no plugins installed",t.jsxs("div",{className:"mt-2 text-fg-faint",children:["install one from the Library view or run ",t.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const Ge=c.memo($e),te={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Pe({seeders:e,seedStatus:n,onDismiss:i,onOpenLibrary:s}){return t.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:e.map(a=>t.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[te[a]," setup failed after retrying — manual fix needed"]}),a==="dev-plugin"?t.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",t.jsx("button",{onClick:s,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):t.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[a].fix})]}),t.jsx("button",{onClick:()=>i(a),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${te[a]} warning`,children:"✕"})]},a))})}function ne({active:e,onChange:n}){const i=[["installed","Installed"],["library","Library"]];return t.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:i.map(([s,a])=>t.jsx("button",{onClick:()=>n(s),role:"tab","aria-selected":e===s,className:`px-2 py-0.5 text-xs ${e===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:a},s))})}const Ee=250,Ce=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function Ae({row:e,home:n,onBack:i}){var O,j,H,B,U;const[s,a]=c.useState([]),[d,l]=c.useState([]),[h,o]=c.useState([]),[u,N]=c.useState([]),[m,I]=c.useState([]),[D,F]=c.useState("skills"),[E,C]=c.useState(null),[b,f]=c.useState(!0),[p,w]=c.useState([]),y=c.useRef(0),r=c.useRef(!1),g=c.useCallback(async()=>{if(!n)return;const v=++y.current;try{const{manifest:M}=await ue(e.path),[z,V,he]=await Promise.all([oe(e.path),me(e.path,M),K(`${e.path}/bin`,{filesOnly:!0})]),G=z?await ce(z):[],[X,Y]=await Promise.all([ie(V.agentFiles),ie(V.commandFiles)]),Q=V.mcpServers,fe=await Promise.all([...new Set([...Ce.map(A=>`${e.path}/${A}`),...V.sourcePaths])].map(async A=>await window.api.config.exists(A)?A:null));if(v!==y.current)return;a(G),l(X),o(Y),N(Q),I(he);const Z=fe.filter(A=>A!==null);w(A=>A.join("\0")===Z.join("\0")?A:Z),r.current||(r.current=!0,F(G.length>0?"skills":X.length>0?"agents":Y.length>0?"commands":Q.length>0?"mcp":e.hooks>0?"hooks":e.monitors>0?"monitors":e.hasLsp?"lsp":"files"))}catch(M){if(v!==y.current)return;q.error(`Failed to load plugin contents: ${M instanceof Error?M.message:String(M)}`)}finally{v===y.current&&f(!1)}},[e.path,e.name,e.hooks,e.monitors,e.hasLsp,n]);c.useEffect(()=>(f(!0),g(),()=>{y.current+=1}),[g]);const k=c.useRef(null),$=c.useRef(!1),x=c.useRef(!1),T=c.useCallback(async()=>{if($.current){x.current=!0;return}$.current=!0;try{do x.current=!1,await g();while(x.current)}finally{$.current=!1}},[g]),J=c.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,T()},Ee)},[T]);c.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),ae(p,J,{depth:0});const W=[{key:"skills",label:"Skills",count:s.length},{key:"agents",label:"Agents",count:d.length},{key:"commands",label:"Commands",count:h.length},{key:"mcp",label:"MCP server",count:u.length},{key:"hooks",label:"Hooks",count:e.hooks},{key:"monitors",label:"Monitors",count:e.monitors},{key:"lsp",label:"LSP",count:e.hasLsp?1:0},{key:"files",label:"Bin",count:m.length}],R=(O=e.manifest)!=null&&O.author?typeof e.manifest.author=="string"?e.manifest.author:e.manifest.author.name??null:null,_=async v=>{const M=await window.api.shell.open({as:"external",url:v});M.ok||q.error(M.error??`Failed to open ${v}`)};return E?t.jsx(Se,{pluginName:((j=e.manifest)==null?void 0:j.name)??e.name,skills:s,initialSelectedId:E.id,onBack:()=>C(null)},E.id):t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsx("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((H=e.manifest)==null?void 0:H.name)??e.name}),(B=e.manifest)!=null&&B.version?t.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",e.manifest.version]}):null,(U=e.manifest)!=null&&U.description?t.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:e.manifest.description}):t.jsx("span",{className:"flex-1"}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(re,{input:de(e)}),e.hasMcp?t.jsx(xe,{tone:"accent",children:"MCP"}):null]})]}),e.manifest?t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[R?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"Author "}),R]}):null,e.manifest.license?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"License "}),e.manifest.license]}):null,e.manifest.homepage?t.jsxs("button",{onClick:()=>_(e.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:e.manifest.homepage,children:[t.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),e.manifest.homepage]}):null,t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})]}):t.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})}),t.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[t.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:W.map(v=>t.jsxs("button",{type:"button",disabled:v.count===0,onClick:()=>F(v.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${v.count===0?"text-fg-faint opacity-50 cursor-default":D===v.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("span",{children:v.label}),v.count>0?t.jsx("span",{className:"font-mono text-fg-faint",children:v.count}):null]},v.key))}),t.jsx("div",{className:"min-h-0 overflow-auto",children:b?t.jsx(S,{title:"scanning…"}):t.jsx(Me,{active:D,row:e,skills:s,agents:d,commands:h,mcpServers:u,files:m,onOpenSkill:C})})]})]})}function Me({active:e,row:n,skills:i,agents:s,commands:a,mcpServers:d,files:l,onOpenSkill:h}){return e==="skills"?i.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:i.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description,onClick:()=>h(o)},o.id))}):e==="agents"?s.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:s.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="commands"?a.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:a.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="mcp"?d.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:d.map((o,u)=>t.jsx(L,{n:u+1,name:o.name,description:o.description},o.id))}):e==="hooks"?n.hooks===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):e==="monitors"?n.monitors===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):e==="lsp"?n.hasLsp?t.jsx("div",{children:t.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):t.jsx(S,{title:"no components"}):l.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:l.map((o,u)=>t.jsx(L,{n:u+1,name:o,description:null},o))})}function L({n:e,name:n,description:i,onClick:s}){const a=s?"button":"div";return t.jsxs(a,{onClick:s,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${s?"hover:bg-bg-hi cursor-pointer":""}`,children:[t.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(e).padStart(2,"0")}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),i?t.jsx("div",{className:"text-fg-dim text-xs truncate",children:i}):null]})]})}const Le=4;async function De(e,n,i){const s=new Array(e.length);let a=0;const d=Array.from({length:Math.min(n,e.length)},async()=>{for(;a<e.length;){const l=a++;s[l]=await i(e[l])}});return await Promise.all(d),s}function Re(e,n){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,error:n}}async function _e(e){const{hasManifest:n,manifest:i}=await ue(e.path),[s,a]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let d=0;if(a){const m=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(m.data)?d=m.data.length:m.data&&typeof m.data=="object"&&Array.isArray(m.data.monitors)&&(d=m.data.monitors.length)}const[l,h,o]=await Promise.all([me(e.path,i),K(`${e.path}/bin`,{filesOnly:!0}),oe(e.path)]),u=h.length,N=o?(await ce(o)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:n,manifest:i,hasLsp:s,monitors:d,hooks:l.hooks,agents:l.agentFiles.length,commands:l.commandFiles.length,skills:N,binCount:u,hasMcp:l.mcpServers.length>0}}async function ue(e){let n=`${e}/.claude-plugin/plugin.json`,i=await window.api.config.exists(n);if(i||(n=`${e}/plugin.json`,i=await window.api.config.exists(n)),!i)return{hasManifest:i,manifest:null};const s=await window.api.config.readJson(n),a=s.exists&&!s.parseError&&s.data&&typeof s.data=="object"&&!Array.isArray(s.data);return{hasManifest:i,manifest:a?s.data:null}}const P=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Oe(e,n){const i=n.startsWith("/")?n.startsWith(`${e}/`)?n.slice(e.length+1):null:n;if(i===null)return se(n);const s=[];for(const a of i.split("/"))if(!(a===""||a===".")){if(a!=="..")s.push(a);else if(s.pop()===void 0)return se(n)}return s.length>0?`${e}/${s.join("/")}`:e}function se(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Fe(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function Te(e){if(!P(e))return null;if(P(e.mcpServers))return e.mcpServers;const n=Object.values(e);return n.length>0&&n.every(s=>P(s)&&(typeof s.command=="string"||typeof s.url=="string"))?e:null}function Be(e){if(!P(e))return 0;const n=P(e.hooks)?e.hooks:e;return Object.values(n).reduce((i,s)=>Array.isArray(s)?i+s.reduce((a,d)=>a+(P(d)&&Array.isArray(d.hooks)?d.hooks.length:0),0):i,0)}async function me(e,n){const i=(b,f)=>{const p=new Set;for(const w of Fe(b)){const y=Oe(e,w);y&&p.add(y)}return p.add(`${e}/${f}`),[...p]},s=async b=>{const f=new Set;for(const p of b)if(p.endsWith(".md"))f.add(p);else for(const w of await K(p,{filesOnly:!0}))w.endsWith(".md")&&f.add(`${p}/${w}`);return[...f]},a=async b=>{try{const f=await window.api.config.readJson(b);return f.exists&&!f.parseError?f.data:null}catch{return null}},d=i(n==null?void 0:n.commands,"commands"),l=i(n==null?void 0:n.agents,"agents"),h=n==null?void 0:n.hooks,o=i(typeof h=="string"||Array.isArray(h)?h:void 0,"hooks/hooks.json"),u=n==null?void 0:n.mcpServers,N=i(typeof u=="string"||Array.isArray(u)?u:void 0,".mcp.json"),[m,I,D,F]=await Promise.all([s(d),s(l),Promise.all(o.map(a)),Promise.all(N.map(a))]),E=[...P(h)?[h]:[],...D].reduce((b,f)=>b+Be(f),0),C=new Map;for(const b of[...P(u)?[u]:[],...F])for(const[f,p]of Object.entries(Te(b)??{})){if(C.has(f))continue;const w=P(p)?p.command:void 0,y=P(p)?p.url:void 0;C.set(f,{id:f,name:f,description:typeof w=="string"?w:typeof y=="string"?y:null})}return{commandFiles:m,agentFiles:I,hooks:E,mcpServers:[...C.values()],sourcePaths:[...d,...l,...o,...N]}}async function ie(e){const n=await Promise.all(e.map(s=>window.api.config.readText(s))),i=[];return e.forEach((s,a)=>{if(!n[a].exists)return;const d=s.slice(s.lastIndexOf("/")+1),l=le(n[a].text);i.push({id:s,name:l.name??d.replace(/\.md$/,""),description:l.description})}),i}async function K(e,n){try{return(await window.api.config.listDir(e,n)).entries.map(s=>s.name)}catch{return[]}}export{Ge as Plugins};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-Ca5z2avC.js","./index-DZ5TJKNI.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-DAMBm3UN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ap as t,aF as c,n as S,b4 as pe,aX as q,a$ as ae,a as xe}from"./index-DZ5TJKNI.js";import{P as ee}from"./Panel-yOYf80ax.js";import{P as re}from"./ProvenanceBadge-DFyBe7Po.js";import{e as ge}from"./Library-wBI4Fwh3.js";import{p as le,M as je}from"./skillFrontmatter-ED1DjPE1.js";import{l as be}from"./listSkills-C1aWKf0T.js";import{_ as ye}from"./monaco-editor-BsIlgG7c.js";import{L as ve}from"./ListDetail-CY5hhwn9.js";import"./Button-BuyzGzO8.js";function ke({columns:e,rows:n,getKey:i,onRowClick:s,activeKey:a,empty:d}){return n.length===0?t.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:d??"no entries"}):t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:t.jsx("tr",{className:"border-b border-line",children:e.map(l=>t.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),t.jsx("tbody",{children:n.map(l=>{const h=i(l),o=a===h;return t.jsx("tr",{"data-row-key":h,onClick:()=>s==null?void 0:s(l),className:`border-b border-line/50 transition-colors ${s?"cursor-pointer":""} ${o?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:e.map(u=>t.jsx("td",{className:`px-3 py-1 ${u.className??""}`,children:u.render(l)},u.key))},h)})})]})}async function oe(e){const n=`${e}/skills`;return await window.api.config.exists(n)?n:null}async function ce(e){const{entries:n}=await be(e,{nested:!1});return n.map(i=>{const s=le(i.text);return{id:i.name,name:s.name,description:s.description,dir:i.dir,path:i.path,body:s.body}})}function Ne(e){const n=[],i=new Set;for(const s of e)for(const a of e){if(s.id===a.id)continue;const d=a.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${d}\\b`,`\`${d}\``];if(a.id.length>=4&&l.push(`\\b${d}\\b`),!l.some(u=>new RegExp(u,"i").test(s.body)))continue;const o=`${s.id}->${a.id}`;i.has(o)||(i.add(o),n.push({from:s.id,to:a.id}))}return n}const we=c.lazy(()=>ye(()=>import("./SkillReferenceGraph-Ca5z2avC.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>({default:e.SkillReferenceGraph})));function Se({pluginName:e,skills:n,onBack:i,initialSelectedId:s}){var N;const[a,d]=c.useState(s??((N=n[0])==null?void 0:N.id)??null),l=a?n.find(m=>m.id===a)??null:null,h=c.useMemo(()=>Ne(n),[n]),[o,u]=c.useState("list");return t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsxs("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",e]}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),t.jsx("span",{className:"flex-1"}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[t.jsx("button",{onClick:()=>u("list"),className:`px-2 py-0.5 text-xs ${o==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),t.jsx("button",{onClick:()=>u("graph"),className:`px-2 py-0.5 text-xs ${o==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?t.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,t.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",h.length," ",h.length===1?"reference":"references"]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?t.jsx(S,{title:"no skills in this plugin"}):o==="graph"?t.jsx(c.Suspense,{fallback:t.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:t.jsx(we,{skills:n,edges:h,selectedId:a,onSelect:d})}):t.jsx(ve,{sidebar:t.jsx("div",{className:"py-1",children:n.map(m=>t.jsxs("button",{onClick:()=>d(m.id),className:`w-full px-3 py-1 text-xs text-left ${a===m.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("div",{className:"truncate",children:m.name??m.id}),m.description?t.jsx("div",{className:"truncate text-fg-faint",children:m.description}):null]},m.id))}),detail:l?t.jsx("div",{className:"h-full min-h-0",children:t.jsx(je,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):t.jsx(S,{title:"select a skill"})})})]})}const de=e=>{var n,i;return{type:"plugin",name:e.name,repository:(n=e.manifest)==null?void 0:n.repository,homepage:(i=e.manifest)==null?void 0:i.homepage}};function $e(){const e=pe(),[n,i]=c.useState([]),[s,a]=c.useState(!0),[d,l]=c.useState(null),[h,o]=c.useState(null),[u,N]=c.useState("installed"),[m,I]=c.useState(null),[D,F]=c.useState(new Set);c.useEffect(()=>{var g,k;let r=!1;return(k=(g=window.api.app).seedStatus)==null||k.call(g).then($=>{r||I($)}).catch(()=>{}),()=>{r=!0}},[]);const E=c.useRef(0),C=c.useRef(!1),b=c.useCallback(async()=>{const r=++E.current;if(!e)return;C.current||a(!0);const g=`${e}/.claude/plugins/installed_plugins.json`;let k=[],$=null;try{const x=await window.api.config.readJson(g);if(x.exists&&x.parseError)$=`could not parse installed_plugins.json${x.error?`: ${x.error}`:""}`;else if(x.exists&&x.data&&typeof x.data=="object"){const T=x.data,J=[];for(const[W,R]of Object.entries(T.plugins??{})){if(!Array.isArray(R))continue;const[_,O]=W.split("@");for(const j of R)j!=null&&j.installPath&&J.push({name:_,marketplace:O,entry:j})}k=await De(J,Le,async({name:W,marketplace:R,entry:_})=>{var H;const O={name:W,path:_.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let j;try{j=await _e(O)}catch(B){j=Re(O,B instanceof Error?B.message:String(B))}return(H=j.manifest)!=null&&H.version||(j.manifest={...j.manifest??{},version:_.version}),j.marketplace=R,j.scope=_.scope,j})}}catch(x){$=`could not read installed_plugins.json: ${x instanceof Error?x.message:String(x)}`}E.current===r&&(l($),$?q.error(`Plugins: ${$}`):(k.sort((x,T)=>x.name.localeCompare(T.name)),C.current=k.length>0,i(k)),a(!1))},[e]);c.useEffect(()=>{b()},[b]),c.useEffect(()=>()=>{E.current+=1},[]),ae(e?[`${e}/.claude/plugins/installed_plugins.json`]:[],b);const f=[{key:"name",header:"name",render:r=>{var g;return t.jsxs("div",{style:{maxWidth:"16rem"},children:[t.jsx("div",{className:"truncate",children:r.name}),(g=r.manifest)!=null&&g.description?t.jsx("div",{className:"truncate text-fg-faint",title:r.manifest.description,children:r.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:r=>t.jsx(re,{interactive:!1,input:de(r)}),width:"7rem"},{key:"scope",header:"scope",render:r=>r.scope?t.jsx("span",{"data-testid":"plugin-scope",children:r.scope}):t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:r=>{var g;return((g=r.manifest)==null?void 0:g.version)??t.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:r=>r.hasManifest?"plugin.json":t.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:r=>t.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[r.agents>0?`${r.agents} agents`:null,r.commands>0?`${r.commands} commands`:null,r.skills>0?`${r.skills} skills`:null,r.hooks>0?`${r.hooks} hooks`:null,r.monitors>0?`${r.monitors} monitors`:null,r.binCount>0?`${r.binCount} bin`:null,r.hasLsp?"lsp":null,r.hasMcp?"mcp":null,r.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:r=>t.jsx("span",{className:"font-mono text-fg-faint truncate",children:r.path})}],p=c.useMemo(()=>m?Object.keys(m).filter(r=>m[r].status==="exhausted"&&!D.has(r)):[],[m,D]),w=p.length>0?t.jsx(Pe,{seeders:p,seedStatus:m,onDismiss:r=>F(g=>new Set(g).add(r)),onOpenLibrary:()=>N("library")}):null;if(u==="library")return t.jsxs(ee,{toolbar:t.jsx(ne,{active:u,onChange:N}),children:[w,t.jsx(ge,{})]});const y=h?n.find(r=>r.path===h)??null:null;return t.jsxs(ee,{toolbar:t.jsxs(t.Fragment,{children:[t.jsx(ne,{active:u,onChange:N}),t.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),t.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),t.jsx("div",{className:"flex-1"}),t.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[w,d?t.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[d,n.length>0?" — showing the last known list":null]}):null,s&&n.length===0?t.jsx(S,{title:"scanning plugins…"}):d&&n.length===0?null:y?t.jsx(Ae,{row:y,home:e,onBack:()=>o(null)},y.path):t.jsx("div",{className:"flex flex-col h-full",children:t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsx(ke,{columns:f,rows:n,getKey:r=>r.path,activeKey:h,onRowClick:r=>o(r.path),empty:t.jsxs(t.Fragment,{children:["no plugins installed",t.jsxs("div",{className:"mt-2 text-fg-faint",children:["install one from the Library view or run ",t.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const Ge=c.memo($e),te={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Pe({seeders:e,seedStatus:n,onDismiss:i,onOpenLibrary:s}){return t.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:e.map(a=>t.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[te[a]," setup failed after retrying — manual fix needed"]}),a==="dev-plugin"?t.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",t.jsx("button",{onClick:s,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):t.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[a].fix})]}),t.jsx("button",{onClick:()=>i(a),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${te[a]} warning`,children:"✕"})]},a))})}function ne({active:e,onChange:n}){const i=[["installed","Installed"],["library","Library"]];return t.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:i.map(([s,a])=>t.jsx("button",{onClick:()=>n(s),role:"tab","aria-selected":e===s,className:`px-2 py-0.5 text-xs ${e===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:a},s))})}const Ee=250,Ce=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function Ae({row:e,home:n,onBack:i}){var O,j,H,B,U;const[s,a]=c.useState([]),[d,l]=c.useState([]),[h,o]=c.useState([]),[u,N]=c.useState([]),[m,I]=c.useState([]),[D,F]=c.useState("skills"),[E,C]=c.useState(null),[b,f]=c.useState(!0),[p,w]=c.useState([]),y=c.useRef(0),r=c.useRef(!1),g=c.useCallback(async()=>{if(!n)return;const v=++y.current;try{const{manifest:M}=await ue(e.path),[z,V,he]=await Promise.all([oe(e.path),me(e.path,M),K(`${e.path}/bin`,{filesOnly:!0})]),G=z?await ce(z):[],[X,Y]=await Promise.all([ie(V.agentFiles),ie(V.commandFiles)]),Q=V.mcpServers,fe=await Promise.all([...new Set([...Ce.map(A=>`${e.path}/${A}`),...V.sourcePaths])].map(async A=>await window.api.config.exists(A)?A:null));if(v!==y.current)return;a(G),l(X),o(Y),N(Q),I(he);const Z=fe.filter(A=>A!==null);w(A=>A.join("\0")===Z.join("\0")?A:Z),r.current||(r.current=!0,F(G.length>0?"skills":X.length>0?"agents":Y.length>0?"commands":Q.length>0?"mcp":e.hooks>0?"hooks":e.monitors>0?"monitors":e.hasLsp?"lsp":"files"))}catch(M){if(v!==y.current)return;q.error(`Failed to load plugin contents: ${M instanceof Error?M.message:String(M)}`)}finally{v===y.current&&f(!1)}},[e.path,e.name,e.hooks,e.monitors,e.hasLsp,n]);c.useEffect(()=>(f(!0),g(),()=>{y.current+=1}),[g]);const k=c.useRef(null),$=c.useRef(!1),x=c.useRef(!1),T=c.useCallback(async()=>{if($.current){x.current=!0;return}$.current=!0;try{do x.current=!1,await g();while(x.current)}finally{$.current=!1}},[g]),J=c.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,T()},Ee)},[T]);c.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]),ae(p,J,{depth:0});const W=[{key:"skills",label:"Skills",count:s.length},{key:"agents",label:"Agents",count:d.length},{key:"commands",label:"Commands",count:h.length},{key:"mcp",label:"MCP server",count:u.length},{key:"hooks",label:"Hooks",count:e.hooks},{key:"monitors",label:"Monitors",count:e.monitors},{key:"lsp",label:"LSP",count:e.hasLsp?1:0},{key:"files",label:"Bin",count:m.length}],R=(O=e.manifest)!=null&&O.author?typeof e.manifest.author=="string"?e.manifest.author:e.manifest.author.name??null:null,_=async v=>{const M=await window.api.shell.open({as:"external",url:v});M.ok||q.error(M.error??`Failed to open ${v}`)};return E?t.jsx(Se,{pluginName:((j=e.manifest)==null?void 0:j.name)??e.name,skills:s,initialSelectedId:E.id,onBack:()=>C(null)},E.id):t.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[t.jsx("button",{type:"button",onClick:i,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),t.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((H=e.manifest)==null?void 0:H.name)??e.name}),(B=e.manifest)!=null&&B.version?t.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",e.manifest.version]}):null,(U=e.manifest)!=null&&U.description?t.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:e.manifest.description}):t.jsx("span",{className:"flex-1"}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(re,{input:de(e)}),e.hasMcp?t.jsx(xe,{tone:"accent",children:"MCP"}):null]})]}),e.manifest?t.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[R?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"Author "}),R]}):null,e.manifest.license?t.jsxs("span",{className:"text-fg-dim truncate",children:[t.jsx("span",{className:"text-fg-faint",children:"License "}),e.manifest.license]}):null,e.manifest.homepage?t.jsxs("button",{onClick:()=>_(e.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:e.manifest.homepage,children:[t.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),e.manifest.homepage]}):null,t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})]}):t.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:t.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:e.path})}),t.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[t.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:W.map(v=>t.jsxs("button",{type:"button",disabled:v.count===0,onClick:()=>F(v.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${v.count===0?"text-fg-faint opacity-50 cursor-default":D===v.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsx("span",{children:v.label}),v.count>0?t.jsx("span",{className:"font-mono text-fg-faint",children:v.count}):null]},v.key))}),t.jsx("div",{className:"min-h-0 overflow-auto",children:b?t.jsx(S,{title:"scanning…"}):t.jsx(Me,{active:D,row:e,skills:s,agents:d,commands:h,mcpServers:u,files:m,onOpenSkill:C})})]})]})}function Me({active:e,row:n,skills:i,agents:s,commands:a,mcpServers:d,files:l,onOpenSkill:h}){return e==="skills"?i.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:i.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description,onClick:()=>h(o)},o.id))}):e==="agents"?s.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:s.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="commands"?a.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:a.map((o,u)=>t.jsx(L,{n:u+1,name:o.name??o.id,description:o.description},o.id))}):e==="mcp"?d.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:d.map((o,u)=>t.jsx(L,{n:u+1,name:o.name,description:o.description},o.id))}):e==="hooks"?n.hooks===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):e==="monitors"?n.monitors===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:t.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):e==="lsp"?n.hasLsp?t.jsx("div",{children:t.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):t.jsx(S,{title:"no components"}):l.length===0?t.jsx(S,{title:"no components"}):t.jsx("div",{children:l.map((o,u)=>t.jsx(L,{n:u+1,name:o,description:null},o))})}function L({n:e,name:n,description:i,onClick:s}){const a=s?"button":"div";return t.jsxs(a,{onClick:s,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${s?"hover:bg-bg-hi cursor-pointer":""}`,children:[t.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(e).padStart(2,"0")}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),i?t.jsx("div",{className:"text-fg-dim text-xs truncate",children:i}):null]})]})}const Le=4;async function De(e,n,i){const s=new Array(e.length);let a=0;const d=Array.from({length:Math.min(n,e.length)},async()=>{for(;a<e.length;){const l=a++;s[l]=await i(e[l])}});return await Promise.all(d),s}function Re(e,n){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,error:n}}async function _e(e){const{hasManifest:n,manifest:i}=await ue(e.path),[s,a]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let d=0;if(a){const m=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(m.data)?d=m.data.length:m.data&&typeof m.data=="object"&&Array.isArray(m.data.monitors)&&(d=m.data.monitors.length)}const[l,h,o]=await Promise.all([me(e.path,i),K(`${e.path}/bin`,{filesOnly:!0}),oe(e.path)]),u=h.length,N=o?(await ce(o)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:n,manifest:i,hasLsp:s,monitors:d,hooks:l.hooks,agents:l.agentFiles.length,commands:l.commandFiles.length,skills:N,binCount:u,hasMcp:l.mcpServers.length>0}}async function ue(e){let n=`${e}/.claude-plugin/plugin.json`,i=await window.api.config.exists(n);if(i||(n=`${e}/plugin.json`,i=await window.api.config.exists(n)),!i)return{hasManifest:i,manifest:null};const s=await window.api.config.readJson(n),a=s.exists&&!s.parseError&&s.data&&typeof s.data=="object"&&!Array.isArray(s.data);return{hasManifest:i,manifest:a?s.data:null}}const P=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Oe(e,n){const i=n.startsWith("/")?n.startsWith(`${e}/`)?n.slice(e.length+1):null:n;if(i===null)return se(n);const s=[];for(const a of i.split("/"))if(!(a===""||a===".")){if(a!=="..")s.push(a);else if(s.pop()===void 0)return se(n)}return s.length>0?`${e}/${s.join("/")}`:e}function se(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Fe(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function Te(e){if(!P(e))return null;if(P(e.mcpServers))return e.mcpServers;const n=Object.values(e);return n.length>0&&n.every(s=>P(s)&&(typeof s.command=="string"||typeof s.url=="string"))?e:null}function Be(e){if(!P(e))return 0;const n=P(e.hooks)?e.hooks:e;return Object.values(n).reduce((i,s)=>Array.isArray(s)?i+s.reduce((a,d)=>a+(P(d)&&Array.isArray(d.hooks)?d.hooks.length:0),0):i,0)}async function me(e,n){const i=(b,f)=>{const p=new Set;for(const w of Fe(b)){const y=Oe(e,w);y&&p.add(y)}return p.add(`${e}/${f}`),[...p]},s=async b=>{const f=new Set;for(const p of b)if(p.endsWith(".md"))f.add(p);else for(const w of await K(p,{filesOnly:!0}))w.endsWith(".md")&&f.add(`${p}/${w}`);return[...f]},a=async b=>{try{const f=await window.api.config.readJson(b);return f.exists&&!f.parseError?f.data:null}catch{return null}},d=i(n==null?void 0:n.commands,"commands"),l=i(n==null?void 0:n.agents,"agents"),h=n==null?void 0:n.hooks,o=i(typeof h=="string"||Array.isArray(h)?h:void 0,"hooks/hooks.json"),u=n==null?void 0:n.mcpServers,N=i(typeof u=="string"||Array.isArray(u)?u:void 0,".mcp.json"),[m,I,D,F]=await Promise.all([s(d),s(l),Promise.all(o.map(a)),Promise.all(N.map(a))]),E=[...P(h)?[h]:[],...D].reduce((b,f)=>b+Be(f),0),C=new Map;for(const b of[...P(u)?[u]:[],...F])for(const[f,p]of Object.entries(Te(b)??{})){if(C.has(f))continue;const w=P(p)?p.command:void 0,y=P(p)?p.url:void 0;C.set(f,{id:f,name:f,description:typeof w=="string"?w:typeof y=="string"?y:null})}return{commandFiles:m,agentFiles:I,hooks:E,mcpServers:[...C.values()],sourcePaths:[...d,...l,...o,...N]}}async function ie(e){const n=await Promise.all(e.map(s=>window.api.config.readText(s))),i=[];return e.forEach((s,a)=>{if(!n[a].exists)return;const d=s.slice(s.lastIndexOf("/")+1),l=le(n[a].text);i.push({id:s,name:l.name??d.replace(/\.md$/,""),description:l.description})}),i}async function K(e,n){try{return(await window.api.config.listDir(e,n)).entries.map(s=>s.name)}catch{return[]}}export{Ge as Plugins};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a6 as P,b4 as G,aF as x,ap as i,$ as R,B as T,a as _}from"./index-DZ5TJKNI.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-wBI4Fwh3.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),$=new Set,j=new Set;for(const e of I){const t=e.official?$:j;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(S.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(S.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),F=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.map(e=>e.command.trim())),q=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),y=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return $.has(t)?l("official MCP server (catalog)"):j.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?y("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return F.has(t)||n&&Z.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&q.has(t))return l("built-in Claude Code command");if(Q.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?y(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!b)return;const s=C=>{v.current&&!v.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[b]);const w=ne(e.type,t??null,e.name),f=te(e),p=d[w],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(_,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:v,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),b&&i.jsxs("span",{className:`absolute ${R.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(w,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${T[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(w,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{bf as _,aF as d,a2 as P,ap as e,a as N,bn as D,X as O,D as A,a0 as H,a3 as U}from"./index-DZ5TJKNI.js";import{b as L,P as E,E as T,R as z,u as W,S as G}from"./useRemotePeers-Dy_o0WlY.js";import"./monaco-editor-BsIlgG7c.js";function M(o){return o instanceof Error?o.message:String(o)}function V({peerId:o,machineName:i,onOpenTerminal:y}){const c=_(a=>a.show),[x,m]=d.useState([]),[p,w]=d.useState("loading"),[h,k]=d.useState(null),[t,j]=d.useState(""),[C,I]=d.useState(!1),f=d.useRef(0),v=d.useCallback(async()=>{const a=++f.current;w("loading");try{let u;try{const s=await window.api.remoteClient.send(o,"cmd:sessions:list",{});u=Array.isArray(s==null?void 0:s.sessions)?s.sessions:[]}catch{if(a!==f.current)return;const s=await window.api.remoteClient.send(o,"cmd:sessions:load",{});u=(Array.isArray(s==null?void 0:s.tabs)?s.tabs:[]).map(b=>({kind:"project",tabId:b.sessionId,cwd:b.cwd,title:b.label||b.cwd,project:b.label||P(b.cwd)}))}if(a!==f.current)return;m(u),w("ready")}catch(u){if(a!==f.current)return;w("error"),c("error",`Could not load sessions from ${i}: ${M(u)}`)}},[o,i,c]);d.useEffect(()=>(v(),()=>{f.current++}),[v]);const S=d.useMemo(()=>{const a=new Map;for(const s of x){const g=s.project||P(s.cwd);(a.get(g)??a.set(g,[]).get(g)).push(s)}const u=s=>s.kind==="project"?0:1;for(const s of a.values())s.sort((g,b)=>u(g)-u(b));return[...a.entries()].sort((s,g)=>s[0].localeCompare(g[0]))},[x]),n=t.trim(),$=h!==null&&n.length>0&&!C,R=d.useCallback(async()=>{if(!(h===null||t.trim().length===0)){I(!0);try{await window.api.remoteClient.send(o,"cmd:chat:send",{tabId:h,prompt:t}),j("")}catch(a){c("error",`Could not send prompt to ${i}: ${M(a)}`)}finally{I(!1)}}},[o,i,h,t,c]);return e.jsxs("div",{"data-testid":"remote-sessions-panel",className:"flex flex-col gap-3",children:[e.jsx(L,{right:e.jsx(N,{tone:"accent",className:"",title:`Sessions on ${i}`,children:e.jsxs("span",{"data-testid":"remote-sessions-badge",children:["Remote: ",i]})}),children:"Remote sessions"}),e.jsx("div",{className:"flex justify-end",children:e.jsx(E,{icon:"history",testId:"remote-sessions-refresh",onClick:()=>{v()},disabled:p==="loading",children:"Refresh"})}),p==="loading"&&e.jsx(T,{testId:"remote-sessions-loading",children:"Loading sessions…"}),p==="error"&&e.jsxs(T,{testId:"remote-sessions-error",children:["Could not load sessions from ",i,"."]}),p==="ready"&&x.length===0&&e.jsxs(T,{testId:"remote-sessions-empty",children:["No sessions open on ",i,"."]}),p==="ready"&&S.map(([a,u])=>e.jsx("div",{"data-testid":"remote-sessions-group",className:"flex flex-col gap-2",children:u.map(s=>e.jsx(z,{testId:`remote-session-${s.tabId}`,icon:"terminal",title:s.title||s.cwd,subtitle:s.cwd,badge:s.kind==="epic"&&s.tag?e.jsx(N,{tone:"accent",children:s.tag}):void 0,action:e.jsxs("div",{className:"flex items-center gap-2",children:[s.kind==="project"&&y&&e.jsx(E,{icon:"terminal",kind:"ghost",testId:`remote-session-terminal-${s.tabId}`,onClick:()=>y(s.cwd),children:"Terminal here"}),e.jsx(E,{kind:h===s.tabId?"soft":"ghost",testId:`remote-session-select-${s.tabId}`,onClick:()=>k(s.tabId),children:h===s.tabId?"Selected":"Select"})]})},s.tabId))},a)),p==="ready"&&x.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("textarea",{"data-testid":"remote-sessions-prompt",value:t,onChange:a=>j(a.target.value),rows:3,placeholder:h?`Prompt for the selected session on ${i}`:"Select a session first",className:"w-full rounded-lg bg-bg-hi border border-line px-3 py-2 text-[13px] text-fg placeholder:text-fg-faint"}),e.jsx("div",{className:"flex justify-end",children:e.jsx(E,{icon:"play",testId:"remote-sessions-send",onClick:()=>{R()},disabled:!$,children:"Send"})})]})]})}const X=260;function q({peerId:o,machineName:i,cwd:y,onClose:c}){const x=d.useRef(null),m=d.useRef(null),p=_(t=>t.show),[w,h]=d.useState(!1);d.useEffect(()=>{const t=x.current;if(!t)return;const j=crypto.randomUUID();let C=!0,I=!1,f=!1;const v=(r,l)=>{C&&p("error",`Remote terminal ${r} failed: ${l instanceof Error?l.message:String(l)}`)},S=(r,l)=>window.api.remoteClient.send(o,r,l),n=new D.Terminal({fontFamily:'"IBM Plex Mono", JetBrains Mono, ui-monospace, Menlo, monospace',fontSize:A.fontSize,lineHeight:1.2,cursorBlink:!0,allowProposedApi:!0,theme:O[A.theme]}),$=new H.FitAddon;n.loadAddon($);const R=()=>{if(U(t.clientWidth,t.clientHeight))try{$.fit()}catch{}};n.open(t),R(),n.focus();const a=window.api.remoteClient.onEvent(r=>{if(r.peerId!==o)return;const l=r.payload??{};l.tabId===j&&(r.type==="event:pty:data"?typeof l.data=="string"&&n.write(l.data):r.type==="event:pty:exit"&&(I=!0,n.options.disableStdin=!0,n.write(`\r
|
|
2
|
+
\x1B[38;5;240m[remote session exited code=${l.exitCode??"?"}]\x1B[0m\r
|
|
3
|
+
`),h(!0)))}),u=n.onData(r=>{I||S("cmd:pty:write",{tabId:j,data:r}).catch(l=>v("write",l))}),s=n.onResize(({cols:r,rows:l})=>{I||S("cmd:pty:resize",{tabId:j,cols:r,rows:l}).catch(F=>v("resize",F))});S("cmd:pty:spawn",{tabId:j,cwd:y,cols:n.cols,rows:n.rows}).catch(r=>v("spawn",r)),m.current=()=>{f||(f=!0,S("cmd:pty:kill",{tabId:j}).catch(r=>v("kill",r)))};const g=()=>R();window.addEventListener("resize",g);const b=new ResizeObserver(()=>R());return b.observe(t),()=>{var r;window.removeEventListener("resize",g),b.disconnect(),a(),u.dispose(),s.dispose(),(r=m.current)==null||r.call(m),m.current=null,C=!1,n.dispose()}},[o,y,p]);const k=()=>{var t;(t=m.current)==null||t.call(m),c()};return e.jsxs("div",{"data-testid":"remote-terminal-panel",className:"bg-bg-hi border border-line rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-[18px] pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(L,{children:"Remote terminal"}),e.jsx(N,{tone:"accent",children:e.jsxs("span",{"data-testid":"remote-terminal-badge",children:["Remote: ",i]})}),w&&e.jsx(N,{tone:"dim",children:"exited"})]}),e.jsx(E,{kind:"ghost",onClick:k,testId:"remote-terminal-close",children:"Close"})]}),e.jsx("div",{ref:x,"data-testid":"remote-terminal-host",className:"w-full bg-bg",style:{height:X}})]})}const J="relay_client_auth_unavailable",K="device_offline",Q={win32:"Windows",darwin:"macOS",linux:"Linux"},B=o=>o?Q[o]??o:"OS unknown";function Y({peers:o,selectedId:i,onSelect:y}){return e.jsxs("div",{className:"w-[240px] shrink-0 border-r border-line p-3 space-y-2 overflow-y-auto","data-testid":"remote-view-switcher",children:[e.jsx(L,{children:"Machines"}),o.map(c=>{const x=c.status==="authenticated";return e.jsxs("button",{type:"button","data-testid":"remote-view-machine","aria-pressed":c.peerId===i,onClick:()=>y(c.peerId),className:`w-full text-left rounded-lg border px-3 py-2 transition-colors ${c.peerId===i?"bg-bg-hi border-accent/40":"bg-bg border-line hover:bg-bg-hi"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:c.machineName}),x?e.jsx(N,{tone:"good",children:"online"}):e.jsx(N,{tone:"dim",children:"offline"})]}),e.jsx("div",{className:"text-[11.5px] text-fg-faint",children:B(c.os)})]},c.peerId)})]})}function se({onOpenSettings:o}){const{peers:i,connect:y,confirmSas:c}=W(),[x,m]=d.useState(null),[p,w]=d.useState("sessions"),[h,k]=d.useState("");if(i.length===0)return e.jsxs("div",{className:"p-6 space-y-3","data-testid":"remote-view",children:[e.jsx(T,{testId:"remote-view-empty",children:"No machines paired yet. Pair a machine in Settings → Phone remote."}),e.jsx(E,{testId:"remote-view-open-settings",onClick:o,children:"Open Settings"})]});const t=i.find(n=>n.peerId===x)??i[0],j=t.status==="authenticated",C=t.status==="failed"&&t.reason===J,I=t.status==="connecting",f=`Remote: ${t.machineName}`,v=n=>{m(n),w("sessions"),k("")},S=n=>{k(n),w("terminal")};return e.jsxs("div",{className:"flex h-full min-h-0","data-testid":"remote-view",children:[e.jsx(Y,{peers:i,selectedId:t.peerId,onSelect:v}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col p-4 gap-3 overflow-y-auto",children:[e.jsxs("div",{"data-testid":"remote-view-header",className:"flex items-center gap-2.5",children:[e.jsx(N,{tone:"accent",className:"",title:t.peerId,children:e.jsx("span",{"data-testid":"remote-view-header-badge",children:f})}),e.jsx("span",{className:"text-[12.5px] text-fg-faint",children:B(t.os)})]}),t.status==="pending_sas"&&t.sas&&e.jsx(G,{peer:"other machine",testId:"remote-view-sas",code:t.sas,onConfirm:()=>{c(t.peerId)}}),j?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex gap-2 border-b border-line pb-2",children:["sessions","terminal"].map(n=>e.jsxs("button",{type:"button","data-testid":`remote-view-tab-${n}`,onClick:()=>w(n),className:`inline-flex items-center gap-2 rounded-lg px-3 py-1.5 text-[13px] font-semibold ${p===n?"bg-bg-hi text-fg border border-line":"text-fg-dim hover:text-fg"}`,children:[n==="sessions"?"Sessions":"Terminal",e.jsx(N,{tone:"accent",children:f})]},n))}),p==="sessions"?e.jsx(V,{peerId:t.peerId,machineName:t.machineName,onOpenTerminal:S},t.peerId):e.jsx(q,{peerId:t.peerId,machineName:t.machineName,cwd:h,onClose:()=>w("sessions")},t.peerId)]}):e.jsxs("div",{className:"space-y-2","data-testid":"remote-view-offline",children:[e.jsx(T,{children:C?"The bilko.run relay does not support desktop clients yet":t.reason===K?`${t.machineName} is offline.`:`Not connected to ${t.machineName}.`}),!C&&t.status!=="pending_sas"&&e.jsx(z,{icon:"terminal",title:t.machineName,subtitle:t.peerId,action:e.jsx(E,{testId:"remote-view-connect",disabled:I,onClick:()=>{y(t.peerId)},children:I?"Connecting…":"Connect"})})]})]})]})}export{se as RemoteMachines};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ap as e,aj as x}from"./index-DZ5TJKNI.js";function m({dirty:a,busy:n,parseError:t,lastSavedAt:c,onSave:i,onRevert:l,leading:d}){const s=a&&!n&&!t;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:d}),t&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:t,children:t}),!a&&!t&&c&&e.jsx("span",{className:"text-fg-faint",children:x(c)}),a&&!t&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:l,disabled:!a||n,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:i,disabled:!s,className:`px-2.5 py-0.5 rounded border ${s?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:n?"Saving…":"Save"})]})}export{m as S};
|