claude-code-session-manager 0.92.1 → 0.93.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/DataModel-DDGx3qrn.js +1 -0
- package/dist/assets/{History-BOR_fJNr.js → History-CHBjYZyD.js} +2 -2
- package/dist/assets/{Hooks-BtD436iL.js → Hooks-DG4c-Rzz.js} +3 -3
- package/dist/assets/{HostBilko-CMe5cH3H.js → HostBilko-DHXcpV2c.js} +1 -1
- package/dist/assets/{Library-DeKdY-tD.js → Library-CN1h5rAE.js} +1 -1
- package/dist/assets/{MarkdownEditor-CbzC-Oqf.js → MarkdownEditor-DmBxrhdn.js} +1 -1
- package/dist/assets/{McpServers-DKN75Shn.js → McpServers-Beb_HD6I.js} +2 -2
- package/dist/assets/{Memory-B68AJjg2.js → Memory-Dk4uDCjg.js} +4 -4
- package/dist/assets/{Permissions-Cr0RRvNy.js → Permissions-BovobeZw.js} +3 -3
- package/dist/assets/Plugins-DvOf_B62.js +2 -0
- package/dist/assets/ProvenanceBadge-Dutz_4OY.js +1 -0
- package/dist/assets/{SaveBar-87ZJfscX.js → SaveBar-CT5u6ZCJ.js} +1 -1
- package/dist/assets/Scheduler-B7GSnZj5.js +16 -0
- package/dist/assets/{ScopeSwitcher-CKzpqjJ_.js → ScopeSwitcher-BUYDpz2v.js} +1 -1
- package/dist/assets/Settings-DIRmr3tL.js +3 -0
- package/dist/assets/{SkillReferenceGraph-D_-wg4r9.js → SkillReferenceGraph-CdGr6d3_.js} +1 -1
- package/dist/assets/Skills-BQOheQv4.js +3 -0
- package/dist/assets/SystemPrompt-5LsimKbX.js +1 -0
- package/dist/assets/TagLibrary-DreLsT3n.js +1 -0
- package/dist/assets/{TiptapBody-DYXIp8aG.js → TiptapBody-C9kmlBnI.js} +1 -1
- package/dist/assets/{Toggle-CDXR5l3m.js → Toggle-BKLCBu9A.js} +1 -1
- package/dist/assets/{index-D3P_jldk.css → index-CKH5Uxik.css} +1 -1
- package/dist/assets/index-Db_SK9rW.js +3079 -0
- package/dist/assets/settingsSchema-B5jBhSUP.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/main/__tests__/agentEffortResolve.test.cjs +117 -0
- package/src/main/__tests__/agentLibrary.test.cjs +21 -0
- package/src/main/__tests__/agentModelResolve.test.cjs +16 -0
- package/src/main/__tests__/agentOverlayWrite.test.cjs +95 -0
- package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +44 -0
- package/src/main/__tests__/personaMerge.test.cjs +169 -0
- package/src/main/__tests__/prdCreatePlanId.test.cjs +132 -0
- package/src/main/__tests__/promptSessionsCreateEpicHandler.test.cjs +13 -0
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +47 -2
- package/src/main/agentLibrary.cjs +86 -40
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +5 -0
- package/src/main/index.cjs +10 -0
- package/src/main/ipcSchemas.cjs +12 -0
- package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +10 -5
- package/src/main/lib/__tests__/modelCatalog.test.cjs +202 -0
- package/src/main/lib/agentEffortResolve.cjs +74 -0
- package/src/main/lib/agentModelResolve.cjs +52 -59
- package/src/main/lib/agentPersonaSchema.cjs +3 -0
- package/src/main/lib/effectiveModelInfo.cjs +38 -20
- package/src/main/lib/epicMint.cjs +5 -2
- package/src/main/lib/epicWorktreeMerge.cjs +7 -6
- package/src/main/lib/modelCatalog.cjs +243 -0
- package/src/main/lib/personaMerge.cjs +166 -0
- package/src/main/lib/prdCreate.cjs +23 -5
- package/src/main/lib/prdDisposition.cjs +46 -0
- package/src/main/lib/prdFrontmatter.cjs +6 -2
- package/src/main/lib/promptSessionSchema.cjs +3 -0
- package/src/main/lib/promptSessionsCreateEpic.cjs +5 -3
- package/src/main/scheduler/prdParser.cjs +2 -0
- package/src/main/scheduler.cjs +21 -5
- package/src/main/templates/PRD_AUTHORING.md +4 -0
- package/src/preload/api.d.ts +53 -2
- package/src/preload/index.cjs +4 -0
- package/dist/assets/AgentLibrary-Ci6u03bq.js +0 -3
- package/dist/assets/DataModel-BIqcjsv2.js +0 -1
- package/dist/assets/ListDetail-CtVjrHKB.js +0 -1
- package/dist/assets/Panel-C2YTW-qP.js +0 -1
- package/dist/assets/Plugins-DbZkJs5l.js +0 -2
- package/dist/assets/ProvenanceBadge-kJ__BOQv.js +0 -1
- package/dist/assets/Scheduler-DdEaxku8.js +0 -16
- package/dist/assets/Settings-CjywVsNB.js +0 -3
- package/dist/assets/Skills-Cd_yPO_l.js +0 -3
- package/dist/assets/SystemPrompt-2z6eGPSF.js +0 -1
- package/dist/assets/TagLibrary-DcaWQSp4.js +0 -1
- package/dist/assets/index-D5H_H5wC.js +0 -3074
- package/dist/assets/settingsSchema-JRDfjgHb.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`}function we(n){let t=Object.keys(n).length+1,a=`server-${t}`;for(;n[a];)t+=1,a=`server-${t}`;return a}function Se(){const n=oe(),t=ie(),a=(t==null?void 0:t.cwd)??null,d=ce(s=>s.navFace),p=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"),[w,_]=c.useState("");c.useEffect(()=>{if(b.current!==d){if(b.current=d,p.current){p.current=!1;return}j(d==="project"&&a?"project":"user")}},[d,a]);const f=c.useMemo(()=>n?ve(o,n,a):null,[n,o,a]),k=N(s=>s.files),l=N(s=>s.loadJson),v=N(s=>s.setDraft),m=N(s=>s.saveJson),I=N(s=>s.revert),T=N(s=>s.watchFile),X=N(s=>s.unwatchFile);c.useEffect(()=>{if(f)return k[f]||l(f),T(f),()=>X(f)},[f]);const[ee,R]=c.useState(null),[J,K]=c.useState(null),[B,z]=c.useState(!1),F=c.useRef(0),A=c.useRef(!0);c.useEffect(()=>()=>{A.current=!1},[]);const V=async()=>{const s=++F.current;z(!0);try{const i=await window.api.mcp.status();if(!A.current||s!==F.current)return;K(i),i.ok||q.error(i.error??"MCP status probe failed")}catch(i){if(!A.current||s!==F.current)return;K(null),q.error(i.message||"MCP status probe failed")}finally{A.current&&s===F.current&&z(!1)}};if(c.useEffect(()=>{V()},[]),!n)return e.jsx(O,{title:"loading…"});if(x==="library")return e.jsx($,{toolbar:e.jsx(D,{active:x,onChange:u}),children:e.jsx(ue,{})});if(o==="project"&&!a)return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(D,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(H,{scopes:["user","project"],active:o,onChange:s=>{p.current=!0,j(s)}})]}),children:e.jsx(O,{title:"no active project"})});if(!f)return e.jsx(O,{title:"loading…"});const y=k[f],{full:te,servers:h,err:se}=y?ye(y.draftRaw):{full:{},servers:{},err:null},L=Object.keys(h).sort(),M=r?h[r]:null,P=s=>{R(null),v(f,Ne(te,s))},ae=()=>{const s=we(h);P({...h,[s]:{type:"stdio",command:"",args:[]}}),g(s)},le=s=>{const i={...h};delete i[s],P(i),r===s&&g(null)},ne=(s,i)=>{if(!i||i===s||h[i])return;const S={};for(const C of Object.keys(h))S[C===s?i:C]=h[C];P(S),g(i)},re=(s,i)=>{P({...h,[s]:i})};return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(D,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(H,{scopes:["user","project"],active:o,onChange:s=>{p.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:[L.length," server",L.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:f}),e.jsx("div",{className:"flex-1"}),r&&M&&e.jsx(Y,{scope:o,input:U(r,M),className:"mr-2"}),e.jsx("button",{onClick:V,disabled:B,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:B?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:ae,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:y?e.jsx(xe,{dirty:y.dirty,busy:y.busy,parseError:ee||se||y.parseError,lastSavedAt:y.lastSavedAt,onSave:async()=>{R(null);const s=await m(f);s.ok||R(s.error??"save failed")},onRevert:()=>{R(null),I(f)}}):null,children:e.jsx(de,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:w,onChange:s=>_(s.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),L.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):L.filter(s=>!w||s.toLowerCase().includes(w.toLowerCase())).map(s=>{var C;const i=G(s,J),S=(C=h[s].description)==null?void 0:C.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(W,{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:[e.jsx(Q,{tone:i.badgeTone,children:i.label}),e.jsx(Y,{interactive:!1,scope:o,input:U(s,h[s])}),e.jsx("span",{className:"text-fg-faint",children:h[s].type??"stdio"})]})]}),S?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:S,children:S}):null]},s)})]}),detail:r&&M?e.jsx(Ce,{name:r,server:M,connection:G(r,J),onTestConnection:V,testing:B,onRename:s=>ne(r,s),onChange:s=>re(r,s),onRemove:()=>le(r)}):e.jsx(O,{title:"select a server or click + new"})})})}const Pe=c.memo(Se);function Ce({name:n,server:t,connection:a,onTestConnection:d,testing:p,onRename:b,onChange:o,onRemove:j}){var k;const r=t.type??"stdio",g=be.has(n),x=je.has(n),u=(k=t.permissions)==null?void 0:k.tools,w=u===void 0?"inherit":u==="allow"?"allow":u==="deny"?"deny":"list",_=Array.isArray(u)?u:[],f=(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(W,{state:a.dotState,size:"md",title:a.label}),e.jsx(Q,{tone:a.badgeTone,children:a.label}),e.jsx("button",{onClick:d,disabled:p,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:p?"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:n,onBlur:l=>b(l.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(E,{label:"description",value:t.description??"",onChange:l=>o({...t,description:l||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:n})," 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:n})," 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:l=>o({...t,type:l.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:ge.map(l=>e.jsx("option",{value:l,children:l},l))}),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(E,{label:"command",value:t.command??"",onChange:l=>o({...t,command:l}),placeholder:"npx / node / python …"}),e.jsx(E,{label:"args",value:(t.args??[]).join(" "),onChange:l=>o({...t,args:l.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(Z,{label:"env",value:t.env??{},onChange:l=>o({...t,env:l})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"url",value:t.url??"",onChange:l=>o({...t,url:l}),placeholder:"https://…"}),e.jsx(Z,{label:"headers",value:t.headers??{},onChange:l=>o({...t,headers:l})})]}),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:l=>o({...t,alwaysLoad:l.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:l=>o({...t,enabled:l.target.checked?void 0:!1})}),e.jsx("span",{className:"text-fg-dim",children:"load this server in new sessions"})]})]}),e.jsx(E,{label:"disabledTools",value:f,onChange:l=>{const v=l.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:w,onChange:l=>{const v=l.target.value,m={...t};if(v==="inherit"){if(m.permissions){const{tools:I,...T}=m.permissions;m.permissions=Object.keys(T).length?T: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…"})]}),w==="list"?e.jsx("input",{value:_.join(", "),onChange:l=>{const v=l.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 E({label:n,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:n}),e.jsx("input",{value:t,onChange:p=>a(p.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 Z({label:n,value:t,onChange:a}){const[d,p]=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:n}),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=>p(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}),p(""),o(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}export{Pe as McpServers,we as nextServerName};
|
|
1
|
+
import{aj as e,ay as c,aQ as oe,aL as ie,aS as ce,aN as N,l as O,u as $,q as de,a as Z,aK as q}from"./index-Db_SK9rW.js";import{S as xe}from"./SaveBar-CT5u6ZCJ.js";import{S as Y}from"./ScopeSwitcher-BUYDpz2v.js";import{P as G}from"./ProvenanceBadge-Dutz_4OY.js";import{M as ue,V as D}from"./Library-CN1h5rAE.js";import"./monaco-editor-BW5C4Iv1.js";const pe={live:"bg-emerald-400",idle:"bg-amber-400",offline:"bg-fg-faint",attention:"bg-accent",paused:"bg-zinc-500"},fe={sm:"w-1.5 h-1.5",md:"w-2 h-2"},me={on:"live",off:"offline",warn:"attention",live:"live",idle:"idle"};function W({state:n,kind:t,pulse:a=!1,size:d="sm",className:p="",title:b,"aria-label":o}){const j=n??(t?me[t]:"idle"),r=pe[j],h=fe[d],x=a?"animate-pulse":"",u=o??b??j;return e.jsx("span",{role:"img","aria-label":u,className:`inline-block rounded-full ${h} ${r} ${x} ${p}`.trim(),title:b})}const ge={failed:"Failed","needs-auth":"Needs auth",pending:"Pending approval"};function H(n,t){const a=t!=null&&t.ok?t.servers.find(d=>d.name===n):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:ge[a.status],probeStatus:a.status,badgeTone:"warn",dotState:"attention"}}const Q=(n,t)=>({type:"mcp",name:n,command:t.command,args:t.args,url:t.url}),he=["stdio","http","streamable-http","sse","ws"],be=new Set(["workspace"]),je=new Set(["ide","tasks"]);function ve(n,t,a){return n==="user"?`${t}/.claude.json`:a?`${a}/.mcp.json`:null}function ye(n){if(n.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(n),a=t.mcpServers??{};return{full:t,servers:a,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Ne(n,t){return JSON.stringify({...n,mcpServers:t},null,2)+`
|
|
2
|
+
`}function we(n){let t=Object.keys(n).length+1,a=`server-${t}`;for(;n[a];)t+=1,a=`server-${t}`;return a}function Se(){const n=oe(),t=ie(),a=(t==null?void 0:t.cwd)??null,d=ce(s=>s.navFace),p=c.useRef(!1),b=c.useRef(d),[o,j]=c.useState(()=>d==="project"&&a?"project":"user"),[r,h]=c.useState(null),[x,u]=c.useState("installed"),[w,_]=c.useState("");c.useEffect(()=>{if(b.current!==d){if(b.current=d,p.current){p.current=!1;return}j(d==="project"&&a?"project":"user")}},[d,a]);const f=c.useMemo(()=>n?ve(o,n,a):null,[n,o,a]),k=N(s=>s.files),l=N(s=>s.loadJson),v=N(s=>s.setDraft),m=N(s=>s.saveJson),I=N(s=>s.revert),T=N(s=>s.watchFile),X=N(s=>s.unwatchFile);c.useEffect(()=>{if(f)return k[f]||l(f),T(f),()=>X(f)},[f]);const[ee,R]=c.useState(null),[J,K]=c.useState(null),[B,z]=c.useState(!1),F=c.useRef(0),A=c.useRef(!0);c.useEffect(()=>()=>{A.current=!1},[]);const V=async()=>{const s=++F.current;z(!0);try{const i=await window.api.mcp.status();if(!A.current||s!==F.current)return;K(i),i.ok||q.error(i.error??"MCP status probe failed")}catch(i){if(!A.current||s!==F.current)return;K(null),q.error(i.message||"MCP status probe failed")}finally{A.current&&s===F.current&&z(!1)}};if(c.useEffect(()=>{V()},[]),!n)return e.jsx(O,{title:"loading…"});if(x==="library")return e.jsx($,{toolbar:e.jsx(D,{active:x,onChange:u}),children:e.jsx(ue,{})});if(o==="project"&&!a)return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(D,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(Y,{scopes:["user","project"],active:o,onChange:s=>{p.current=!0,j(s)}})]}),children:e.jsx(O,{title:"no active project"})});if(!f)return e.jsx(O,{title:"loading…"});const y=k[f],{full:te,servers:g,err:se}=y?ye(y.draftRaw):{full:{},servers:{},err:null},L=Object.keys(g).sort(),M=r?g[r]:null,P=s=>{R(null),v(f,Ne(te,s))},ae=()=>{const s=we(g);P({...g,[s]:{type:"stdio",command:"",args:[]}}),h(s)},le=s=>{const i={...g};delete i[s],P(i),r===s&&h(null)},ne=(s,i)=>{if(!i||i===s||g[i])return;const S={};for(const C of Object.keys(g))S[C===s?i:C]=g[C];P(S),h(i)},re=(s,i)=>{P({...g,[s]:i})};return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(D,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(Y,{scopes:["user","project"],active:o,onChange:s=>{p.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:[L.length," server",L.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:f}),e.jsx("div",{className:"flex-1"}),r&&M&&e.jsx(G,{scope:o,input:Q(r,M),className:"mr-2"}),e.jsx("button",{onClick:V,disabled:B,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:B?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:ae,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:y?e.jsx(xe,{dirty:y.dirty,busy:y.busy,parseError:ee||se||y.parseError,lastSavedAt:y.lastSavedAt,onSave:async()=>{R(null);const s=await m(f);s.ok||R(s.error??"save failed")},onRevert:()=>{R(null),I(f)}}):null,children:e.jsx(de,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:w,onChange:s=>_(s.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),L.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):L.filter(s=>!w||s.toLowerCase().includes(w.toLowerCase())).map(s=>{var C;const i=H(s,J),S=(C=g[s].description)==null?void 0:C.trim();return e.jsxs("button",{onClick:()=>h(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(W,{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:[e.jsx(Z,{tone:i.badgeTone,children:i.label}),e.jsx(G,{interactive:!1,scope:o,input:Q(s,g[s])}),e.jsx("span",{className:"text-fg-faint",children:g[s].type??"stdio"})]})]}),S?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:S,children:S}):null]},s)})]}),detail:r&&M?e.jsx(Ce,{name:r,server:M,connection:H(r,J),onTestConnection:V,testing:B,onRename:s=>ne(r,s),onChange:s=>re(r,s),onRemove:()=>le(r)}):e.jsx(O,{title:"select a server or click + new"})})})}const Le=c.memo(Se);function Ce({name:n,server:t,connection:a,onTestConnection:d,testing:p,onRename:b,onChange:o,onRemove:j}){var k;const r=t.type??"stdio",h=be.has(n),x=je.has(n),u=(k=t.permissions)==null?void 0:k.tools,w=u===void 0?"inherit":u==="allow"?"allow":u==="deny"?"deny":"list",_=Array.isArray(u)?u:[],f=(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(W,{state:a.dotState,size:"md",title:a.label}),e.jsx(Z,{tone:a.badgeTone,children:a.label}),e.jsx("button",{onClick:d,disabled:p,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:p?"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:n,onBlur:l=>b(l.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(E,{label:"description",value:t.description??"",onChange:l=>o({...t,description:l||void 0}),placeholder:"what this server does…"}),h?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:n})," 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:n})," 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:l=>o({...t,type:l.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:he.map(l=>e.jsx("option",{value:l,children:l},l))}),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(E,{label:"command",value:t.command??"",onChange:l=>o({...t,command:l}),placeholder:"npx / node / python …"}),e.jsx(E,{label:"args",value:(t.args??[]).join(" "),onChange:l=>o({...t,args:l.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(U,{label:"env",value:t.env??{},onChange:l=>o({...t,env:l})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"url",value:t.url??"",onChange:l=>o({...t,url:l}),placeholder:"https://…"}),e.jsx(U,{label:"headers",value:t.headers??{},onChange:l=>o({...t,headers:l})})]}),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:l=>o({...t,alwaysLoad:l.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:l=>o({...t,enabled:l.target.checked?void 0:!1})}),e.jsx("span",{className:"text-fg-dim",children:"load this server in new sessions"})]})]}),e.jsx(E,{label:"disabledTools",value:f,onChange:l=>{const v=l.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:w,onChange:l=>{const v=l.target.value,m={...t};if(v==="inherit"){if(m.permissions){const{tools:I,...T}=m.permissions;m.permissions=Object.keys(T).length?T: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…"})]}),w==="list"?e.jsx("input",{value:_.join(", "),onChange:l=>{const v=l.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 E({label:n,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:n}),e.jsx("input",{value:t,onChange:p=>a(p.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 U({label:n,value:t,onChange:a}){const[d,p]=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:n}),e.jsxs("div",{className:"flex-1 space-y-1",children:[j.map(([r,h])=>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]=h,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:h,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=>p(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}),p(""),o(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}export{Le as McpServers,we as nextServerName};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aQ as I,aL as V,ay as l,aK as A,aj as e,l as F,X as oe,a7 as H,a0 as le,u as J,q as ee,ab as K,W as te}from"./index-Db_SK9rW.js";import{M as se}from"./MarkdownEditor-DmBxrhdn.js";import"./monaco-editor-BW5C4Iv1.js";function ie(t){return!t||!t.trim()?"default":t.replace(/[^a-zA-Z0-9]/g,"-")}const re=/^[a-z0-9-_]+$/;function ce(t,o,r,i){return t.filter(m=>!o||m.name.toLowerCase().includes(o.toLowerCase())).filter(m=>{var s;return!r||((s=i[m.name])==null?void 0:s.stale)===!0})}const de=["Commands:"," list — show all memory entries"," show <slug> — read one entry"," search <text> — find entries containing <text>"," forget <slug> — delete an entry (with confirm)"," remember <free-form> — ask Claude to save this"," help — this message","","Anything else: I will offer to send it to Claude in the terminal,","or add it as a new memory entry directly."].join(`
|
|
2
2
|
`);function me(t){const o=t.trim();if(!o)return{kind:"freeform",arg:"",raw:t};const r=o.toLowerCase();if(r==="help"||r==="?")return{kind:"help",arg:"",raw:t};if(r==="list"||r==="ls"||r==="list memories"||r==="list all"||r==="what do you remember"||r==="what do you remember?")return{kind:"list",arg:"",raw:t};const i=o.match(/^(?:show|read|open)\s+(.+)$/i);if(i)return{kind:"show",arg:i[1].trim(),raw:t};const m=o.match(/^(?:forget|delete|remove)\s+(.+)$/i);if(m)return{kind:"forget",arg:m[1].trim(),raw:t};const s=o.match(/^(?:search|find)\s+(.+)$/i)||o.match(/^what (?:do )?you know about\s+(.+?)\??$/i);if(s)return{kind:"search",arg:s[1].trim(),raw:t};const u=o.match(/^remember(?:\s+that)?\s+(.+)$/i)||o.match(/^note(?:\s+that)?\s+(.+)$/i)||o.match(/^save(?:\s+that)?\s+(.+)$/i);return u?{kind:"remember",arg:u[1].trim(),raw:t}:{kind:"freeform",arg:o,raw:t}}function G(t,o){const r=t.toLowerCase().replace(/\.md$/,""),i=o.find(u=>u.name.replace(/\.md$/,"").toLowerCase()===r);if(i)return i;const m=o.filter(u=>u.name.replace(/\.md$/,"").toLowerCase().startsWith(r));if(m.length===1)return m[0];const s=o.filter(u=>u.name.replace(/\.md$/,"").toLowerCase().includes(r));return s.length===1?s[0]:null}function Z(t){const o=new Set(["the","a","an","is","are","to","of","in","for","and","or"]);return t.toLowerCase().replace(/[^a-z0-9\s-]/g," ").split(/\s+/).filter(m=>m&&!o.has(m)).slice(0,4).join("-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`note-${Date.now().toString(36).slice(-4)}`}function Q(t,o){return[`Please save this to my workspace memory (workspace: ${t}).`,`Use the memory tool (or write a markdown file under ~/.claude/projects/${t}/memory/).`,"Pick a short kebab-case filename and add a one-line title at the top.","","Memory to save:",o].join(`
|
|
3
|
-
`)}function X(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function xe({workspace:t,entries:o,onChanged:r}){const i=
|
|
3
|
+
`)}function X(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function xe({workspace:t,entries:o,onChanged:r}){const i=I(),m=V(),s=(m==null?void 0:m.id)??null,[u,f]=l.useState(""),[c,b]=l.useState(()=>[{id:X(),role:"system",text:"Hi — I am the memory assistant for this workspace. Type `help` for what I understand, or just talk to me."}]),[C,g]=l.useState(!1),N=l.useRef(null),$=l.useRef(null);l.useEffect(()=>{const a=N.current;a&&(a.scrollTop=a.scrollHeight)},[c]);const x=l.useCallback(a=>{b(p=>[...p,{...a,id:X()}])},[]),S=l.useCallback(()=>{if(o.length===0){x({role:"result",text:"No memories saved for this workspace yet."});return}x({role:"result",text:`Found ${o.length} ${o.length===1?"memory":"memories"}:`,payload:{kind:"entries",entries:o}})},[o,x]),T=l.useCallback(async a=>{const p=G(a,o);if(!p){x({role:"result",text:`No memory matches "${a}". Try \`list\` to see what is here.`});return}const y=await window.api.memory.read(p.name,t);if(y.error){A.error(`Memory read failed: ${y.error}`),x({role:"result",text:`Read failed: ${y.error}`});return}x({role:"result",text:`${p.name}`,payload:{kind:"entry",entry:p,content:y.content}})},[o,t,x]),B=l.useCallback(async a=>{const p=a.toLowerCase(),y=o.filter(k=>k.name.toLowerCase().includes(p)),O=[];for(const k of o){if(y.includes(k))continue;const L=await window.api.memory.read(k.name,t);if(L.error)continue;const d=L.content.split(`
|
|
4
4
|
`),h=d.findIndex(w=>w.toLowerCase().includes(p));h>=0&&O.push({entry:k,snippet:d[h].trim().slice(0,200)})}const n=[...y.map(k=>({entry:k,snippet:"(filename match)"})),...O];if(n.length===0){x({role:"result",text:`No matches for "${a}".`});return}x({role:"result",text:`Found ${n.length} ${n.length===1?"match":"matches"} for "${a}":`,payload:{kind:"search",query:a,hits:n}})},[o,t,x]),D=l.useCallback(async a=>{const p=G(a,o);if(!p){x({role:"result",text:`No memory matches "${a}". Try \`list\` to see what is here.`});return}if(!window.confirm(`Delete memory "${p.name}"? This cannot be undone.`))return;const y=await window.api.memory.delete(p.name,t);if(!y.ok){A.error(`Memory delete failed: ${y.error??"unknown error"}`),x({role:"result",text:`Delete failed: ${y.error??"unknown error"}`});return}x({role:"result",text:`Deleted ${p.name}.`}),r()},[o,t,x,r]),v=l.useCallback(a=>{const p=Z(a),y=Q(t,a);x({role:"result",text:"I do not write to memory from this panel. Send the request to Claude in the active terminal, or add it directly as a new memory entry below.",payload:{kind:"suggest-send",prompt:y,original:a}}),x({role:"result",text:`Add it directly as \`${p}.md\` instead?`,payload:{kind:"suggest-add",slug:p,content:a}})},[t,x]),_=l.useCallback(a=>{const p=Z(a),y=Q(t,a);x({role:"result",text:"Not a recognised command. Options:",payload:{kind:"suggest-send",prompt:y,original:a}}),x({role:"result",text:`…or save it directly as \`${p}.md\`.`,payload:{kind:"suggest-add",slug:p,content:a}})},[t,x]),M=l.useCallback(async a=>{g(!0);try{switch(a.kind){case"list":S();break;case"show":await T(a.arg);break;case"search":await B(a.arg);break;case"forget":await D(a.arg);break;case"help":x({role:"result",text:de});break;case"remember":v(a.arg);break;case"freeform":_(a.arg);break}}finally{g(!1)}},[S,T,B,D,v,_,x]),R=l.useCallback(async()=>{const a=u.trim();!a||C||(f(""),x({role:"user",text:a}),await M(me(a)))},[u,C,M,x]),j=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),R())},E=l.useCallback(a=>{if(!s){A.error("No active terminal session — open or focus a tab first.");return}window.api.pty.write({tabId:s,data:a}),A.info("Prompt sent to active terminal (not submitted)")},[s]),P=l.useCallback(async(a,p)=>{if(!re.test(a)){A.error(`Invalid slug "${a}" — must be [a-z0-9-_]+`);return}const y=`${a}.md`,O=await window.api.memory.create(y,void 0,t);if(!O.ok){A.error(`Create failed: ${O.error??"unknown error"}`);return}const n=await window.api.memory.read(y,t),k=n.error?p:`${n.content.trimEnd()}
|
|
5
5
|
|
|
6
6
|
${p}
|
|
7
|
-
`,L=await window.api.memory.write(y,k,t);if(!L.ok){A.error(`Write failed: ${L.error??"unknown error"}`);return}x({role:"result",text:`Saved as ${y}.`}),r()},[t,x,r]),W=l.useMemo(()=>[{label:"List memories",value:"list"},{label:"Help",value:"help"},{label:"Search…",value:"search "},{label:"Remember…",value:"remember "}],[]);return i?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:N,className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-2",children:[c.map(a=>e.jsx(ue,{message:a,entries:o,onShow:p=>{var y;f(`show ${p.replace(/\.md$/,"")}`),(y=$.current)==null||y.focus()},onSendToClaude:E,onAddDirect:P},a.id)),C&&e.jsx("div",{className:"text-xs text-fg-faint italic",children:"working…"})]}),e.jsxs("div",{className:"shrink-0 border-t border-line px-3 py-2 space-y-2",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:W.map(a=>e.jsx("button",{onClick:()=>{var p;f(a.value),(p=$.current)==null||p.focus()},className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors",children:a.label},a.label))}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx(oe,{}),e.jsx("textarea",{ref:$,value:u,onChange:a=>f(a.target.value),onKeyDown:j,placeholder:"Type `list`, `show <slug>`, `search <text>`, `remember …`, or talk freely. Enter to send, Shift+Enter for newline.",rows:2,className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-xs text-fg resize-none focus:outline-none focus:border-fg-faint"}),e.jsx("button",{onClick:R,disabled:!u.trim()||C,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Send"})]}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Workspace: ",e.jsx("span",{className:"font-mono",children:t}),!s&&e.jsx("span",{className:"ml-2 text-amber-400",children:"(no active terminal — Send-to-Claude disabled)"})]})]})]}):e.jsx(F,{title:"loading…"})}function ue({message:t,entries:o,onShow:r,onSendToClaude:i,onAddDirect:m}){var u,f,c,b,C;const s=t.role==="user"?"bg-bg-hi text-fg ml-8":t.role==="system"?"bg-bg text-fg-dim italic":"bg-bg text-fg-dim";return e.jsxs("div",{className:`text-xs rounded border border-line px-3 py-2 ${s}`,children:[e.jsx("div",{className:"whitespace-pre-wrap font-mono text-[11px] leading-relaxed",children:t.text}),((u=t.payload)==null?void 0:u.kind)==="entries"&&e.jsx("div",{className:"mt-2 space-y-0.5",children:t.payload.entries.map(g=>e.jsxs("button",{onClick:()=>r(g.name),className:"block w-full text-left px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg hover:bg-bg-hi rounded font-mono",children:[g.name," ",e.jsxs("span",{className:"text-fg-faint",children:["(",H(g.bytes),")"]})]},g.name))}),((f=t.payload)==null?void 0:f.kind)==="entry"&&e.jsx("pre",{className:"mt-2 max-h-64 overflow-auto px-2 py-1 bg-bg-hi rounded text-[11px] whitespace-pre-wrap text-fg",children:t.payload.content}),((c=t.payload)==null?void 0:c.kind)==="search"&&e.jsx("div",{className:"mt-2 space-y-1",children:t.payload.hits.map((g,N)=>e.jsxs("button",{onClick:()=>r(g.entry.name),className:"block w-full text-left px-2 py-1 hover:bg-bg-hi rounded",children:[e.jsx("div",{className:"font-mono text-[11px] text-fg-dim",children:g.entry.name}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",children:g.snippet})]},`${g.entry.name}-${N}`))}),((b=t.payload)==null?void 0:b.kind)==="suggest-send"&&e.jsxs("div",{className:"mt-2 flex gap-2 items-center",children:[e.jsx("button",{onClick:()=>i(t.payload.kind==="suggest-send"?t.payload.prompt:""),className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Send to Claude in terminal"}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"paste-only — you press Enter"})]}),((C=t.payload)==null?void 0:C.kind)==="suggest-add"&&e.jsxs("div",{className:"mt-2 flex gap-2 items-center",children:[e.jsx("button",{onClick:()=>{var g;return((g=t.payload)==null?void 0:g.kind)==="suggest-add"&&m(t.payload.slug,t.payload.content)},className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Add as new memory"}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:[t.payload.slug,".md"]})]})]})}const z=le((t,o)=>({entriesByAgent:new Map,loading:null,errorByAgent:new Map,loadAgent:async r=>{t({loading:r});const i=await window.api.agentMemory.list(r),m=new Map(o().entriesByAgent);m.set(r,i.entries);const s=new Map(o().errorByAgent);i.error?(s.set(r,i.error),A.error(`Agent memory load failed: ${i.error}`)):s.delete(r),t({entriesByAgent:m,loading:null,errorByAgent:s})},setEntry:async(r,i,m,s)=>{const u=await window.api.agentMemory.set(r,i,m,s);return u.ok&&await o().loadAgent(r),u},deleteEntry:async(r,i)=>{const m=await window.api.agentMemory.delete(r,i);if(m.ok){const s=new Map(o().entriesByAgent),u=s.get(r)??[];s.set(r,u.filter(f=>f.id!==i)),t({entriesByAgent:s})}return m}})),U=/^[A-Za-z0-9._-]{1,128}$/,V={command:"Commands",preference:"Preferences",pattern:"Patterns",failure:"Avoid",workflow:"Workflow"},ne=["command","preference","pattern","failure","workflow"];async function fe(t,o){const r=[{dir:`${t}/.claude/agents`,scope:"user"}];o&&r.push({dir:`${o}/.claude/agents`,scope:"project"});const i=[];for(const{dir:s,scope:u}of r)try{const f=await window.api.config.listDir(s,{filesOnly:!0});for(const c of f.entries){if(!c.name.endsWith(".md"))continue;const b=c.name.replace(/\.md$/,"");U.test(b)&&i.push({id:b,label:b,scope:u})}}catch{}const m=new Map;for(const s of i)s.scope==="project"?m.set(s.id,s):m.has(s.id)||m.set(s.id,s);return Array.from(m.values()).sort((s,u)=>s.id.localeCompare(u.id))}function he(){const t=Y(),o=K(),r=(o==null?void 0:o.cwd)??null,[i,m]=l.useState([]),[s,u]=l.useState(null),[f,c]=l.useState(null),[b,C]=l.useState(""),[g,N]=l.useState(!1),[$,x]=l.useState(!1),[S,T]=l.useState({}),B=z(n=>n.entriesByAgent),D=z(n=>n.loadAgent),v=z(n=>n.setEntry),_=z(n=>n.deleteEntry);l.useEffect(()=>{if(!t)return;let n=!1;return fe(t,r).then(k=>{n||(m(k),u(L=>{var d;return L&&k.find(h=>h.id===L)?L:((d=k[0])==null?void 0:d.id)??null}))}),()=>{n=!0}},[t,r]),l.useEffect(()=>{s&&(c(null),D(s))},[s,D]);const M=s?B.get(s)??[]:[],R=l.useMemo(()=>M.filter(n=>!b||n.id.toLowerCase().includes(b.toLowerCase())||n.body.toLowerCase().includes(b.toLowerCase())),[M,b]),j=l.useMemo(()=>M.find(n=>n.id===f)??null,[M,f]);l.useEffect(()=>{var n;!f&&R.length>0?c(R[0].id):f&&!R.find(k=>k.id===f)&&c(((n=R[0])==null?void 0:n.id)??null)},[R,f]);const E=s&&f?`${s}::${f}`:null,P=E?S[E]??(j==null?void 0:j.body)??"":"",W=!!E&&j!==null&&P!==j.body,a=l.useCallback(async()=>{s&&await D(s)},[s,D]),p=async()=>{if(!s||!f||!E)return;N(!0);const n=await v(s,f,P,(j==null?void 0:j.category)??void 0);if(N(!1),!n.ok){A.error(`Save failed: ${n.error??"unknown"}`);return}T(k=>{const L={...k};return delete L[E],L})},y=async()=>{if(!s||!f||!window.confirm(`Delete memory "${f}"? This cannot be undone.`))return;N(!0);const n=await _(s,f);if(N(!1),!n.ok){A.error(`Delete failed: ${n.error??"unknown"}`);return}c(null)},O=async n=>{if(!s||!f||!j)return;N(!0);const k=await v(s,f,j.body,n??void 0);N(!1),k.ok||A.error(`Update failed: ${k.error??"unknown"}`)};return t?e.jsx(ee,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-faint",children:"Agent"}),e.jsxs("select",{value:s??"",onChange:n=>u(n.target.value||null),className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg max-w-[16rem]",children:[i.length===0&&e.jsx("option",{value:"",children:"(no agents found)"}),i.map(n=>e.jsxs("option",{value:n.id,children:[n.label," ",n.scope==="project"?"· project":""]},`${n.scope}:${n.id}`))]}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[M.length," ",M.length===1?"entry":"entries"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>x(!0),disabled:!s,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40",children:"+ New entry"}),e.jsx("button",{onClick:a,disabled:!s,className:"ml-2 px-2 py-0.5 text-xs text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40",children:"Refresh"})]}),footer:j?e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsx("button",{onClick:p,disabled:!W||g,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:g?"Saving…":"Save"}),e.jsx("button",{onClick:y,disabled:g,className:"px-2 py-0.5 text-xs text-red-400 hover:text-red-300 border border-line hover:border-red-400/50 rounded transition-colors disabled:opacity-40",children:"Delete"}),e.jsx("span",{className:"text-fg-faint",children:"Category:"}),e.jsxs("select",{value:j.category??"",onChange:n=>O(n.target.value||null),disabled:g,className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim disabled:opacity-40",children:[e.jsx("option",{value:"",children:"(none)"}),ne.map(n=>e.jsx("option",{value:n,children:V[n]},n))]}),e.jsx("span",{className:"text-fg-faint truncate flex-1",children:j.id}),W&&e.jsx("span",{className:"text-accent",children:"unsaved"})]}):null,children:e.jsx(te,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:b,onChange:n=>C(n.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),s?R.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:M.length===0?"no entries yet":"no matches"}):R.map(n=>e.jsxs("button",{onClick:()=>c(n.id),className:`w-full text-left px-3 py-1 text-xs flex items-center justify-between ${f===n.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,title:n.id,children:[e.jsx("span",{className:"truncate",children:n.id}),e.jsxs("span",{className:"ml-2 text-fg-faint shrink-0 text-[10px]",children:[H(n.bytes)," · ",I(n.updatedAt)]})]},n.id)):e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:"select an agent first"})]}),detail:$&&s?e.jsx(pe,{agentId:s,existingIds:new Set(M.map(n=>n.id)),onCancel:()=>x(!1),onCreated:n=>{x(!1),c(n),D(s)}}):j&&s&&f&&E?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-3 py-2 border-b border-line text-xs",children:[e.jsx("div",{className:"text-fg truncate",children:j.id}),e.jsxs("div",{className:"text-fg-faint truncate",children:[H(j.bytes)," · modified ",I(j.updatedAt),j.category?` · ${V[j.category]}`:""]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(se,{path:`agent-memory/${s}/${j.id}.md`,value:P,onChange:n=>T(k=>({...k,[E]:n}))})})]}):e.jsx(F,{title:s?M.length===0?"no entries yet":"select an entry":"no agent selected",hint:s&&M.length===0?"Use “+ New entry” to give this subagent its first memory.":void 0})})}):e.jsx(F,{title:"loading…"})}function pe({agentId:t,existingIds:o,onCancel:r,onCreated:i}){const m=z(v=>v.setEntry),[s,u]=l.useState(""),[f,c]=l.useState(""),[b,C]=l.useState(""),[g,N]=l.useState(!1),[$,x]=l.useState(null),S=s.trim(),T=U.test(S)&&!o.has(S),B=s?U.test(S)?o.has(S)?"an entry with this id already exists":null:"must match [A-Za-z0-9._-]+":null,D=async()=>{if(!T)return;N(!0),x(null);const v=await m(t,S,f,b||void 0);if(N(!1),!v.ok){x(v.error??"create failed");return}i(S)};return e.jsxs("div",{className:"p-4 max-w-xl space-y-3",children:[e.jsxs("div",{className:"text-sm text-fg",children:["New memory entry for ",e.jsx("span",{className:"font-mono text-fg-dim",children:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Entry id"}),e.jsx("input",{autoFocus:!0,value:s,onChange:v=>u(v.target.value),placeholder:"e.g. preferred-test-runner",className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),B&&e.jsx("div",{className:"text-[10px] text-red-400",children:B}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Letters, digits, dots, dashes, underscores. Persists at",e.jsxs("code",{className:"ml-1 font-mono text-fg-dim",children:["~/.claude/session-manager/agent-memory/",t,".json"]}),"."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Category (optional)"}),e.jsxs("select",{value:b,onChange:v=>C(v.target.value),className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"",children:"(none)"}),ne.map(v=>e.jsx("option",{value:v,children:V[v]},v))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Body (markdown)"}),e.jsx("textarea",{value:f,onChange:v=>c(v.target.value),rows:6,placeholder:"What should this subagent remember?",className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]}),$&&e.jsx("div",{className:"text-xs text-red-400",children:$}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:D,disabled:!T||g,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40",children:g?"Creating…":"Create"}),e.jsx("button",{onClick:r,disabled:g,className:"px-3 py-1 text-xs text-fg-faint hover:text-fg-dim rounded transition-colors",children:"Cancel"})]})]})}function ge({workspace:t,onOpenMember:o}){const[r,i]=l.useState(null),[m,s]=l.useState(!1),[u,f]=l.useState(!1),c=l.useRef(0),b=l.useCallback(async $=>{const x=++c.current;s(!0);try{const S=await window.api.memory.aggregate(t,$);if(c.current!==x)return;i(S)}catch(S){if(c.current!==x)return;A.error(`Memory aggregate failed: ${S instanceof Error?S.message:String(S)}`)}finally{c.current===x&&(s(!1),f(!0))}},[t]);l.useEffect(()=>{i(null),f(!1),b(!1)},[b]);const C=(r==null?void 0:r.clusters)??[],g=(r==null?void 0:r.orphans)??[],N=C.length>0||g.length>0;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-2 border-b border-line text-xs",children:[e.jsx("span",{className:"text-fg-faint",children:r!=null&&r.generatedAt?`generated ${I(r.generatedAt)} ago`:"not yet aggregated"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>b(!0),disabled:m,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:m?"Aggregating…":r!=null&&r.generatedAt?"Refresh":"Aggregate"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:u?N?e.jsxs("div",{className:"space-y-4",children:[C.length>0&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:C.map($=>e.jsx(be,{cluster:$,onOpenMember:o},$.id))}),g.length>0&&e.jsxs("div",{className:"border border-line rounded p-3",children:[e.jsx("div",{className:"text-xs text-fg mb-2",children:"Unclustered"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:g.map($=>e.jsx("button",{onClick:()=>o($),className:"px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:$},$))})]})]}):e.jsx(F,{title:"no clusters yet",hint:"Click Aggregate to organize this workspace's memories into named clusters."}):e.jsx(F,{title:"loading…"})})]})}function be({cluster:t,onOpenMember:o}){return e.jsxs("div",{className:"border border-line rounded p-3",children:[e.jsx("div",{className:"text-sm text-fg",children:t.name}),t.summary&&e.jsx("div",{className:"text-xs text-fg-faint mt-0.5",children:t.summary}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.memberSlugs.map(r=>e.jsx("button",{onClick:()=>o(r),className:"px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:r},r))}),t.links.length>0&&e.jsx("div",{className:"mt-2 space-y-0.5",children:t.links.map((r,i)=>e.jsxs("div",{className:"text-[10px] text-fg-faint font-mono",children:[r.from," → ",r.to,r.label?` (${r.label})`:""]},`${r.from}-${r.to}-${i}`))})]})}const ye=[{key:"workspace",label:"Workspace"},{key:"subagent",label:"Subagent"}],J="sm.memoryTab.scope";function je(){const[t,o]=l.useState(()=>localStorage.getItem(J)==="subagent"?"subagent":"workspace");return l.useEffect(()=>{localStorage.setItem(J,t)},[t]),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[e.jsx(q,{options:ye,active:t,onChange:o}),e.jsx("span",{className:"text-[11px] text-fg-faint",children:t==="workspace"?"memories scoped to the active project":"long-term memory per subagent"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:t==="workspace"?e.jsx(ve,{}):e.jsx(he,{})})]})}const Ee=l.memo(je);function ve(){const t=Y(),o=K(),r=(o==null?void 0:o.cwd)??null,i=l.useMemo(()=>ie(r),[r]),[m,s]=l.useState("classic"),[u,f]=l.useState([]),[c,b]=l.useState(null),[C,g]=l.useState(""),[N,$]=l.useState({}),[x,S]=l.useState(!1),[T,B]=l.useState({}),[D,v]=l.useState({}),[_,M]=l.useState(!1),[R,j]=l.useState(!1),E=l.useCallback(async()=>{if(!t)return;const d=await window.api.memory.list(i);f(d.entries),d.error&&A.error(`Memory list failed: ${d.error}`),b(h=>{var w;return h&&d.entries.some(ae=>ae.name===h)?h:((w=d.entries[0])==null?void 0:w.name)??null});try{const h=await window.api.memory.stale(i,r??void 0);$(Object.fromEntries(h.entries.map(w=>[w.name,w])))}catch(h){$({}),A.error(`Memory staleness check failed: ${h instanceof Error?h.message:String(h)}`)}},[t,i,r]);if(l.useEffect(()=>{B({}),v({}),b(null),E()},[i,E]),l.useEffect(()=>{if(!t)return;const d=`${t}/.claude/projects/${i}/memory`;window.api.config.watch([d]);const h=window.api.config.onChanged(({path:w})=>{(w===d||w.startsWith(d+"/"))&&E()});return()=>{h(),window.api.config.unwatch([d])}},[t,i,E]),l.useEffect(()=>{if(!c||T[c]!==void 0)return;let d=!1;return(async()=>{const h=await window.api.memory.read(c,i);if(!d){if(h.error){A.error(`Memory read failed: ${h.error}`);return}B(w=>({...w,[c]:h.content})),v(w=>({...w,[c]:h.content}))}})(),()=>{d=!0}},[c,i]),!t)return e.jsx(F,{title:"loading…"});const P=u.reduce((d,h)=>{var w;return d+((w=N[h.name])!=null&&w.stale?1:0)},0),W=ce(u,C,x,N),a=u.find(d=>d.name===c)??null,p=c?N[c]:void 0,y=c?T[c]??"":"",O=c?D[c]??"":"",n=c?y!==O:!1,k=async()=>{if(!c)return;M(!0);const d=await window.api.memory.write(c,y,i);if(M(!1),!d.ok){A.error(`Memory save failed: ${d.error??"unknown error"}`);return}v(h=>({...h,[c]:y})),E()},L=async()=>{if(!c||!window.confirm(`Delete memory "${c}"? This cannot be undone.`))return;M(!0);const d=await window.api.memory.delete(c,i);if(M(!1),!d.ok){A.error(`Memory delete failed: ${d.error??"unknown error"}`);return}B(h=>{const w={...h};return delete w[c],w}),v(h=>{const w={...h};return delete w[c],w}),b(null),E()};return e.jsx(ee,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(q,{options:[{key:"classic",label:"Editor"},{key:"natural",label:"Natural"},{key:"clusters",label:"Clusters"}],active:m,onChange:s}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-faint",children:"Workspace"}),e.jsx("span",{className:"font-mono text-fg-dim truncate max-w-[24rem]",title:i,children:i}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[u.length," ",u.length===1?"entry":"entries"]}),e.jsx("div",{className:"flex-1"}),m==="classic"&&P>0&&e.jsxs("button",{onClick:()=>S(d=>!d),className:`px-2 py-0.5 text-xs border rounded transition-colors ${x?"text-amber-400 border-amber-400/50 bg-amber-400/10":"text-fg-dim hover:text-fg border-line hover:border-fg-faint"}`,children:["Stale only (",P,")"]}),m==="classic"&&e.jsx("button",{onClick:()=>j(!0),className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"+ New memory"}),m!=="clusters"&&e.jsx("button",{onClick:E,className:"ml-2 px-2 py-0.5 text-xs text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors",children:"Refresh"})]}),footer:m==="classic"&&a?e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsx("button",{onClick:k,disabled:!n||_,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:_?"Saving…":"Save"}),e.jsx("button",{onClick:L,disabled:_,className:"px-2 py-0.5 text-xs text-red-400 hover:text-red-300 border border-line hover:border-red-400/50 rounded transition-colors disabled:opacity-40",children:"Delete"}),(p==null?void 0:p.stale)&&e.jsxs("span",{className:"text-amber-400/90 truncate",title:p.reasons.join("; "),children:["stale · ",p.reasons.join(", ")]}),e.jsx("span",{className:"text-fg-faint truncate flex-1",children:a.path}),n&&e.jsx("span",{className:"text-accent",children:"unsaved"})]}):null,children:m==="natural"?e.jsx(xe,{workspace:i,entries:u,onChanged:E}):m==="clusters"?e.jsx(ge,{workspace:i,onOpenMember:d=>{b(`${d}.md`),s("classic")}}):e.jsx(te,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:C,onChange:d=>g(d.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),W.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:u.length===0?"no memories yet":"no matches"}):W.map(d=>{const h=N[d.name],w=h!=null&&h.stale?`${d.path}
|
|
8
|
-
stale: ${h.reasons.join(", ")}`:d.path;return e.jsxs("button",{onClick:()=>b(d.name),className:`w-full text-left px-3 py-1 text-xs flex items-center justify-between ${c===d.name?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,title:w,children:[e.jsxs("span",{className:"truncate flex items-center",children:[e.jsx("span",{className:"truncate",children:d.name.replace(/\.md$/,"")}),(h==null?void 0:h.stale)&&e.jsx("span",{className:"ml-1.5 shrink-0 px-1 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30",children:"stale"})]}),e.jsxs("span",{className:"ml-2 text-fg-faint shrink-0 text-[10px]",children:[H(d.bytes)," · ",
|
|
7
|
+
`,L=await window.api.memory.write(y,k,t);if(!L.ok){A.error(`Write failed: ${L.error??"unknown error"}`);return}x({role:"result",text:`Saved as ${y}.`}),r()},[t,x,r]),W=l.useMemo(()=>[{label:"List memories",value:"list"},{label:"Help",value:"help"},{label:"Search…",value:"search "},{label:"Remember…",value:"remember "}],[]);return i?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:N,className:"flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-2",children:[c.map(a=>e.jsx(ue,{message:a,entries:o,onShow:p=>{var y;f(`show ${p.replace(/\.md$/,"")}`),(y=$.current)==null||y.focus()},onSendToClaude:E,onAddDirect:P},a.id)),C&&e.jsx("div",{className:"text-xs text-fg-faint italic",children:"working…"})]}),e.jsxs("div",{className:"shrink-0 border-t border-line px-3 py-2 space-y-2",children:[e.jsx("div",{className:"flex gap-1 flex-wrap",children:W.map(a=>e.jsx("button",{onClick:()=>{var p;f(a.value),(p=$.current)==null||p.focus()},className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors",children:a.label},a.label))}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx(oe,{}),e.jsx("textarea",{ref:$,value:u,onChange:a=>f(a.target.value),onKeyDown:j,placeholder:"Type `list`, `show <slug>`, `search <text>`, `remember …`, or talk freely. Enter to send, Shift+Enter for newline.",rows:2,className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-xs text-fg resize-none focus:outline-none focus:border-fg-faint"}),e.jsx("button",{onClick:R,disabled:!u.trim()||C,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Send"})]}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Workspace: ",e.jsx("span",{className:"font-mono",children:t}),!s&&e.jsx("span",{className:"ml-2 text-amber-400",children:"(no active terminal — Send-to-Claude disabled)"})]})]})]}):e.jsx(F,{title:"loading…"})}function ue({message:t,entries:o,onShow:r,onSendToClaude:i,onAddDirect:m}){var u,f,c,b,C;const s=t.role==="user"?"bg-bg-hi text-fg ml-8":t.role==="system"?"bg-bg text-fg-dim italic":"bg-bg text-fg-dim";return e.jsxs("div",{className:`text-xs rounded border border-line px-3 py-2 ${s}`,children:[e.jsx("div",{className:"whitespace-pre-wrap font-mono text-[11px] leading-relaxed",children:t.text}),((u=t.payload)==null?void 0:u.kind)==="entries"&&e.jsx("div",{className:"mt-2 space-y-0.5",children:t.payload.entries.map(g=>e.jsxs("button",{onClick:()=>r(g.name),className:"block w-full text-left px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg hover:bg-bg-hi rounded font-mono",children:[g.name," ",e.jsxs("span",{className:"text-fg-faint",children:["(",H(g.bytes),")"]})]},g.name))}),((f=t.payload)==null?void 0:f.kind)==="entry"&&e.jsx("pre",{className:"mt-2 max-h-64 overflow-auto px-2 py-1 bg-bg-hi rounded text-[11px] whitespace-pre-wrap text-fg",children:t.payload.content}),((c=t.payload)==null?void 0:c.kind)==="search"&&e.jsx("div",{className:"mt-2 space-y-1",children:t.payload.hits.map((g,N)=>e.jsxs("button",{onClick:()=>r(g.entry.name),className:"block w-full text-left px-2 py-1 hover:bg-bg-hi rounded",children:[e.jsx("div",{className:"font-mono text-[11px] text-fg-dim",children:g.entry.name}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",children:g.snippet})]},`${g.entry.name}-${N}`))}),((b=t.payload)==null?void 0:b.kind)==="suggest-send"&&e.jsxs("div",{className:"mt-2 flex gap-2 items-center",children:[e.jsx("button",{onClick:()=>i(t.payload.kind==="suggest-send"?t.payload.prompt:""),className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Send to Claude in terminal"}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"paste-only — you press Enter"})]}),((C=t.payload)==null?void 0:C.kind)==="suggest-add"&&e.jsxs("div",{className:"mt-2 flex gap-2 items-center",children:[e.jsx("button",{onClick:()=>{var g;return((g=t.payload)==null?void 0:g.kind)==="suggest-add"&&m(t.payload.slug,t.payload.content)},className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Add as new memory"}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:[t.payload.slug,".md"]})]})]})}const z=le((t,o)=>({entriesByAgent:new Map,loading:null,errorByAgent:new Map,loadAgent:async r=>{t({loading:r});const i=await window.api.agentMemory.list(r),m=new Map(o().entriesByAgent);m.set(r,i.entries);const s=new Map(o().errorByAgent);i.error?(s.set(r,i.error),A.error(`Agent memory load failed: ${i.error}`)):s.delete(r),t({entriesByAgent:m,loading:null,errorByAgent:s})},setEntry:async(r,i,m,s)=>{const u=await window.api.agentMemory.set(r,i,m,s);return u.ok&&await o().loadAgent(r),u},deleteEntry:async(r,i)=>{const m=await window.api.agentMemory.delete(r,i);if(m.ok){const s=new Map(o().entriesByAgent),u=s.get(r)??[];s.set(r,u.filter(f=>f.id!==i)),t({entriesByAgent:s})}return m}})),U=/^[A-Za-z0-9._-]{1,128}$/,Y={command:"Commands",preference:"Preferences",pattern:"Patterns",failure:"Avoid",workflow:"Workflow"},ne=["command","preference","pattern","failure","workflow"];async function fe(t,o){const r=[{dir:`${t}/.claude/agents`,scope:"user"}];o&&r.push({dir:`${o}/.claude/agents`,scope:"project"});const i=[];for(const{dir:s,scope:u}of r)try{const f=await window.api.config.listDir(s,{filesOnly:!0});for(const c of f.entries){if(!c.name.endsWith(".md"))continue;const b=c.name.replace(/\.md$/,"");U.test(b)&&i.push({id:b,label:b,scope:u})}}catch{}const m=new Map;for(const s of i)s.scope==="project"?m.set(s.id,s):m.has(s.id)||m.set(s.id,s);return Array.from(m.values()).sort((s,u)=>s.id.localeCompare(u.id))}function he(){const t=I(),o=V(),r=(o==null?void 0:o.cwd)??null,[i,m]=l.useState([]),[s,u]=l.useState(null),[f,c]=l.useState(null),[b,C]=l.useState(""),[g,N]=l.useState(!1),[$,x]=l.useState(!1),[S,T]=l.useState({}),B=z(n=>n.entriesByAgent),D=z(n=>n.loadAgent),v=z(n=>n.setEntry),_=z(n=>n.deleteEntry);l.useEffect(()=>{if(!t)return;let n=!1;return fe(t,r).then(k=>{n||(m(k),u(L=>{var d;return L&&k.find(h=>h.id===L)?L:((d=k[0])==null?void 0:d.id)??null}))}),()=>{n=!0}},[t,r]),l.useEffect(()=>{s&&(c(null),D(s))},[s,D]);const M=s?B.get(s)??[]:[],R=l.useMemo(()=>M.filter(n=>!b||n.id.toLowerCase().includes(b.toLowerCase())||n.body.toLowerCase().includes(b.toLowerCase())),[M,b]),j=l.useMemo(()=>M.find(n=>n.id===f)??null,[M,f]);l.useEffect(()=>{var n;!f&&R.length>0?c(R[0].id):f&&!R.find(k=>k.id===f)&&c(((n=R[0])==null?void 0:n.id)??null)},[R,f]);const E=s&&f?`${s}::${f}`:null,P=E?S[E]??(j==null?void 0:j.body)??"":"",W=!!E&&j!==null&&P!==j.body,a=l.useCallback(async()=>{s&&await D(s)},[s,D]),p=async()=>{if(!s||!f||!E)return;N(!0);const n=await v(s,f,P,(j==null?void 0:j.category)??void 0);if(N(!1),!n.ok){A.error(`Save failed: ${n.error??"unknown"}`);return}T(k=>{const L={...k};return delete L[E],L})},y=async()=>{if(!s||!f||!window.confirm(`Delete memory "${f}"? This cannot be undone.`))return;N(!0);const n=await _(s,f);if(N(!1),!n.ok){A.error(`Delete failed: ${n.error??"unknown"}`);return}c(null)},O=async n=>{if(!s||!f||!j)return;N(!0);const k=await v(s,f,j.body,n??void 0);N(!1),k.ok||A.error(`Update failed: ${k.error??"unknown"}`)};return t?e.jsx(J,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-faint",children:"Agent"}),e.jsxs("select",{value:s??"",onChange:n=>u(n.target.value||null),className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg max-w-[16rem]",children:[i.length===0&&e.jsx("option",{value:"",children:"(no agents found)"}),i.map(n=>e.jsxs("option",{value:n.id,children:[n.label," ",n.scope==="project"?"· project":""]},`${n.scope}:${n.id}`))]}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[M.length," ",M.length===1?"entry":"entries"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>x(!0),disabled:!s,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40",children:"+ New entry"}),e.jsx("button",{onClick:a,disabled:!s,className:"ml-2 px-2 py-0.5 text-xs text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40",children:"Refresh"})]}),footer:j?e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsx("button",{onClick:p,disabled:!W||g,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:g?"Saving…":"Save"}),e.jsx("button",{onClick:y,disabled:g,className:"px-2 py-0.5 text-xs text-red-400 hover:text-red-300 border border-line hover:border-red-400/50 rounded transition-colors disabled:opacity-40",children:"Delete"}),e.jsx("span",{className:"text-fg-faint",children:"Category:"}),e.jsxs("select",{value:j.category??"",onChange:n=>O(n.target.value||null),disabled:g,className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim disabled:opacity-40",children:[e.jsx("option",{value:"",children:"(none)"}),ne.map(n=>e.jsx("option",{value:n,children:Y[n]},n))]}),e.jsx("span",{className:"text-fg-faint truncate flex-1",children:j.id}),W&&e.jsx("span",{className:"text-accent",children:"unsaved"})]}):null,children:e.jsx(ee,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:b,onChange:n=>C(n.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),s?R.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:M.length===0?"no entries yet":"no matches"}):R.map(n=>e.jsxs("button",{onClick:()=>c(n.id),className:`w-full text-left px-3 py-1 text-xs flex items-center justify-between ${f===n.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,title:n.id,children:[e.jsx("span",{className:"truncate",children:n.id}),e.jsxs("span",{className:"ml-2 text-fg-faint shrink-0 text-[10px]",children:[H(n.bytes)," · ",K(n.updatedAt)]})]},n.id)):e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:"select an agent first"})]}),detail:$&&s?e.jsx(pe,{agentId:s,existingIds:new Set(M.map(n=>n.id)),onCancel:()=>x(!1),onCreated:n=>{x(!1),c(n),D(s)}}):j&&s&&f&&E?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-3 py-2 border-b border-line text-xs",children:[e.jsx("div",{className:"text-fg truncate",children:j.id}),e.jsxs("div",{className:"text-fg-faint truncate",children:[H(j.bytes)," · modified ",K(j.updatedAt),j.category?` · ${Y[j.category]}`:""]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(se,{path:`agent-memory/${s}/${j.id}.md`,value:P,onChange:n=>T(k=>({...k,[E]:n}))})})]}):e.jsx(F,{title:s?M.length===0?"no entries yet":"select an entry":"no agent selected",hint:s&&M.length===0?"Use “+ New entry” to give this subagent its first memory.":void 0})})}):e.jsx(F,{title:"loading…"})}function pe({agentId:t,existingIds:o,onCancel:r,onCreated:i}){const m=z(v=>v.setEntry),[s,u]=l.useState(""),[f,c]=l.useState(""),[b,C]=l.useState(""),[g,N]=l.useState(!1),[$,x]=l.useState(null),S=s.trim(),T=U.test(S)&&!o.has(S),B=s?U.test(S)?o.has(S)?"an entry with this id already exists":null:"must match [A-Za-z0-9._-]+":null,D=async()=>{if(!T)return;N(!0),x(null);const v=await m(t,S,f,b||void 0);if(N(!1),!v.ok){x(v.error??"create failed");return}i(S)};return e.jsxs("div",{className:"p-4 max-w-xl space-y-3",children:[e.jsxs("div",{className:"text-sm text-fg",children:["New memory entry for ",e.jsx("span",{className:"font-mono text-fg-dim",children:t})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Entry id"}),e.jsx("input",{autoFocus:!0,value:s,onChange:v=>u(v.target.value),placeholder:"e.g. preferred-test-runner",className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),B&&e.jsx("div",{className:"text-[10px] text-red-400",children:B}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Letters, digits, dots, dashes, underscores. Persists at",e.jsxs("code",{className:"ml-1 font-mono text-fg-dim",children:["~/.claude/session-manager/agent-memory/",t,".json"]}),"."]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Category (optional)"}),e.jsxs("select",{value:b,onChange:v=>C(v.target.value),className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"",children:"(none)"}),ne.map(v=>e.jsx("option",{value:v,children:Y[v]},v))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Body (markdown)"}),e.jsx("textarea",{value:f,onChange:v=>c(v.target.value),rows:6,placeholder:"What should this subagent remember?",className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]}),$&&e.jsx("div",{className:"text-xs text-red-400",children:$}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:D,disabled:!T||g,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40",children:g?"Creating…":"Create"}),e.jsx("button",{onClick:r,disabled:g,className:"px-3 py-1 text-xs text-fg-faint hover:text-fg-dim rounded transition-colors",children:"Cancel"})]})]})}function ge({workspace:t,onOpenMember:o}){const[r,i]=l.useState(null),[m,s]=l.useState(!1),[u,f]=l.useState(!1),c=l.useRef(0),b=l.useCallback(async $=>{const x=++c.current;s(!0);try{const S=await window.api.memory.aggregate(t,$);if(c.current!==x)return;i(S)}catch(S){if(c.current!==x)return;A.error(`Memory aggregate failed: ${S instanceof Error?S.message:String(S)}`)}finally{c.current===x&&(s(!1),f(!0))}},[t]);l.useEffect(()=>{i(null),f(!1),b(!1)},[b]);const C=(r==null?void 0:r.clusters)??[],g=(r==null?void 0:r.orphans)??[],N=C.length>0||g.length>0;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-3 py-2 border-b border-line text-xs",children:[e.jsx("span",{className:"text-fg-faint",children:r!=null&&r.generatedAt?`generated ${K(r.generatedAt)} ago`:"not yet aggregated"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>b(!0),disabled:m,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:m?"Aggregating…":r!=null&&r.generatedAt?"Refresh":"Aggregate"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:u?N?e.jsxs("div",{className:"space-y-4",children:[C.length>0&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:C.map($=>e.jsx(be,{cluster:$,onOpenMember:o},$.id))}),g.length>0&&e.jsxs("div",{className:"border border-line rounded p-3",children:[e.jsx("div",{className:"text-xs text-fg mb-2",children:"Unclustered"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:g.map($=>e.jsx("button",{onClick:()=>o($),className:"px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:$},$))})]})]}):e.jsx(F,{title:"no clusters yet",hint:"Click Aggregate to organize this workspace's memories into named clusters."}):e.jsx(F,{title:"loading…"})})]})}function be({cluster:t,onOpenMember:o}){return e.jsxs("div",{className:"border border-line rounded p-3",children:[e.jsx("div",{className:"text-sm text-fg",children:t.name}),t.summary&&e.jsx("div",{className:"text-xs text-fg-faint mt-0.5",children:t.summary}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.memberSlugs.map(r=>e.jsx("button",{onClick:()=>o(r),className:"px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:r},r))}),t.links.length>0&&e.jsx("div",{className:"mt-2 space-y-0.5",children:t.links.map((r,i)=>e.jsxs("div",{className:"text-[10px] text-fg-faint font-mono",children:[r.from," → ",r.to,r.label?` (${r.label})`:""]},`${r.from}-${r.to}-${i}`))})]})}const ye=[{key:"workspace",label:"Workspace"},{key:"subagent",label:"Subagent"}],q="sm.memoryTab.scope";function je(){const[t,o]=l.useState(()=>localStorage.getItem(q)==="subagent"?"subagent":"workspace");return l.useEffect(()=>{localStorage.setItem(q,t)},[t]),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[e.jsx(te,{options:ye,active:t,onChange:o}),e.jsx("span",{className:"text-[11px] text-fg-faint",children:t==="workspace"?"memories scoped to the active project":"long-term memory per subagent"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:t==="workspace"?e.jsx(ve,{}):e.jsx(he,{})})]})}const $e=l.memo(je);function ve(){const t=I(),o=V(),r=(o==null?void 0:o.cwd)??null,i=l.useMemo(()=>ie(r),[r]),[m,s]=l.useState("classic"),[u,f]=l.useState([]),[c,b]=l.useState(null),[C,g]=l.useState(""),[N,$]=l.useState({}),[x,S]=l.useState(!1),[T,B]=l.useState({}),[D,v]=l.useState({}),[_,M]=l.useState(!1),[R,j]=l.useState(!1),E=l.useCallback(async()=>{if(!t)return;const d=await window.api.memory.list(i);f(d.entries),d.error&&A.error(`Memory list failed: ${d.error}`),b(h=>{var w;return h&&d.entries.some(ae=>ae.name===h)?h:((w=d.entries[0])==null?void 0:w.name)??null});try{const h=await window.api.memory.stale(i,r??void 0);$(Object.fromEntries(h.entries.map(w=>[w.name,w])))}catch(h){$({}),A.error(`Memory staleness check failed: ${h instanceof Error?h.message:String(h)}`)}},[t,i,r]);if(l.useEffect(()=>{B({}),v({}),b(null),E()},[i,E]),l.useEffect(()=>{if(!t)return;const d=`${t}/.claude/projects/${i}/memory`;window.api.config.watch([d]);const h=window.api.config.onChanged(({path:w})=>{(w===d||w.startsWith(d+"/"))&&E()});return()=>{h(),window.api.config.unwatch([d])}},[t,i,E]),l.useEffect(()=>{if(!c||T[c]!==void 0)return;let d=!1;return(async()=>{const h=await window.api.memory.read(c,i);if(!d){if(h.error){A.error(`Memory read failed: ${h.error}`);return}B(w=>({...w,[c]:h.content})),v(w=>({...w,[c]:h.content}))}})(),()=>{d=!0}},[c,i]),!t)return e.jsx(F,{title:"loading…"});const P=u.reduce((d,h)=>{var w;return d+((w=N[h.name])!=null&&w.stale?1:0)},0),W=ce(u,C,x,N),a=u.find(d=>d.name===c)??null,p=c?N[c]:void 0,y=c?T[c]??"":"",O=c?D[c]??"":"",n=c?y!==O:!1,k=async()=>{if(!c)return;M(!0);const d=await window.api.memory.write(c,y,i);if(M(!1),!d.ok){A.error(`Memory save failed: ${d.error??"unknown error"}`);return}v(h=>({...h,[c]:y})),E()},L=async()=>{if(!c||!window.confirm(`Delete memory "${c}"? This cannot be undone.`))return;M(!0);const d=await window.api.memory.delete(c,i);if(M(!1),!d.ok){A.error(`Memory delete failed: ${d.error??"unknown error"}`);return}B(h=>{const w={...h};return delete w[c],w}),v(h=>{const w={...h};return delete w[c],w}),b(null),E()};return e.jsx(J,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(te,{options:[{key:"classic",label:"Editor"},{key:"natural",label:"Natural"},{key:"clusters",label:"Clusters"}],active:m,onChange:s}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-faint",children:"Workspace"}),e.jsx("span",{className:"font-mono text-fg-dim truncate max-w-[24rem]",title:i,children:i}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[u.length," ",u.length===1?"entry":"entries"]}),e.jsx("div",{className:"flex-1"}),m==="classic"&&P>0&&e.jsxs("button",{onClick:()=>S(d=>!d),className:`px-2 py-0.5 text-xs border rounded transition-colors ${x?"text-amber-400 border-amber-400/50 bg-amber-400/10":"text-fg-dim hover:text-fg border-line hover:border-fg-faint"}`,children:["Stale only (",P,")"]}),m==="classic"&&e.jsx("button",{onClick:()=>j(!0),className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"+ New memory"}),m!=="clusters"&&e.jsx("button",{onClick:E,className:"ml-2 px-2 py-0.5 text-xs text-fg-faint hover:text-fg-dim border border-line hover:border-fg-faint rounded transition-colors",children:"Refresh"})]}),footer:m==="classic"&&a?e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsx("button",{onClick:k,disabled:!n||_,className:"px-2 py-0.5 text-xs text-fg-dim hover:text-fg border border-line hover:border-fg-faint rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:_?"Saving…":"Save"}),e.jsx("button",{onClick:L,disabled:_,className:"px-2 py-0.5 text-xs text-red-400 hover:text-red-300 border border-line hover:border-red-400/50 rounded transition-colors disabled:opacity-40",children:"Delete"}),(p==null?void 0:p.stale)&&e.jsxs("span",{className:"text-amber-400/90 truncate",title:p.reasons.join("; "),children:["stale · ",p.reasons.join(", ")]}),e.jsx("span",{className:"text-fg-faint truncate flex-1",children:a.path}),n&&e.jsx("span",{className:"text-accent",children:"unsaved"})]}):null,children:m==="natural"?e.jsx(xe,{workspace:i,entries:u,onChanged:E}):m==="clusters"?e.jsx(ge,{workspace:i,onOpenMember:d=>{b(`${d}.md`),s("classic")}}):e.jsx(ee,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:C,onChange:d=>g(d.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),W.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:u.length===0?"no memories yet":"no matches"}):W.map(d=>{const h=N[d.name],w=h!=null&&h.stale?`${d.path}
|
|
8
|
+
stale: ${h.reasons.join(", ")}`:d.path;return e.jsxs("button",{onClick:()=>b(d.name),className:`w-full text-left px-3 py-1 text-xs flex items-center justify-between ${c===d.name?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,title:w,children:[e.jsxs("span",{className:"truncate flex items-center",children:[e.jsx("span",{className:"truncate",children:d.name.replace(/\.md$/,"")}),(h==null?void 0:h.stale)&&e.jsx("span",{className:"ml-1.5 shrink-0 px-1 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30",children:"stale"})]}),e.jsxs("span",{className:"ml-2 text-fg-faint shrink-0 text-[10px]",children:[H(d.bytes)," · ",K(d.mtimeMs)]})]},d.name)})]}),detail:R?e.jsx(we,{workspace:i,onCancel:()=>j(!1),onCreated:d=>{j(!1),b(d),E()}}):a&&c?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-3 py-2 border-b border-line text-xs",children:[e.jsx("div",{className:"text-fg truncate",children:a.name}),e.jsxs("div",{className:"text-fg-faint truncate",children:[H(a.bytes)," · modified ",K(a.mtimeMs)]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(se,{path:a.path,value:y,onChange:d=>B(h=>({...h,[c]:d}))})})]}):e.jsx(F,{title:u.length===0?"no memories yet":"select a memory",hint:u.length===0?"Claude writes to memories during sessions when you ask it to remember things, or you can create one manually with the + New memory button.":void 0})})})}function we({workspace:t,onCancel:o,onCreated:r}){const[i,m]=l.useState(""),[s,u]=l.useState(""),[f,c]=l.useState(!1),[b,C]=l.useState(null),g=i.trim().toLowerCase(),N=re.test(g),$=async()=>{if(!N){C("Slug must match [a-z0-9-_]+");return}c(!0),C(null);const x=`${g}.md`,S=await window.api.memory.create(x,s.trim()||void 0,t);if(c(!1),!S.ok){C(S.error??"create failed");return}r(x)};return e.jsxs("div",{className:"p-4 max-w-xl space-y-3",children:[e.jsx("div",{className:"text-sm text-fg",children:"New memory"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:i,onChange:x=>m(x.target.value),placeholder:"my-notes",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("span",{className:"text-xs text-fg-faint",children:".md"})]}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:["Lowercase letters, digits, dashes, underscores. The file is created at",e.jsxs("code",{className:"ml-1 font-mono text-fg-dim",children:["~/.claude/projects/",t,"/memory/",g||"…",".md"]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs text-fg-faint",children:"Description (optional)"}),e.jsx("input",{value:s,onChange:x=>u(x.target.value),placeholder:"one-line summary",className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})]}),b&&e.jsx("div",{className:"text-xs text-red-400",children:b}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:$,disabled:!N||f,className:"px-3 py-1 text-xs text-fg border border-line hover:bg-bg-hi rounded transition-colors disabled:opacity-40",children:f?"Creating…":"Create"}),e.jsx("button",{onClick:o,disabled:f,className:"px-3 py-1 text-xs text-fg-faint hover:text-fg-dim rounded transition-colors",children:"Cancel"})]})]})}export{$e as Memory};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`}function ie(){const r=
|
|
3
|
-
`)};if(!r)return e.jsx(w,{title:"loading…"});if(m==="presets")return e.jsx(
|
|
1
|
+
import{ay as d,aQ as W,aL as z,aS as H,aN as N,al as Q,ap as q,af as G,aj as e,l as w,u as D,P as A,W as U,aD as X}from"./index-Db_SK9rW.js";import{S as Y}from"./ScopeSwitcher-BUYDpz2v.js";import{S as Z}from"./SaveBar-CT5u6ZCJ.js";import{P as ee}from"./Library-CN1h5rAE.js";import{u as te,E as se,s as re}from"./settingsSchema-B5jBhSUP.js";import"./monaco-editor-BW5C4Iv1.js";const ne=["allow","deny","ask"];function ae(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function oe(r,n){const a={...r,permissions:n};return JSON.stringify(a,null,2)+`
|
|
2
|
+
`}function ie(){const r=W(),n=z(),a=(n==null?void 0:n.cwd)??null,s=H(t=>t.navFace),i=d.useRef(!1),u=d.useRef(s),[p,c]=d.useState(()=>s==="project"&&a?"project":"user"),[m,P]=d.useState("effective");d.useEffect(()=>{if(u.current!==s){if(u.current=s,i.current){i.current=!1;return}c(s==="project"&&a?"project":"user")}},[s,a]),d.useEffect(()=>{s==="project"&&m==="presets"&&P("effective")},[s,m]);const J=t=>{i.current=!0,c(t)},b=te(A,r,a),f=b[p]??null,j=N(t=>t.files),E=N(t=>t.setDraft),O=N(t=>t.saveJson),I=N(t=>t.revert),[L,y]=d.useState(null),k=e.jsx(U,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:m,onChange:P}),M=d.useMemo(()=>{const t=Q(q(j,b));return G(t,["permissions"])??{kind:"object",children:{}}},[j,b]),$=(t,l)=>{var R;const o=b[p];if(!o)return;y(null);const g=((R=j[o])==null?void 0:R.draftRaw)??"";let v={};if(g.trim())try{v=JSON.parse(g)}catch{v={}}const K=X(v.permissions??{},t,l),V={...v,permissions:K};E(o,JSON.stringify(V,null,2)+`
|
|
3
|
+
`)};if(!r)return e.jsx(w,{title:"loading…"});if(m==="presets")return e.jsx(D,{toolbar:k,children:e.jsx(ee,{})});const C=t=>t!=="user"&&!a,h=f?j[f]:null,{perms:x,full:F,err:T}=h?ae(h.draftRaw):{perms:{},full:{},err:null},S=t=>{f&&(y(null),E(f,oe(F,t)))},_=(t,l)=>{const o=l.trim();if(!o)return;const g=x[t]??[];g.includes(o)||S({...x,[t]:[...g,o]})},B=(t,l)=>{const o=x[t]??[];S({...x,[t]:o.filter((g,v)=>v!==l)})};return e.jsx(D,{toolbar:e.jsxs(e.Fragment,{children:[k,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(Y,{scopes:A.scopes,active:p,onChange:J,annotate:t=>{if(C(t))return{exists:!1};const l=b[t];if(!l)return null;const o=j[l];return{exists:(o==null?void 0:o.exists)??!1,dirty:(o==null?void 0:o.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:f??"—"}),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:f&&h?e.jsx(Z,{dirty:h.dirty,busy:h.busy,parseError:L||T||h.parseError,lastSavedAt:h.lastSavedAt,onSave:async()=>{y(null);const t=await O(f);t.ok||y(t.error??"save failed")},onRevert:()=>{y(null),I(f)}}):null,children:C(p)?e.jsx(w,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):m==="effective"?e.jsx(se,{node:M,targetScope:p,onOverride:$,schema:re().rootedAt(["permissions"]),rootLabel:"permissions"}):f&&h?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[e.jsx(le,{value:x.defaultMode??"default",onChange:t=>S({...x,defaultMode:t})}),ne.map(t=>e.jsx(ce,{list:t,rules:x[t]??[],onAdd:l=>_(t,l),onRemove:l=>B(t,l)},t)),e.jsx(de,{dirs:x.additionalDirectories??[],onChange:t=>S({...x,additionalDirectories:t})})]}):e.jsx(w,{title:"resolving…"})})}const ge=d.memo(ie);function le({value:r,onChange:n}){const a=["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:a.map(s=>e.jsx("button",{onClick:()=>n(s),className:`px-2.5 py-1 text-xs transition-colors ${r===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ce({list:r,rules:n,onAdd:a,onRemove:s}){const[i,u]=d.useState(""),p=r==="allow"?"text-green-400":r==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${p}`,children:r}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,onChange:c=>u(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(a(i),u(""))},placeholder:r==="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:()=>{a(i),u("")},disabled:!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"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((c,m)=>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:c}),e.jsx("button",{onClick:()=>s(m),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${m}-${c}`))})]})}function de({dirs:r,onChange:n}){const[a,s]=d.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:a,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a.trim()&&(n([...r,a.trim()]),s(""))},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:r.map((i,u)=>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:()=>n(r.filter((p,c)=>c!==u)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${u}-${i}`))})]})}export{ge as Permissions};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-CdGr6d3_.js","./index-Db_SK9rW.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./index-CKH5Uxik.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aj as e,ay as p,l as y,q as X,aQ as Y,u as R,aK as K,a as Z}from"./index-Db_SK9rW.js";import{P as z}from"./ProvenanceBadge-Dutz_4OY.js";import{e as ee}from"./Library-CN1h5rAE.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as te}from"./monaco-editor-BW5C4Iv1.js";import{M as ne}from"./MarkdownEditor-DmBxrhdn.js";function se({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:h}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:h??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.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))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(f=>e.jsx("td",{className:`px-3 py-1 ${f.className??""}`,children:f.render(l)},f.key))},r)})})]})}async function ie(t,n,o){var f,b;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const h=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!h)return null;const l=(b=(f=i.plugins[h])==null?void 0:f[0])==null?void 0:b.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function ae(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,h=await window.api.config.readText(i);if(!h.exists)continue;const l=G(h.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function le(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const h=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${h}\\b`,`\`${h}\``];if(i.id.length>=4&&l.push(`\\b${h}\\b`),!l.some(f=>new RegExp(f,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const re=p.lazy(()=>te(()=>import("./SkillReferenceGraph-CdGr6d3_.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function oe({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var b;const[i,h]=p.useState(a??((b=n[0])==null?void 0:b.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=p.useMemo(()=>le(n),[n]),[d,f]=p.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.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"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>f("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>f("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(y,{title:"no skills in this plugin"}):d==="graph"?e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(re,{skills:n,edges:r,selectedId:i,onSelect:h})}):e.jsx(X,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>h(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(ne,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(y,{title:"select a skill"})})})]})}const q=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function ce(){const t=Y(),[n,o]=p.useState([]),[a,i]=p.useState(!0),[h,l]=p.useState(null),[r,d]=p.useState("installed"),[f,b]=p.useState(null),[c,E]=p.useState(new Set);p.useEffect(()=>{var x,k;let s=!1;return(k=(x=window.api.app).seedStatus)==null||k.call(x).then(j=>{s||b(j)}).catch(()=>{}),()=>{s=!0}},[]),p.useEffect(()=>{if(!t)return;let s=!1;return(async()=>{var k;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const w=j.data;for(const[C,A]of Object.entries(w.plugins??{})){if(!Array.isArray(A))continue;const _=C.split("@")[0],u=C.split("@")[1];for(const g of A){if(!(g!=null&&g.installPath))continue;const B={name:_,path:g.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},v=await fe(B);(k=v.manifest)!=null&&k.version||(v.manifest={...v.manifest??{},version:g.version}),v.marketplace=u,x.push(v)}}}}catch{}s||(x.sort((j,w)=>j.name.localeCompare(w.name)),s||(o(x),i(!1)))})(),()=>{s=!0}},[t]);const S=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(z,{interactive:!1,input:q(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],$=p.useMemo(()=>f?Object.keys(f).filter(s=>f[s].status==="exhausted"&&!c.has(s)):[],[f,c]),L=$.length>0?e.jsx(de,{seeders:$,seedStatus:f,onDismiss:s=>E(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(R,{toolbar:e.jsx(W,{active:r,onChange:d}),children:[L,e.jsx(ee,{})]});const m=h?n.find(s=>s.path===h)??null:null;return e.jsxs(R,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(W,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[L,a?e.jsx(y,{title:"scanning plugins…"}):m?e.jsx(he,{row:m,home:t,onBack:()=>l(null)},m.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(se,{columns:S,rows:n,getKey:s=>s.path,activeKey:h,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const ve=p.memo(ce),V={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function de({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[V[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${V[i]} warning`,children:"✕"})]},i))})}function W({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function he({row:t,home:n,onBack:o}){var j,w,C,A,_;const[a,i]=p.useState([]),[h,l]=p.useState([]),[r,d]=p.useState([]),[f,b]=p.useState([]),[c,E]=p.useState("skills"),[S,$]=p.useState(null),[L,m]=p.useState(!0);p.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{m(!0);try{const[g,B,v,Q]=await Promise.all([ie(t.name,t.path,n),O(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),O(`${t.path}/bin`,{filesOnly:!0})]),J=g?await ae(g):[],T=B.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),I=[];T.forEach((N,F)=>{const M=U[F];if(!M.exists)return;const D=G(M.text);I.push({id:N,name:D.name??N.replace(/\.md$/,""),description:D.description})});const H=[];if(v&&v.exists&&!v.parseError&&v.data&&typeof v.data=="object"){const N=v.data.mcpServers;if(N&&typeof N=="object")for(const[F,M]of Object.entries(N)){const D=M&&typeof M=="object"?M.command:void 0;H.push({id:F,name:F,description:typeof D=="string"?D:null})}}if(u)return;i(J),l(I),d(H),b(Q),E(J.length>0?"skills":I.length>0?"agents":H.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(g){if(u)return;K.error(`Failed to load plugin contents: ${g instanceof Error?g.message:String(g)}`),i([]),l([]),d([]),b([])}finally{u||m(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const s=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:h.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:f.length}],x=(j=t.manifest)!=null&&j.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,k=async u=>{const g=await window.api.shell.open({as:"external",url:u});g.ok||K.error(g.error??`Failed to open ${u}`)};return S?e.jsx(oe,{pluginName:((w=t.manifest)==null?void 0:w.name)??t.name,skills:a,initialSelectedId:S.id,onBack:()=>$(null)},S.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((C=t.manifest)==null?void 0:C.name)??t.name}),(A=t.manifest)!=null&&A.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(_=t.manifest)!=null&&_.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(z,{input:q(t)}),t.hasMcp?e.jsx(Z,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[x?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),x]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>k(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:s.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>E(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:L?e.jsx(y,{title:"scanning…"}):e.jsx(me,{active:c,row:t,skills:a,agents:h,mcpServers:r,files:f,onOpenSkill:$})})]})]})}function me({active:t,row:n,skills:o,agents:a,mcpServers:i,files:h,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(P,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(P,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(P,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:e.jsx(P,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:e.jsx(P,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(P,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(y,{title:"no components"}):h.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:h.map((r,d)=>e.jsx(P,{n:d+1,name:r,description:null},r))})}function P({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function fe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const m=await window.api.config.readJson(n);m.exists&&!m.parseError&&m.data&&typeof m.data=="object"&&(a=m.data)}const[i,h,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const m=await window.api.config.readJson(`${t.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)}let f=0;if(r){const m=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(m.data&&typeof m.data=="object"){const s=m.data;f=Object.values(s).reduce((x,k)=>Array.isArray(k)?x+k.reduce((j,w)=>j+(Array.isArray(w.hooks)?w.hooks.length:0),0):x,0)}}const[b,c,E]=await Promise.all([O(`${t.path}/agents`,{filesOnly:!0}),O(`${t.path}/bin`,{filesOnly:!0}),O(`${t.path}/skills`,{dirsOnly:!0})]),S=b.filter(m=>m.endsWith(".md")).length,$=c.length,L=E.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:f,agents:S,skills:L,binCount:$,hasMcp:h}}async function O(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{ve as Plugins};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a0 as P,aQ as G,ay as x,aj as i,Z as R,B as T,a as _}from"./index-Db_SK9rW.js";import{a as j,C as B,c as E,d as L,b as I}from"./Library-CN1h5rAE.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(),S=new Set,$=new Set;for(const e of I){const t=e.official?S:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(E.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(E.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Q=new Set(j.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(j.map(e=>e.command.trim())),q=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),F=/(@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 S.has(t)?l("official MCP server (catalog)"):$.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 Q.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(F.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(),[v,m]=x.useState(!1),w=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!v)return;const s=C=>{w.current&&!w.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)}},[v]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],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:w,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}),v&&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(b,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(b,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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aj as e,ad as x}from"./index-Db_SK9rW.js";function m({dirty:a,busy:n,parseError:t,lastSavedAt:c,onSave:i,onRevert:d,leading:l}){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:l}),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:d,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};
|