claude-code-session-manager 0.130.2 → 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/bin/cli.cjs +19 -2
  3. package/dist/assets/AgentLibrary-CYXre0J-.js +2 -0
  4. package/dist/assets/{AppSettings-Bpwynea4.js → AppSettings-xNSfCj8e.js} +2 -2
  5. package/dist/assets/{Button-DSoqrxCB.js → Button-BWljh5IK.js} +1 -1
  6. package/dist/assets/DocumentEditorPane-FUC2hZlp.js +1 -0
  7. package/dist/assets/Extensions-CsyUoklz.js +2 -0
  8. package/dist/assets/{History-DzMo9Otn.js → History-BvNmY9OQ.js} +2 -2
  9. package/dist/assets/{Library-C5wKMTSn.js → Library-DVXk77zA.js} +12 -12
  10. package/dist/assets/{ListDetail-DDQ1S0yu.js → ListDetail-DAAx__24.js} +1 -1
  11. package/dist/assets/{Panel-B-3NWUlv.js → Panel-g2D-e-RM.js} +1 -1
  12. package/dist/assets/ProjectClaudeConfig-BDuHJwaO.js +25 -0
  13. package/dist/assets/{ProvenanceBadge-CUChwz4Z.js → ProvenanceBadge-wew4_nf3.js} +1 -1
  14. package/dist/assets/Scheduler-CbeUIqD-.js +16 -0
  15. package/dist/assets/Settings-B23RsRfm.js +2 -0
  16. package/dist/assets/{SkillReferenceGraph-C6JEdypC.js → SkillReferenceGraph-BxQPCfsg.js} +1 -1
  17. package/dist/assets/Skills-4AR2FQrI.js +29 -0
  18. package/dist/assets/{SourceChip-DcBNYYhe.js → SourceChip-jrC0vjfw.js} +1 -1
  19. package/dist/assets/SystemPrompt-hHoBEnYb.js +1 -0
  20. package/dist/assets/{TiptapBody-DiVYC-_O.js → TiptapBody-FkUqxO9u.js} +1 -1
  21. package/dist/assets/{Toggle-Cs3k6I96.js → Toggle-DQMNWZKT.js} +1 -1
  22. package/dist/assets/ViewTabs-DGU0ZuxB.js +1 -0
  23. package/dist/assets/{VoiceButton-C3NLotUZ.js → VoiceButton-BPPvDllh.js} +1 -1
  24. package/dist/assets/{historyTotals-f-E0L9Xw.js → historyTotals-D8Oc3wUK.js} +1 -1
  25. package/dist/assets/index-9ajPMXBg.js +3097 -0
  26. package/dist/assets/{index-Bp8XE9A6.css → index-oXqzajWV.css} +1 -1
  27. package/dist/index.html +2 -2
  28. package/dist-web/app.css +1 -1
  29. package/dist-web/app.js +455 -427
  30. package/package.json +1 -1
  31. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  32. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +15 -5
  33. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +8 -4
  34. package/scripts/scheduler-mcp-server.cjs +71 -0
  35. package/src/main/agentLibrary.cjs +81 -29
  36. package/src/main/agentsIpc.cjs +21 -16
  37. package/src/main/build-info.json +4 -4
  38. package/src/main/index.cjs +9 -0
  39. package/src/main/ipcSchemas.cjs +35 -2
  40. package/src/main/lib/epic/epicMint.cjs +61 -6
  41. package/src/main/lib/epic/epicWorktreeMerge.cjs +11 -9
  42. package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
  43. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
  44. package/src/main/lib/epic/restorableSessions.cjs +749 -0
  45. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
  46. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +4 -0
  47. package/src/main/lib/git/branchSweep.cjs +9 -3
  48. package/src/main/lib/git/gitExec.cjs +8 -1
  49. package/src/main/lib/git/gitWorktree.cjs +771 -96
  50. package/src/main/lib/git/jobWorktree.cjs +3 -0
  51. package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
  52. package/src/main/lib/mcpToolCatalog.cjs +28 -0
  53. package/src/main/lib/mcpToolsProbe.cjs +831 -0
  54. package/src/main/lib/mdNetworkScan.cjs +555 -0
  55. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +18 -5
  56. package/src/main/lib/persona-macro/builtinMacros.cjs +22 -4
  57. package/src/main/lib/persona-macro/macroJobDispatch.cjs +17 -2
  58. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
  59. package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
  60. package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
  61. package/src/main/lib/project-pages/matrixStore.cjs +112 -0
  62. package/src/main/lib/promptSessionSchema.cjs +5 -0
  63. package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
  64. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
  65. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  66. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
  67. package/src/main/lib/scheduler/terminalRunOutcome.cjs +61 -15
  68. package/src/main/projectPages.cjs +51 -7
  69. package/src/main/runVerify.cjs +8 -3
  70. package/src/main/scheduler/budget.cjs +146 -7
  71. package/src/main/scheduler/gitTreeGuard.cjs +92 -20
  72. package/src/main/scheduler/reviewLadder.cjs +60 -0
  73. package/src/main/scheduler.cjs +477 -53
  74. package/src/main/seedAgentPersonas.cjs +1 -1
  75. package/src/preload/api.d.ts +250 -7
  76. package/src/preload/apiSurface.json +28 -0
  77. package/src/preload/index.cjs +6 -0
  78. package/src/seed/agents/competitive-analyst.md +69 -0
  79. package/src/seed/agents/competitive-researcher.md +75 -0
  80. package/src/seed/agents/validator.md +2 -2
  81. package/dist/assets/AgentLibrary-Bfj862qf.js +0 -2
  82. package/dist/assets/Extensions-BziIutWV.js +0 -13
  83. package/dist/assets/Memory-Bq5T33d2.js +0 -25
  84. package/dist/assets/Scheduler-CkGHMXvo.js +0 -16
  85. package/dist/assets/Settings-DGxvyajs.js +0 -2
  86. package/dist/assets/SystemPrompt-CfozyVQx.js +0 -1
  87. package/dist/assets/ViewTabs-DFXH03tb.js +0 -1
  88. package/dist/assets/index-CuAfFXNd.js +0 -3086
@@ -1,2 +0,0 @@
1
- import{b9 as X,b4 as ve,aJ as y,Y as P,b1 as Z,a$ as N,at as e,l as K,a_ as z,a6 as je,ay as A,bk as we,b as V,aY as Ne,bc as ee,M as ye,d as Y,E as $e}from"./index-CuAfFXNd.js";import{P as te}from"./Panel-B-3NWUlv.js";import{L as ne}from"./ListDetail-DDQ1S0yu.js";import{V as Ce}from"./ViewTabs-DFXH03tb.js";import{S as se}from"./SourceChip-DcBNYYhe.js";import{B as R}from"./Button-DSoqrxCB.js";import{r as ke}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";function ae(t,s){const a=X();ve([a?`${a}/.claude/agents`:null,t?`${t}/.claude/agents`:null],s)}function Se({onOpenPersona:t}){const[s,a]=y.useState(P[0].tag),{personas:d,refresh:l}=Z(o=>N.error(o.message||"failed to load agent personas"));ae(null,()=>{l()});const r=P.find(o=>o.tag===s)??null;return e.jsx(te,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[P.length," tag",P.length===1?"":"s"]}),children:e.jsx(ne,{sidebar:e.jsx("div",{className:"py-1",children:P.map(o=>{const p=z(o.tag),b=s===o.tag,c=(d==null?void 0:d.filter(v=>v.tags.includes(o.tag)).length)??0;return e.jsxs("button",{onClick:()=>{a(o.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${b?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${p.bg} ${p.text} ${p.border?"border border-current/30":""}`,children:["#",o.tag]}),e.jsx("span",{className:"truncate",children:o.label}),c>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:c})]},o.tag)})}),detail:r?e.jsx(Ee,{entry:r,personas:d,onOpenPersona:t}):e.jsx(K,{title:"select a tag"})})})}const Le=y.memo(Se);function Ee({entry:t,personas:s,onOpenPersona:a}){const d=z(t.tag),l=je(t.tag),r=(s==null?void 0:s.filter(o=>o.tags.includes(t.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${d.bg} ${d.text} ${d.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),s===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.map(o=>e.jsx("button",{onClick:()=>a==null?void 0:a(o.name),title:`Open ${o.name} in Personas`,className:"inline-flex items-center bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg hover:bg-bg-hi",children:o.name},o.name)),r.length===0&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:l.initialPromptTemplate})]})]})}const De=new Set(P.map(t=>t.tag));function oe(t){return t.filter(s=>De.has(s))}function Te(t,s={}){return{name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??void 0,color:t.color??"",tags:oe(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...s}}const Oe=t=>{const[s,a]=t.split(".");return Number(s)+(a?Number(a)/100:0)};function Re(t){const s=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!s)return[];const a=[];for(const d of s[1].split(/,\s*|\s+and\s+/)){const l=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(d.trim());l&&a.push({family:l[1].toLowerCase(),version:Oe(l[2])})}return a}var q,Q;const Pe=Re(String(((Q=(q=ke.properties)==null?void 0:q.effortLevel)==null?void 0:Q.description)??""));function Ae(t,s){const a=new RegExp(`${s}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(a)return Number(a[1])+(a[2]?Number(a[2])/100:0);const d=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${s}`,"i").exec(t);return d?Number(d[1])+(d[2]?Number(d[2])/100:0):null}function Fe(t,s=Pe){if(!t||t==="inherit"||s.length===0)return null;const a=A(t);if(!a)return null;const d=s.filter(r=>r.family===a);if(d.length===0)return!1;const l=Ae(t,a);return l===null?null:l>=Math.min(...d.map(r=>r.version))}const H=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Be=["","red","orange","yellow","green","cyan","blue","purple","pink"],re={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function _(t){return{name:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??"inherit",color:t.color??"",tags:t.tags,body:t.body}}const J={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""};function Me(t){return t.overridingProjects.map(s=>{var l;const a=(l=t.overrideDetails)==null?void 0:l.find(r=>r.project===s);if(!a)return s;const d=[...a.fields.filter(r=>r!=="name"),...a.bodyOverridden?["full body"]:[]];return`${s}: ${d.join(", ")||"overlay"}`}).join(`
2
- `)}function Ve(){const[t,s]=y.useState("personas"),{personas:a,refresh:d}=Z(n=>N.error(n.message||"failed to load agent personas")),[l,r]=y.useState(null),[o,p]=y.useState(""),[b,c]=y.useState(null),[v,h]=y.useState(!1),[$,S]=y.useState(!1),[g,C]=y.useState(null),[L,k]=y.useState(!1),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1},[]);const i=we(n=>{var u;return((u=n.tabs.find(T=>T.id===n.activeTabId))==null?void 0:u.cwd)??null}),w=i?i.replace(/\/+$/,"").split("/").pop()||i:null,j=async n=>{await d()&&n&&r(n)};ae(i,()=>j()),y.useEffect(()=>{const n=Ne();n&&r(n);const u=T=>r(T.detail);return window.addEventListener("sm:select-persona",u),()=>window.removeEventListener("sm:select-persona",u)},[]);const O=e.jsx(Ce,{options:[{key:"personas",label:"Personas"},{key:"tags",label:"Tags"}],active:t,onChange:s});if(t==="tags")return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-line",children:O}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Le,{onOpenPersona:n=>{r(n),c(null),h(!1),s("personas")}})})]});if(a===null)return e.jsx(K,{title:"loading…"});const F=o.toLowerCase(),B=a.filter(n=>!F||n.name.toLowerCase().includes(F)||(n.description??"").toLowerCase().includes(F)),f=a.find(n=>n.name===l)??a[0]??null,x=b??(f?_(f):null),M=!!b&&!!f&&JSON.stringify(b)!==JSON.stringify(_(f)),m=v,I=n=>{c(null),h(!1),S(!1),C(null),r(n)},de=n=>c(u=>({...u??(f?_(f):J),...n})),ce=()=>{c({...J}),h(!0),S(!1)},fe=()=>{x&&(c({...x,name:x.name+"-copy"}),h(!0))},xe=()=>{c(null),h(!1)},me=async()=>{if(x){if(!/^[a-z][a-z0-9-]*$/.test(x.name)){N.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}k(!0);try{const n=m?null:f,u={name:x.name,originalName:n==null?void 0:n.name,description:x.description,tools:x.tools,model:x.model,effort:x.effort,color:x.color,tags:oe(x.tags),body:x.body},T=n?Te(n,u):u;await window.api.agents.savePersona(T),N.info(m?`created ${x.name}`:`saved ${x.name}`),c(null),h(!1),await j(x.name)}catch(n){N.error(n.message||"failed to save agent persona")}finally{k(!1)}}},ge=async()=>{if(f){k(!0);try{await window.api.agents.deletePersona({name:f.name}),N.info(`deleted ${f.name}`),S(!1),c(null),h(!1),await j()}catch(n){N.error(n.message||"failed to delete agent persona")}finally{k(!1)}}},he=async n=>{k(!0);try{await window.api.agents.deletePersona({name:n}),N.info(`deleted ${n}`),C(null),l===n&&(c(null),h(!1)),await j()}catch(u){N.error(u.message||"failed to delete agent persona")}finally{k(!1)}},pe=async n=>{if(f)try{await window.api.agents.removeOverride({name:f.name,projectName:n}),N.info(`removed ${n}'s override of ${f.name}`),await j(f.name)}catch(u){N.error(u.message||"failed to remove override")}},ue=async n=>{if(!(!f||!w)){k(!0);try{n.model==="inherit"&&n.effort==="inherit"?(await window.api.agents.removeOverride({name:f.name,projectName:w}),N.info(`cleared ${w}'s override of ${f.name}`)):(await window.api.agents.savePersona({name:f.name,projectName:w,description:"",tools:[],color:"",tags:[],body:"",model:n.model,effort:n.effort}),N.info(`saved ${w}'s override of ${f.name}`)),await j(f.name)}catch(u){N.error(u.message||"failed to save project override")}finally{k(!1)}}};return e.jsx(te,{toolbar:e.jsxs(e.Fragment,{children:[O,e.jsxs("span",{className:"text-fg-faint",children:[a.length," persona",a.length===1?"":"s"]}),e.jsx("input",{value:o,onChange:n=>p(n.target.value),placeholder:"filter…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-40"}),e.jsx("div",{className:"flex-1"}),e.jsx(R,{variant:"primary",onClick:ce,children:"+ New agent"})]}),children:e.jsx(ne,{sidebar:e.jsxs("div",{className:"py-1",children:[m&&e.jsx("div",{className:"w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 bg-bg-hi text-fg border-l-2 border-accent",children:e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsx("span",{className:"truncate font-mono",children:x==null?void 0:x.name}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-accent",children:"new"})]})}),B.length===0&&!m?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):B.map(n=>{const u=!m&&n.name===l,T=u&&M,be=g===n.name;return e.jsxs("div",{"data-agent-row":n.name,className:`group w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 border-l-2 cursor-pointer ${u?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,onClick:()=>I(n.name),children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:n.color?re[n.color]??n.color:"var(--fg-faint, #999)",opacity:n.color?1:.35}}),e.jsx("span",{className:"truncate font-mono",children:n.name})]}),e.jsxs("span",{className:"shrink-0 flex items-center gap-1.5",children:[T&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!T&&n.overridingProjects.length>0&&e.jsx("span",{title:Me(n),children:e.jsxs(V,{tone:"dim",children:[n.overridingProjects.length," override",n.overridingProjects.length>1?"s":""]})}),be?e.jsxs("span",{className:"flex items-center gap-1",onClick:W=>W.stopPropagation(),children:[e.jsx("button",{onClick:()=>he(n.name),disabled:L,title:`Delete ${n.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>C(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{onClick:W=>{W.stopPropagation(),C(n.name)},title:`Delete ${n.name}`,className:"opacity-0 group-hover:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})]}),n.description&&e.jsx("span",{className:"truncate text-fg-faint",children:n.description})]},n.name)})]}),detail:x?e.jsx(Ie,{obj:x,set:de,saved:f,dirty:M,isNew:m,busy:L,confirmDelete:$,setConfirmDelete:S,onDuplicate:fe,onRevert:xe,onSave:me,onDelete:ge,onDropOverride:pe,activeProject:w,activeCwd:i,onSaveOverride:ue}):e.jsx(K,{title:"select an agent"})})})}const qe=y.memo(Ve);function Ie({obj:t,set:s,saved:a,dirty:d,isNew:l,busy:r,confirmDelete:o,setConfirmDelete:p,onDuplicate:b,onRevert:c,onSave:v,onDelete:h,onDropOverride:$,activeProject:S,activeCwd:g,onSaveOverride:C}){const L=X(),k=!l&&a?a.path:`${L??"~"}/.claude/agents/${t.name}.md`,E=d||l;return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-line flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-fg font-mono",children:t.name}),l?e.jsx(V,{tone:"accent",children:"unsaved draft"}):d?e.jsx(V,{tone:"warn",children:"edited"}):e.jsx(V,{tone:"good",children:"saved"}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(se,{path:k})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(D,{label:"name",hint:"Filename on disk — lowercase, hyphenated.",children:e.jsx("input",{value:t.name,onChange:i=>s({name:i.target.value.toLowerCase()}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})}),e.jsx(D,{label:"description",hint:"Shown in the list and in agent pickers.",children:e.jsx("input",{value:t.description,onChange:i=>s({description:i.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})}),e.jsx(ie,{value:t.model,onChange:i=>s({model:i})}),e.jsx(le,{value:t.effort,model:t.model,onChange:i=>s({effort:i})}),!l&&a&&e.jsx(We,{saved:a,activeProject:S,activeCwd:g,busy:r,onSave:C}),e.jsx(D,{label:"tools",hint:`${t.tools.length} of ${H.length} granted. Anything not ticked is refused at call time.`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:H.map(i=>{const w=t.tools.includes(i);return e.jsx("button",{onClick:()=>s({tools:w?t.tools.filter(j=>j!==i):[...t.tools,i]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${w?"bg-sage/15 text-sage-dark border-sage/30":"bg-bg-hi text-fg-faint border-line"}`,children:i},i)})})}),e.jsx(D,{label:"color",children:e.jsx("div",{className:"flex gap-1.5",children:Be.map(i=>e.jsx("button",{title:i||"none",onClick:()=>s({color:i}),className:"w-5 h-5 rounded",style:{background:i?re[i]:"transparent",border:t.color===i?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},i||"none"))})}),e.jsx(D,{label:"tags",hint:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab.",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(i=>{const w=t.tags.includes(i.tag),j=z(i.tag);return e.jsxs("button",{onClick:()=>s({tags:w?t.tags.filter(O=>O!==i.tag):[...t.tags,i.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${w?`${j.bg} ${j.text} ${j.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",i.tag]},i.tag)})})}),e.jsx(D,{label:"definition",hint:"The system prompt this persona runs under.",children:e.jsx("textarea",{rows:9,value:t.body,onChange:i=>s({body:i.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono leading-relaxed resize-y"})}),e.jsx(D,{label:"project overrides",hint:"Open projects that shadow this definition with a local copy.",children:a&&a.overridingProjects.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.overridingProjects.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[i,e.jsx("button",{onClick:()=>$(i),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},i))}):e.jsx("div",{className:"text-xs text-fg-faint italic",children:l?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere."})})]}),e.jsx("div",{className:"px-4 py-2.5 border-t border-line flex items-center gap-2 flex-wrap",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx(R,{variant:"danger",onClick:h,disabled:r,children:"Delete"}),e.jsx(R,{onClick:()=>p(!1),children:"Keep"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:b,disabled:r,children:"Duplicate"}),!l&&e.jsx(R,{variant:"danger",onClick:()=>p(!0),disabled:r,children:"Delete"}),e.jsx("div",{className:"flex-1"}),E&&e.jsx("span",{className:"text-[11px] text-fg-faint",children:"unsaved changes"}),e.jsx(R,{onClick:c,disabled:!E||r,children:"Revert"}),e.jsx(R,{variant:"primary",onClick:v,disabled:!E||r,children:r?"Saving…":l?"Create":"Save"})]})})]})}function D({label:t,hint:s,children:a}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:t}),a,s&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:s})]})}const G="latest",U="Blocked by the availableModels allowlist in your Claude settings";function ie({value:t,onChange:s,label:a="default model",hint:d,testIdPrefix:l="",inheritLabel:r}){var x,M;const{catalog:o,loading:p,degraded:b,refresh:c}=ee(null),v=o?["inherit",...o.aliases]:[...ye],h=(o==null?void 0:o.availableModels)??null,$=m=>!!h&&m!=="inherit"&&!h.includes(m),S=(m,I)=>!!h&&!h.includes(m)&&!(I&&h.includes(I)),g=t||"inherit",C=((x=/\[[^\]]*\]$/.exec(g))==null?void 0:x[0])??"",L=v.includes(g),k=!L&&o&&A(g)&&v.includes(A(g)+C)?A(g)+C:null,E=L?g:k??g,i=A(E),w=((M=/\[[^\]]*\]$/.exec(E))==null?void 0:M[0])??"",j=!!o&&g!=="inherit"&&!!i&&v.includes(E),O=j?o.models.filter(m=>A(m)===i).map(m=>m+w):[],F=L?G:g,B={};if(o)for(const m of v)$(m)&&(B[m]=U);const f={};for(const m of O)S(m,i)&&(f[m]=U);return e.jsxs(D,{label:a,hint:d??"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls.",children:[e.jsx("div",{"data-testid":`${l}model-row`,children:e.jsx(Y,{options:v,value:E,onChange:s,mono:!0,blocked:B,labels:r?{inherit:r}:void 0})}),j&&e.jsxs("div",{className:"mt-2","data-testid":`${l}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(Y,{options:[G,...O],value:F,onChange:m=>s(m===G?E:m),mono:!0,blocked:f})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:o?`Models are live-read from the installed claude CLI${b?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:p?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${l}model-catalog-refresh`,onClick:()=>{c()},disabled:p,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function le({value:t,model:s,onChange:a,label:d="effort",testIdPrefix:l="",inheritLabel:r}){const{catalog:o}=ee(null),p=o&&o.effortLevels.length?["inherit",...o.effortLevels]:[...$e],b=(o==null?void 0:o.settingsEffortLevels)??[],c=o?p.filter($=>$!=="inherit"&&!b.includes($)):[],v=t||"inherit",h=v!=="inherit"&&Fe(s)===!1;return e.jsxs(D,{label:d,hint:o?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${c.length?`${c.join(", ")} ${c.length>1?"are":"is"} session-only — settings.json accepts ${b.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${l}effort-row`,children:e.jsx(Y,{options:p,value:v,onChange:a,mono:!0,labels:r?{inherit:r}:void 0})}),c.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${l}effort-session-only`,children:c.map($=>`${$} (session-only)`).join(" · ")}),h&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${l}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function We({saved:t,activeProject:s,activeCwd:a,busy:d,onSave:l}){var h,$,S;if(!s)return e.jsxs("div",{"data-testid":"project-override-none",className:"border border-dashed border-line rounded p-3 text-[11px] text-fg-faint",children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide mb-1 font-mono",children:"project override"}),"No active project — open a project tab to override this persona's model or effort for that project only."]});const r=(h=t.overrideDetails)==null?void 0:h.find(g=>g.project===s),o=!!(r!=null&&r.bodyOverridden),p=(($=r==null?void 0:r.values)==null?void 0:$.model)??"inherit",b=((S=r==null?void 0:r.values)==null?void 0:S.effort)??"inherit",c=t.model??"inherit",v=t.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override",className:"border border-accent/40 rounded p-3 space-y-3 bg-accent/5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-accent font-mono",children:"project override"}),e.jsxs(V,{tone:"accent",children:[s," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(se,{path:`${(a??"").replace(/\/+$/,"")}/.claude/agents/${t.name}.md`})})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint leading-snug",children:["Changes what the SCHEDULER (and new Epics) spawn for ",e.jsx("strong",{children:s})," only — a frontmatter-only overlay with just the keys you set; the persona's body stays the global one. The global model/effort rows edit the machine-wide persona and are never touched here."]}),o&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s,' already has a FULL-BODY override of this persona (its own definition text). It is shown as-is and not converted to a frontmatter-only overlay — edit that file directly, or drop it with × under "project overrides" below.']}),e.jsxs("fieldset",{disabled:d||o,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(ie,{value:p,onChange:g=>{o||l({model:g,effort:b})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(le,{value:b,model:p!=="inherit"?p:c,onChange:g=>{o||l({model:p,effort:g})},label:"project effort",testIdPrefix:"override-",inheritLabel:"use global"})]}),e.jsx("div",{"data-testid":"override-provenance",className:"text-[11px] font-mono text-fg-dim space-y-0.5",children:[["model",c,p],["effort",v,b]].map(([g,C,L])=>e.jsxs("div",{"data-testid":`override-provenance-${g}`,children:[g,": ",L!=="inherit"?e.jsxs(e.Fragment,{children:[C," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:L})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[C," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},g))})]})}export{qe as AgentLibrary};
@@ -1,13 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-C6JEdypC.js","./index-CuAfFXNd.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-Bp8XE9A6.css"])))=>i.map(i=>d[i]);
2
- import{at as e,F as Le,aJ as o,b9 as ie,b0 as ke,au as we,a$ as G,b3 as J,b4 as de,l as O,b as re,bm as Ne,be as De,H as Oe}from"./index-CuAfFXNd.js";import{V as Fe}from"./ViewTabs-DFXH03tb.js";import{S as le}from"./SourceChip-DcBNYYhe.js";import{P as ae}from"./Panel-B-3NWUlv.js";import{L as ue}from"./ListDetail-DDQ1S0yu.js";import{S as Se,f as he,m as _e,e as Ie,M as Be,d as We}from"./Library-C5wKMTSn.js";import{T as Je}from"./Toggle-Cs3k6I96.js";import{P as te}from"./ProvenanceBadge-CUChwz4Z.js";import{_ as He}from"./monaco-editor-BsIlgG7c.js";import"./Button-DSoqrxCB.js";function $e({value:s,onChange:t,path:n,readOnly:a}){return e.jsx(Le,{path:`file://${n}`,defaultLanguage:"markdown",value:s,onChange:l=>t(l??""),theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,wordWrap:"on",readOnly:a,automaticLayout:!0}})}const me=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,oe="disable-model-invocation",Ce=/^\s*disable-model-invocation\s*:/;function Ve(s){const t=s.match(me);if(!t)return!1;for(const n of t[1].split(/\r?\n/)){if(!Ce.test(n))continue;const a=n.slice(n.indexOf(":")+1).trim().toLowerCase();return a==="true"||a==="yes"}return!1}function Ke(s){const t=s.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function xe(s){return s.length-s.trimStart().length}function pe(s){const t=s.match(me);if(!t)return{name:null,description:null,body:s};const n=t[1].split(/\r?\n/),a=t[2]??"";let l=null,c=null;for(let r=0;r<n.length;r++){const x=n[r],u=x.match(/^(\s*)(name|description)\s*:(.*)$/);if(!u)continue;const[,,f,v]=u,p=v.trim(),A=xe(x);let $;if(p===""||p===">-"||p===">"||p==="|-"||p==="|"){const P=[];let M=r+1;for(;M<n.length&&n[M].trim()!==""&&xe(n[M])>A;)P.push(n[M].trim()),M++;$=P.join(" ")}else $=Ke(p);f==="name"?l=$:c=$}return{name:l,description:c,body:a}}function Ue(s,t){const n=s.match(me);if(!n){if(!t)return s;const r=s.startsWith(`
3
- `)?"":`
4
- `;return`---
5
- ${oe}: true
6
- ---
7
- ${r}${s}`}const a=n[2]??"",l=n[1].split(/\r?\n/),c=l.findIndex(r=>Ce.test(r));if(t)c>=0?l[c]=`${oe}: true`:l.push(`${oe}: true`);else{if(c<0)return s;l.splice(c,1)}return`---
8
- ${l.join(`
9
- `)}
10
- ---
11
- ${a}`}const qe=250,ze=2e3;function Ge(s,t){return{user:{skills:`${s}/.claude/skills`,commands:`${s}/.claude/commands`},project:t?{skills:`${t}/.claude/skills`,commands:`${t}/.claude/commands`}:null}}function Ye({onAdd:s,scope:t="user"}={}){const n=ie(),a=ke(),l=(a==null?void 0:a.cwd)??null,[c,r]=o.useState([]),[x,u]=o.useState(null),[f,v]=o.useState(""),[p,A]=o.useState([]),[$,P]=o.useState(null),M=o.useMemo(()=>n?Ge(n,l):null,[n,l]),j=o.useMemo(()=>M?t==="user"?M.user:M.project:null,[t,M]),k=o.useRef(0),y=o.useCallback(async()=>{const d=++k.current;if(!j){r([]),A([]);return}const S=[],E=[];try{const m=await we(j.skills);E.push(...m.errors);for(const N of m.entries)S.push({kind:"skills",scope:t,name:N.name,path:N.path,dir:N.dir,disabled:Ve(N.text),description:pe(N.text).description??void 0})}catch(m){E.push({path:j.skills,error:m instanceof Error?m.message:String(m)})}try{const m=await window.api.config.listDir(j.commands,{filesOnly:!0});m.ok||E.push({path:j.commands,error:m.error??"failed to list directory"});for(const N of m.entries)N.name.endsWith(".md")&&S.push({kind:"commands",scope:t,name:N.name.replace(/\.md$/,""),path:N.path,dir:null,disabled:!1})}catch(m){E.push({path:j.commands,error:m instanceof Error?m.message:String(m)})}if(k.current===d){for(const m of E)G.error(`Could not read ${m.path}: ${m.error}`);A(E),S.sort((m,N)=>m.kind===N.kind?m.name.localeCompare(N.name):m.kind==="skills"?-1:1),r(S),u(m=>{var N;return S.find(V=>V.path===m)?m:((N=S[0])==null?void 0:N.path)??null})}},[j,t]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>()=>{k.current+=1},[]);const C=o.useRef(y);C.current=y;const R=o.useRef(c);R.current=c;const F=o.useRef(x);F.current=x;const I=o.useRef(null),B=o.useRef(!1),W=o.useRef(!1),D=o.useCallback(async()=>{if(B.current){W.current=!0;return}B.current=!0;try{await C.current()}finally{B.current=!1}W.current&&(W.current=!1,D())},[]);o.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]);const i=o.useCallback(d=>{var N;const S=F.current,E=S?R.current.find(V=>V.path===S):null,m=S?(N=J.getState().files[S])==null?void 0:N.lastSavedAt:null;E!=null&&E.dir&&m&&Date.now()-m<ze&&(d===E.dir||E.dir.startsWith(`${d}/`))||(I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,D()},qe))},[D]);de(j?[j.skills,j.commands]:[],i);const g=J(d=>d.files),K=J(d=>d.loadText),_=J(d=>d.setDraft),H=J(d=>d.saveText),q=J(d=>d.revert),L=J(d=>d.watchFile),z=J(d=>d.unwatchFile);async function X(d,S){const E=await window.api.config.readText(d.path);if(!E.exists)return;const m=Ue(E.text,S);if(m===E.text)return;const N=await window.api.config.writeText(d.path,m);if(!N.ok){G.error(N.error??"failed to update skill");return}r(V=>V.map(Q=>Q.path===d.path?{...Q,disabled:S}:Q)),J.getState().files[d.path]&&J.getState().loadText(d.path,!0)}async function Z(d){if(!d.dir)return;P(null);const S=await window.api.files.delete(d.dir);if(!S.ok){G.error(S.error??"failed to remove skill");return}G.info(`Removed "${d.name}" — moved to trash`),z(d.path),r(E=>{const m=E.filter(N=>N.path!==d.path);return u(N=>{var V;return N!==d.path?N:((V=m[0])==null?void 0:V.path)??null}),m})}o.useEffect(()=>{if(x)return g[x]||K(x),L(x),()=>z(x)},[x]);const[h,b]=o.useState(null);if(!n)return e.jsx(O,{title:"loading…"});if(t==="project"&&!l)return e.jsx(ae,{toolbar:e.jsx(e.Fragment,{}),children:e.jsx(O,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const w=c.find(d=>d.path===x)??null,T=x?g[x]:null;return e.jsx(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ml-3 text-fg-faint",children:[c.length," ",c.length===1?"item":"items"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Add…"}),w&&e.jsx(te,{scope:w.scope,input:{type:w.kind==="commands"?"command":"skill",name:w.name}}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:(w==null?void 0:w.path)??""})]}),footer:x&&T?e.jsx(Se,{dirty:T.dirty,busy:T.busy,parseError:h,lastSavedAt:T.lastSavedAt,onSave:async()=>{b(null);const d=await H(x);d.ok||b(d.error??"save failed")},onRevert:()=>{b(null),q(x)}}):null,children:e.jsx(ue,{sidebar:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:f,onChange:d=>v(d.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),["skills","commands"].map(d=>{const S=f.toLowerCase(),E=c.filter(m=>m.kind===d&&(!S||m.name.toLowerCase().includes(S)));return e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"px-3 py-1 text-xs uppercase tracking-wider text-fg-faint",children:d==="skills"?"Skills":"Slash Commands"}),E.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"none"}):E.map(m=>{var V,Q,se;const N=m.kind==="skills";return e.jsxs("div",{className:`w-full px-3 py-1 text-xs flex items-center justify-between gap-2 ${x===m.path?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("button",{onClick:()=>u(m.path),className:"flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:`truncate ${m.disabled?"line-through opacity-50":""}`,title:m.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,children:[m.kind==="commands"?"/":"",m.name]}),m.description&&e.jsx("div",{className:"truncate text-fg-faint",children:m.description})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(te,{interactive:!1,scope:m.scope,input:{type:m.kind==="commands"?"command":"skill",name:m.name}}),((V=g[m.path])==null?void 0:V.dirty)&&e.jsx("span",{className:"w-1 h-1 rounded-full bg-accent"}),N&&e.jsx("span",{title:(Q=g[m.path])!=null&&Q.dirty?"This skill has unsaved edits — save or revert before toggling":void 0,children:e.jsx(Je,{checked:!m.disabled,disabled:!!((se=g[m.path])!=null&&se.dirty),onChange:U=>void X(m,!U)})}),m.kind==="skills"&&$===m.path&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>void Z(m),title:`Remove ${m.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>P(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}),m.kind==="skills"&&$!==m.path&&e.jsx("button",{onClick:U=>{U.stopPropagation(),P(m.path)},title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${m.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]},m.path)})]},d)})]}),detail:x&&T?e.jsx("div",{className:"h-full",children:e.jsx($e,{path:x,value:T.draftRaw,onChange:d=>{b(null),_(x,d)}})}):c.length===0&&p.length>0?e.jsx("div",{"data-testid":"skills-list-error",children:e.jsx(O,{title:"could not list skills or commands",hint:p.map(d=>`${d.path}: ${d.error}`).join(`
12
- `)})}):e.jsx(O,{title:c.length===0?"no skills or commands":"select an item"})})})}const Xe=o.memo(Ye),Ze={live:"bg-emerald-400",idle:"bg-amber-400",offline:"bg-fg-faint",attention:"bg-accent",paused:"bg-zinc-500"},Qe={sm:"w-1.5 h-1.5",md:"w-2 h-2"},et={on:"live",off:"offline",warn:"attention",live:"live",idle:"idle"};function Ee({state:s,kind:t,pulse:n=!1,size:a="sm",className:l="",title:c,"aria-label":r}){const x=s??(t?et[t]:"idle"),u=Ze[x],f=Qe[a],v=n?"animate-pulse":"",p=r??c??x;return e.jsx("span",{role:"img","aria-label":p,className:`inline-block rounded-full ${f} ${u} ${v} ${l}`.trim(),title:c})}const tt={failed:"Failed","needs-auth":"Needs auth",pending:"Pending approval"};function ge(s,t){const n=t!=null&&t.ok?t.servers.find(a=>a.name===s):void 0;return!n||n.status==="unknown"?{state:"unprobed",label:"Not checked",probeStatus:(n==null?void 0:n.status)??null,badgeTone:"dim",dotState:"offline"}:n.status==="connected"?{state:"ready",label:"Ready",probeStatus:n.status,badgeTone:"good",dotState:"live"}:{state:"not-ready",label:tt[n.status],probeStatus:n.status,badgeTone:"warn",dotState:"attention"}}const be=(s,t)=>({type:"mcp",name:s,command:t.command,args:t.args,url:t.url}),st=["stdio","http","streamable-http","sse","ws"],nt=new Set(["workspace"]),at=new Set(["ide","tasks"]);function lt(s,t,n){return s==="user"?`${t}/.claude.json`:n?`${n}/.mcp.json`:null}function rt(s){if(s.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(s),n=t.mcpServers??{};return{full:t,servers:n,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function it(s,t){const n={};for(const[a,l]of Object.entries(t)){const{enabled:c,...r}=l;n[a]=r}return JSON.stringify({...s,mcpServers:n},null,2)+`
13
- `}function ot(s,t){const n=[];for(const[a,l]of Object.entries(t)){if(JSON.stringify(l)===JSON.stringify(s[a]))continue;const{enabled:c,...r}=l;n.push({name:a,value:r})}for(const a of Object.keys(s))a in t||n.push({name:a,value:void 0});return n}function ct(s){let t=Object.keys(s).length+1,n=`server-${t}`;for(;s[n];)t+=1,n=`server-${t}`;return n}function dt({onAdd:s,scope:t="user"}={}){const n=ie(),a=ke(),l=(a==null?void 0:a.cwd)??null,[c,r]=o.useState(null),[x,u]=o.useState(""),f=o.useMemo(()=>n?lt(t,n,l):null,[n,t,l]),v=J(h=>h.files),p=J(h=>h.loadJson),A=J(h=>h.setDraft),$=J(h=>h.revert),P=J(h=>h.watchFile),M=J(h=>h.unwatchFile);o.useEffect(()=>{if(f)return v[f]||p(f),P(f),()=>M(f)},[f]);const[j,k]=o.useState(null),[y,C]=o.useState(null),[R,F]=o.useState(!1),I=o.useRef(0),B=o.useRef(!0);o.useEffect(()=>()=>{B.current=!1},[]);const W=async()=>{const h=++I.current;F(!0);try{const b=await window.api.mcp.status();if(!B.current||h!==I.current)return;C(b),b.ok||G.error(b.error??"MCP status probe failed")}catch(b){if(!B.current||h!==I.current)return;C(null),G.error(b.message||"MCP status probe failed")}finally{B.current&&h===I.current&&F(!1)}};if(o.useEffect(()=>{W()},[]),!n)return e.jsx(O,{title:"loading…"});if(t==="project"&&!l)return e.jsx(ae,{toolbar:e.jsx(e.Fragment,{}),children:e.jsx(O,{title:"no active project"})});if(!f)return e.jsx(O,{title:"loading…"});const D=v[f],{full:i,servers:g,err:K}=D?rt(D.draftRaw):{full:{},servers:{},err:null},_=Object.keys(g).sort(),H=c?g[c]:null,q=h=>{k(null),A(f,it(i,h))},L=()=>{const h=ct(g);q({...g,[h]:{type:"stdio",command:"",args:[]}}),r(h)},z=h=>{const b={...g};delete b[h],q(b),c===h&&r(null)},X=(h,b)=>{if(!b||b===h||g[b])return;const w={};for(const T of Object.keys(g))w[T===h?b:T]=g[T];q(w),r(b)},Z=(h,b)=>{q({...g,[h]:b})};return e.jsxs(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ml-3 px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-faint",children:[_.length," server",_.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:f}),e.jsx("div",{className:"flex-1"}),c&&H&&e.jsx(te,{scope:t,input:be(c,H),className:"mr-2"}),e.jsx("button",{onClick:W,disabled:R,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50 mr-2",children:R?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:()=>s==null?void 0:s({scope:t,cwd:l}),className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi mr-2",children:"Add…"}),e.jsx("button",{onClick:L,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ new server"})]}),footer:D?e.jsx(Se,{dirty:D.dirty,busy:D.busy,parseError:j||K||D.parseError,lastSavedAt:D.lastSavedAt,onSave:async()=>{var b;k(null);const h=((b=D.diskData)==null?void 0:b.mcpServers)??{};for(const[w,T]of Object.entries(g)){if(JSON.stringify(T)===JSON.stringify(h[w]))continue;const d=he(T);if(d.length>0){Ne.getState().show("error",`Not saved: "${w}" still contains placeholder ${d.map(S=>S.token).join(", ")} — replace it with a real value`);return}}try{for(const w of ot(h,g))await window.api.claudeConfig.patch({..._e(t,l),keyPath:["mcpServers",w.name],value:w.value});await p(f)}catch(w){k(w.message||"save failed")}},onRevert:()=>{k(null),$(f)}}):null,children:[t==="project"&&l&&e.jsx(pt,{cwd:l,names:_}),e.jsx(ue,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:x,onChange:h=>u(h.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),_.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):_.filter(h=>!x||h.toLowerCase().includes(x.toLowerCase())).map(h=>{var T;const b=ge(h,y),w=(T=g[h].description)==null?void 0:T.trim();return e.jsxs("button",{onClick:()=>r(h),className:`w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 ${c===h?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ee,{state:b.dotState,title:b.label}),e.jsx("span",{className:"truncate",children:h})]}),e.jsxs("span",{className:"ml-2 flex items-center gap-2 shrink-0",children:[(()=>{const d=he(g[h]);return d.length>0?e.jsxs(re,{tone:"warn",title:`${t} scope · ${f}`,children:["unconfigured placeholder: ",d.map(S=>S.token).join(", ")]}):null})(),e.jsx(re,{tone:b.badgeTone,children:b.label}),e.jsx(te,{interactive:!1,scope:t,input:be(h,g[h])}),e.jsx("span",{className:"text-fg-faint",children:g[h].type??"stdio"})]})]}),w?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:w,children:w}):null]},h)})]}),detail:c&&H?e.jsx(mt,{name:c,server:H,connection:ge(c,y),onTestConnection:W,testing:R,onRename:h=>X(c,h),onChange:h=>Z(c,h),onRemove:()=>z(c)}):e.jsx(O,{title:"select a server or click + new"})})]})}const ut=o.memo(dt);function mt({name:s,server:t,connection:n,onTestConnection:a,testing:l,onRename:c,onChange:r,onRemove:x}){var M;const u=t.type??"stdio",f=nt.has(s),v=at.has(s),p=(M=t.permissions)==null?void 0:M.tools,A=p===void 0?"inherit":p==="allow"?"allow":p==="deny"?"deny":"list",$=Array.isArray(p)?p:[],P=(t.disabledTools??[]).join(", ");return e.jsxs("div",{className:"p-4 space-y-4 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{state:n.dotState,size:"md",title:n.label}),e.jsx(re,{tone:n.badgeTone,children:n.label}),e.jsx("button",{onClick:a,disabled:l,className:"ml-auto px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50",children:l?"checking…":"test connection"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),e.jsx("input",{defaultValue:s,onBlur:j=>c(j.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("button",{onClick:x,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),e.jsx(ne,{label:"description",value:t.description??"",onChange:j=>r({...t,description:j||void 0}),placeholder:"what this server does…"}),f?e.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:s})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):v?e.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:s})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),e.jsx("select",{value:u,onChange:j=>r({...t,type:j.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:st.map(j=>e.jsx("option",{value:j,children:j},j))}),u==="sse"?e.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),u==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"command",value:t.command??"",onChange:j=>r({...t,command:j}),placeholder:"npx / node / python …"}),e.jsx(ne,{label:"args",value:(t.args??[]).join(" "),onChange:j=>r({...t,args:j.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(je,{label:"env",value:t.env??{},onChange:j=>r({...t,env:j})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{label:"url",value:t.url??"",onChange:j=>r({...t,url:j}),placeholder:"https://…"}),e.jsx(je,{label:"headers",value:t.headers??{},onChange:j=>r({...t,headers:j})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:j=>r({...t,alwaysLoad:j.target.checked||void 0})}),e.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),e.jsx(ne,{label:"disabledTools",value:P,onChange:j=>{const k=j.split(",").map(y=>y.trim()).filter(Boolean);r({...t,disabledTools:k.length?k:void 0})},placeholder:"comma-separated tool names to hide"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("select",{value:A,onChange:j=>{const k=j.target.value,y={...t};if(k==="inherit"){if(y.permissions){const{tools:C,...R}=y.permissions;y.permissions=Object.keys(R).length?R:void 0}}else k==="list"?y.permissions={...y.permissions??{},tools:[]}:y.permissions={...y.permissions??{},tools:k};r(y)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"inherit",children:"inherit (default)"}),e.jsx("option",{value:"allow",children:"allow all tools"}),e.jsx("option",{value:"deny",children:"deny all tools"}),e.jsx("option",{value:"list",children:"allowlist…"})]}),A==="list"?e.jsx("input",{value:$.join(", "),onChange:j=>{const k=j.target.value.split(",").map(y=>y.trim()).filter(Boolean);r({...t,permissions:{...t.permissions??{},tools:k}})},placeholder:"comma-separated tool names",className:"w-full bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}):null]})]})]})}function ne({label:s,value:t,onChange:n,placeholder:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:s}),e.jsx("input",{value:t,onChange:l=>n(l.target.value),placeholder:a,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function je({label:s,value:t,onChange:n}){const[a,l]=o.useState(""),[c,r]=o.useState(""),x=Object.entries(t);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:s}),e.jsxs("div",{className:"flex-1 space-y-1",children:[x.map(([u,f])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:u,onChange:v=>{const p={...t};delete p[u],p[v.target.value]=f,n(p)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("input",{value:f,onChange:v=>n({...t,[u]:v.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:()=>{const v={...t};delete v[u],n(v)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},u)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:a,onChange:u=>l(u.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("input",{value:c,onChange:u=>r(u.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("button",{onClick:()=>{a.trim()&&(n({...t,[a.trim()]:c}),l(""),r(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}function pt({cwd:s,names:t}){const n={fileId:"settings",scope:"project",cwd:s},[a,l]=o.useState([]),[c,r]=o.useState(!1),[x,u]=o.useState(!1);o.useEffect(()=>{var P,M;let p=!0;const A=()=>window.api.claudeConfig.read(n).then(j=>{if(!p)return;const k=j.data;l(Array.isArray(k==null?void 0:k.disabledMcpjsonServers)?k.disabledMcpjsonServers:[]),r((k==null?void 0:k.enableAllProjectMcpServers)===!0)}).catch(()=>{});A();const $=(M=(P=window.api.config)==null?void 0:P.onChanged)==null?void 0:M.call(P,()=>{A()});return()=>{p=!1,$==null||$()}},[s]);const f=async(p,A)=>{u(!0);try{await window.api.claudeConfig.patch({...n,keyPath:[p],value:A})}catch($){G.error($.message||"save failed")}finally{u(!1)}},v=async(p,A)=>{const $=A?a.filter(P=>P!==p):[...new Set([...a,p])];l($),await f("disabledMcpjsonServers",$.length?$:void 0)};return e.jsxs("div",{className:"px-3 py-1 text-xs text-fg-faint border-b border-line flex flex-wrap items-center gap-x-4 gap-y-1","data-testid":"mcp-gating",children:[e.jsxs("span",{children:["Gating · ",s,"/.claude/settings.json"]}),e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox","data-testid":"mcp-enable-all",checked:c,disabled:x,onChange:p=>{r(p.target.checked),f("enableAllProjectMcpServers",p.target.checked?!0:void 0)}}),"enableAllProjectMcpServers"]}),t.map(p=>e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox","data-testid":`mcp-gate-${p}`,checked:!a.includes(p),disabled:x,onChange:A=>v(p,A.target.checked)}),p]},p))]})}function ft({columns:s,rows:t,getKey:n,onRowClick:a,activeKey:l,empty:c}){return t.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:c??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:s.map(r=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${r.className??""}`,style:r.width?{width:r.width}:void 0,children:r.header},r.key))})}),e.jsx("tbody",{children:t.map(r=>{const x=n(r),u=l===x;return e.jsx("tr",{"data-row-key":x,onClick:()=>a==null?void 0:a(r),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${u?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:s.map(f=>e.jsx("td",{className:`px-3 py-1 ${f.className??""}`,children:f.render(r)},f.key))},x)})})]})}async function Pe(s){const t=`${s}/skills`;return await window.api.config.exists(t)?t:null}async function Me(s){const{entries:t}=await we(s,{nested:!1});return t.map(n=>{const a=pe(n.text);return{id:n.name,name:a.name,description:a.description,dir:n.dir,path:n.path,body:a.body}})}function ht(s){const t=[],n=new Set;for(const a of s)for(const l of s){if(a.id===l.id)continue;const c=l.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=[`/${c}\\b`,`\`${c}\``];if(l.id.length>=4&&r.push(`\\b${c}\\b`),!r.some(f=>new RegExp(f,"i").test(a.body)))continue;const u=`${a.id}->${l.id}`;n.has(u)||(n.add(u),t.push({from:a.id,to:l.id}))}return t}const xt=o.lazy(()=>He(()=>import("./SkillReferenceGraph-C6JEdypC.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(s=>({default:s.SkillReferenceGraph})));function gt({pluginName:s,skills:t,onBack:n,initialSelectedId:a}){var v;const[l,c]=o.useState(a??((v=t[0])==null?void 0:v.id)??null),r=l?t.find(p=>p.id===l)??null:null,x=o.useMemo(()=>ht(t),[t]),[u,f]=o.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:n,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",s]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(r==null?void 0:r.name)??(r==null?void 0:r.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>f("list"),className:`px-2 py-0.5 text-xs ${u==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>f("graph"),className:`px-2 py-0.5 text-xs ${u==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[r!=null&&r.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:r.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[t.length," ",t.length===1?"skill":"skills"," · ",x.length," ",x.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.length===0?e.jsx(O,{title:"no skills in this plugin"}):u==="graph"?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(xt,{skills:t,edges:x,selectedId:l,onSelect:c})}):e.jsx(ue,{sidebar:e.jsx("div",{className:"py-1",children:t.map(p=>e.jsxs("button",{onClick:()=>c(p.id),className:`w-full px-3 py-1 text-xs text-left ${l===p.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:p.name??p.id}),p.description?e.jsx("div",{className:"truncate text-fg-faint",children:p.description}):null]},p.id))}),detail:r?e.jsx("div",{className:"h-full min-h-0",children:e.jsx($e,{path:r.path,value:r.body,onChange:()=>{},readOnly:!0})}):e.jsx(O,{title:"select a skill"})})})]})}const Ae=s=>{var t,n;return{type:"plugin",name:s.name,repository:(t=s.manifest)==null?void 0:t.repository,homepage:(n=s.manifest)==null?void 0:n.homepage}};function bt({onAdd:s}={}){const t=ie(),[n,a]=o.useState([]),[l,c]=o.useState(!0),[r,x]=o.useState(null),[u,f]=o.useState(null),[v,p]=o.useState(null),[A,$]=o.useState(new Set),P=Ne(i=>i.show),[M,j]=o.useState(null);o.useEffect(()=>{var g,K;let i=!1;return(K=(g=window.api.app).seedStatus)==null||K.call(g).then(_=>{i||p(_)}).catch(()=>{}),()=>{i=!0}},[]);const k=o.useRef(0),y=o.useRef(!1),C=o.useCallback(async()=>{var H,q;const i=++k.current;if(!t)return;y.current||c(!0);const g=`${t}/.claude/plugins/installed_plugins.json`;let K=[],_=null;try{const L=await window.api.config.readJson(g);if(L.exists&&L.parseError)_=`could not parse installed_plugins.json${L.error?`: ${L.error}`:""}`;else if(L.exists&&L.data&&typeof L.data=="object"){const z=L.data,X=[];for(const[h,b]of Object.entries(z.plugins??{})){if(!Array.isArray(b))continue;const[w,T]=h.split("@");for(const d of b)d!=null&&d.installPath&&X.push({name:w,marketplace:T,entry:d})}let Z=new Map;try{const h=await((q=(H=window.api.plugins)==null?void 0:H.list)==null?void 0:q.call(H))??[];Z=new Map(h.map(b=>[b.key,b.enabled]))}catch{}K=await $t(X,St,async({name:h,marketplace:b,entry:w})=>{var S;const T={name:h,path:w.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let d;try{d=await Et(T)}catch(E){d=Ct(T,E instanceof Error?E.message:String(E))}return(S=d.manifest)!=null&&S.version||(d.manifest={...d.manifest??{},version:w.version}),d.marketplace=b,d.scope=w.scope,d.key=b?`${h}@${b}`:h,d.enabled=Z.get(d.key)===!0,d})}}catch(L){_=`could not read installed_plugins.json: ${L instanceof Error?L.message:String(L)}`}k.current===i&&(x(_),_?G.error(`Plugins: ${_}`):(K.sort((L,z)=>L.name.localeCompare(z.name)),y.current=K.length>0,a(K)),c(!1))},[t]);o.useEffect(()=>{C()},[C]),o.useEffect(()=>()=>{k.current+=1},[]),de(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],C);const R=async i=>{if(i.key){j(i.key);try{const g=await window.api.plugins.setEnabled({key:i.key,enabled:!i.enabled});g.ok||P("error",`Could not ${i.enabled?"disable":"enable"} ${i.name}: ${g.error??"unknown error"}`)}catch(g){P("error",`Could not update ${i.name}: ${g instanceof Error?g.message:String(g)}`)}finally{j(null),await C()}}},F=async i=>{if(i.marketplace&&window.confirm(`Uninstall plugin "${i.name}"?`)){j(i.key??i.name);try{const g=await window.api.plugins.uninstall({slug:i.name,marketplaceName:i.marketplace});g.ok||P("error",`Uninstall ${i.name} failed: ${g.error??`exit ${g.exitCode}`}`)}catch(g){P("error",`Uninstall ${i.name} failed: ${g instanceof Error?g.message:String(g)}`)}finally{j(null),await C()}}},I=[{key:"enabled",header:"on",render:i=>e.jsx("button",{type:"button",role:"switch","aria-checked":i.enabled===!0,"aria-label":`${i.enabled?"Disable":"Enable"} ${i.name}`,"data-testid":"plugin-enabled-switch",disabled:!i.key||M===i.key,onClick:g=>{g.stopPropagation(),R(i)},className:`w-8 h-4 rounded-full relative transition-colors ${i.enabled?"bg-accent":"bg-bg-hi border border-line"}`,children:e.jsx("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-fg transition-all ${i.enabled?"left-4":"left-0.5"}`})}),width:"3.5rem"},{key:"name",header:"name",render:i=>{var g;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:i.name}),(g=i.manifest)!=null&&g.description?e.jsx("div",{className:"truncate text-fg-faint",title:i.manifest.description,children:i.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:i=>e.jsx(te,{interactive:!1,input:Ae(i)}),width:"7rem"},{key:"scope",header:"scope",render:i=>i.scope?e.jsx("span",{"data-testid":"plugin-scope",children:i.scope}):e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"5rem"},{key:"version",header:"version",render:i=>{var g;return((g=i.manifest)==null?void 0:g.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:i=>i.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:i=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[i.agents>0?`${i.agents} agents`:null,i.commands>0?`${i.commands} commands`:null,i.skills>0?`${i.skills} skills`:null,i.hooks>0?`${i.hooks} hooks`:null,i.monitors>0?`${i.monitors} monitors`:null,i.binCount>0?`${i.binCount} bin`:null,i.hasLsp?"lsp":null,i.hasMcp?"mcp":null,i.error?"inspection failed":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:i=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:i.path})},{key:"actions",header:"",render:i=>e.jsx("button",{type:"button","data-testid":"plugin-uninstall",disabled:!i.marketplace||M===(i.key??i.name),onClick:g=>{g.stopPropagation(),F(i)},className:"text-xs text-red-300 hover:underline disabled:opacity-40",children:"Uninstall"}),width:"5rem"}],B=o.useMemo(()=>v?Object.keys(v).filter(i=>(v[i].status==="exhausted"||v[i].status==="failed")&&!A.has(i)):[],[v,A]),W=B.length>0?e.jsx(vt,{seeders:B,seedStatus:v,onDismiss:i=>$(g=>new Set(g).add(i)),onOpenLibrary:()=>s==null?void 0:s()}):null,D=u?n.find(i=>i.path===u)??null:null;return e.jsxs(ae,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:s,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Add…"})]}),children:[W,r?e.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[r,n.length>0?" — showing the last known list":null]}):null,l&&n.length===0?e.jsx(O,{title:"scanning plugins…"}):r&&n.length===0?null:D?e.jsx(wt,{row:D,home:t,onBack:()=>f(null)},D.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ft,{columns:I,rows:n,getKey:i=>i.path,activeKey:u,onRowClick:i=>f(i.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["use Add… or run ",e.jsx("code",{children:"claude plugin install"})]})]})})})})]})}const jt=o.memo(bt),ce={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function vt({seeders:s,seedStatus:t,onDismiss:n,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:s.map(l=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:t[l].status==="failed"?`${ce[l]} setup failed — it will retry on next launch. To fix it now:`:`${ce[l]} setup failed after retrying — manual fix needed`}),l==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:t[l].fix})]}),e.jsx("button",{onClick:()=>n(l),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${ce[l]} warning`,children:"✕"})]},l))})}const yt=250,kt=["hooks/hooks.json",".mcp.json",".lsp.json","agents","skills","commands",".claude-plugin/plugin.json"];function wt({row:s,home:t,onBack:n}){var L,z,X,Z,h;const[a,l]=o.useState([]),[c,r]=o.useState([]),[x,u]=o.useState([]),[f,v]=o.useState([]),[p,A]=o.useState([]),[$,P]=o.useState("skills"),[M,j]=o.useState(null),[k,y]=o.useState(!0),[C,R]=o.useState([]),F=o.useRef(0),I=o.useRef(!1),B=o.useCallback(async()=>{if(!t)return;const b=++F.current;try{const{manifest:w}=await Te(s.path),[T,d,S]=await Promise.all([Pe(s.path),Re(s.path,w),fe(`${s.path}/bin`,{filesOnly:!0})]),E=T?await Me(T):[],[m,N]=await Promise.all([ye(d.agentFiles),ye(d.commandFiles)]),V=d.mcpServers,Q=await Promise.all([...new Set([...kt.map(U=>`${s.path}/${U}`),...d.sourcePaths])].map(async U=>await window.api.config.exists(U)?U:null));if(b!==F.current)return;l(E),r(m),u(N),v(V),A(S);const se=Q.filter(U=>U!==null);R(U=>U.join("\0")===se.join("\0")?U:se),I.current||(I.current=!0,P(E.length>0?"skills":m.length>0?"agents":N.length>0?"commands":V.length>0?"mcp":s.hooks>0?"hooks":s.monitors>0?"monitors":s.hasLsp?"lsp":"files"))}catch(w){if(b!==F.current)return;G.error(`Failed to load plugin contents: ${w instanceof Error?w.message:String(w)}`)}finally{b===F.current&&y(!1)}},[s.path,s.name,s.hooks,s.monitors,s.hasLsp,t]);o.useEffect(()=>(y(!0),B(),()=>{F.current+=1}),[B]);const W=o.useRef(null),D=o.useRef(!1),i=o.useRef(!1),g=o.useCallback(async()=>{if(D.current){i.current=!0;return}D.current=!0;try{do i.current=!1,await B();while(i.current)}finally{D.current=!1}},[B]),K=o.useCallback(()=>{W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{W.current=null,g()},yt)},[g]);o.useEffect(()=>()=>{W.current&&clearTimeout(W.current)},[]),de(C,K,{depth:0});const _=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:c.length},{key:"commands",label:"Commands",count:x.length},{key:"mcp",label:"MCP server",count:f.length},{key:"hooks",label:"Hooks",count:s.hooks},{key:"monitors",label:"Monitors",count:s.monitors},{key:"lsp",label:"LSP",count:s.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],H=(L=s.manifest)!=null&&L.author?typeof s.manifest.author=="string"?s.manifest.author:s.manifest.author.name??null:null,q=async b=>{const w=await window.api.shell.open({as:"external",url:b});w.ok||G.error(w.error??`Failed to open ${b}`)};return M?e.jsx(gt,{pluginName:((z=s.manifest)==null?void 0:z.name)??s.name,skills:a,initialSelectedId:M.id,onBack:()=>j(null)},M.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:n,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((X=s.manifest)==null?void 0:X.name)??s.name}),(Z=s.manifest)!=null&&Z.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",s.manifest.version]}):null,(h=s.manifest)!=null&&h.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:s.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(te,{input:Ae(s)}),s.hasMcp?e.jsx(re,{tone:"accent",children:"MCP"}):null]})]}),s.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[H?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),H]}):null,s.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),s.manifest.license]}):null,s.manifest.homepage?e.jsxs("button",{onClick:()=>q(s.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:s.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),s.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:s.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:s.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:_.map(b=>e.jsxs("button",{type:"button",disabled:b.count===0,onClick:()=>P(b.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${b.count===0?"text-fg-faint opacity-50 cursor-default":$===b.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:b.label}),b.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:b.count}):null]},b.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:k?e.jsx(O,{title:"scanning…"}):e.jsx(Nt,{active:$,row:s,skills:a,agents:c,commands:x,mcpServers:f,files:p,onOpenSkill:j})})]})]})}function Nt({active:s,row:t,skills:n,agents:a,commands:l,mcpServers:c,files:r,onOpenSkill:x}){return s==="skills"?n.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:n.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description,onClick:()=>x(u)},u.id))}):s==="agents"?a.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:a.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description},u.id))}):s==="commands"?l.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:l.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name??u.id,description:u.description},u.id))}):s==="mcp"?c.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:c.map((u,f)=>e.jsx(ee,{n:f+1,name:u.name,description:u.description},u.id))}):s==="hooks"?t.hooks===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:e.jsx(ee,{n:1,name:`${t.hooks} ${t.hooks===1?"hook":"hooks"} configured`,description:`${t.path}/hooks/hooks.json`})}):s==="monitors"?t.monitors===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:e.jsx(ee,{n:1,name:`${t.monitors} ${t.monitors===1?"monitor":"monitors"} configured`,description:`${t.path}/monitors/monitors.json`})}):s==="lsp"?t.hasLsp?e.jsx("div",{children:e.jsx(ee,{n:1,name:"LSP server enabled",description:`${t.path}/.lsp.json`})}):e.jsx(O,{title:"no components"}):r.length===0?e.jsx(O,{title:"no components"}):e.jsx("div",{children:r.map((u,f)=>e.jsx(ee,{n:f+1,name:u,description:null},u))})}function ee({n:s,name:t,description:n,onClick:a}){const l=a?"button":"div";return e.jsxs(l,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(s).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:t}),n?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:n}):null]})]})}const St=4;async function $t(s,t,n){const a=new Array(s.length);let l=0;const c=Array.from({length:Math.min(t,s.length)},async()=>{for(;l<s.length;){const r=l++;a[r]=await n(s[r])}});return await Promise.all(c),a}function Ct(s,t){return{name:s.name,path:s.path,mtimeMs:s.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,error:t}}async function Et(s){const{hasManifest:t,manifest:n}=await Te(s.path),[a,l]=await Promise.all([window.api.config.exists(`${s.path}/.lsp.json`),window.api.config.exists(`${s.path}/monitors/monitors.json`)]);let c=0;if(l){const p=await window.api.config.readJson(`${s.path}/monitors/monitors.json`);Array.isArray(p.data)?c=p.data.length:p.data&&typeof p.data=="object"&&Array.isArray(p.data.monitors)&&(c=p.data.monitors.length)}const[r,x,u]=await Promise.all([Re(s.path,n),fe(`${s.path}/bin`,{filesOnly:!0}),Pe(s.path)]),f=x.length,v=u?(await Me(u)).length:0;return{name:s.name,path:s.path,mtimeMs:s.mtimeMs,hasManifest:t,manifest:n,hasLsp:a,monitors:c,hooks:r.hooks,agents:r.agentFiles.length,commands:r.commandFiles.length,skills:v,binCount:f,hasMcp:r.mcpServers.length>0}}async function Te(s){let t=`${s}/.claude-plugin/plugin.json`,n=await window.api.config.exists(t);if(n||(t=`${s}/plugin.json`,n=await window.api.config.exists(t)),!n)return{hasManifest:n,manifest:null};const a=await window.api.config.readJson(t),l=a.exists&&!a.parseError&&a.data&&typeof a.data=="object"&&!Array.isArray(a.data);return{hasManifest:n,manifest:l?a.data:null}}const Y=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Pt(s,t){const n=t.startsWith("/")?t.startsWith(`${s}/`)?t.slice(s.length+1):null:t;if(n===null)return ve(t);const a=[];for(const l of n.split("/"))if(!(l===""||l===".")){if(l!=="..")a.push(l);else if(a.pop()===void 0)return ve(t)}return a.length>0?`${s}/${a.join("/")}`:s}function ve(s){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${s}`),null}function Mt(s){return typeof s=="string"?[s]:Array.isArray(s)?s.filter(t=>typeof t=="string"):[]}function At(s){if(!Y(s))return null;if(Y(s.mcpServers))return s.mcpServers;const t=Object.values(s);return t.length>0&&t.every(a=>Y(a)&&(typeof a.command=="string"||typeof a.url=="string"))?s:null}function Tt(s){if(!Y(s))return 0;const t=Y(s.hooks)?s.hooks:s;return Object.values(t).reduce((n,a)=>Array.isArray(a)?n+a.reduce((l,c)=>l+(Y(c)&&Array.isArray(c.hooks)?c.hooks.length:0),0):n,0)}async function Re(s,t){const n=(k,y)=>{const C=new Set;for(const R of Mt(k)){const F=Pt(s,R);F&&C.add(F)}return C.add(`${s}/${y}`),[...C]},a=async k=>{const y=new Set;for(const C of k)if(C.endsWith(".md"))y.add(C);else for(const R of await fe(C,{filesOnly:!0}))R.endsWith(".md")&&y.add(`${C}/${R}`);return[...y]},l=async k=>{try{const y=await window.api.config.readJson(k);return y.exists&&!y.parseError?y.data:null}catch{return null}},c=n(t==null?void 0:t.commands,"commands"),r=n(t==null?void 0:t.agents,"agents"),x=t==null?void 0:t.hooks,u=n(typeof x=="string"||Array.isArray(x)?x:void 0,"hooks/hooks.json"),f=t==null?void 0:t.mcpServers,v=n(typeof f=="string"||Array.isArray(f)?f:void 0,".mcp.json"),[p,A,$,P]=await Promise.all([a(c),a(r),Promise.all(u.map(l)),Promise.all(v.map(l))]),M=[...Y(x)?[x]:[],...$].reduce((k,y)=>k+Tt(y),0),j=new Map;for(const k of[...Y(f)?[f]:[],...P])for(const[y,C]of Object.entries(At(k)??{})){if(j.has(y))continue;const R=Y(C)?C.command:void 0,F=Y(C)?C.url:void 0;j.set(y,{id:y,name:y,description:typeof R=="string"?R:typeof F=="string"?F:null})}return{commandFiles:p,agentFiles:A,hooks:M,mcpServers:[...j.values()],sourcePaths:[...c,...r,...u,...v]}}async function ye(s){const t=await Promise.all(s.map(a=>window.api.config.readText(a))),n=[];return s.forEach((a,l)=>{if(!t[l].exists)return;const c=a.slice(a.lastIndexOf("/")+1),r=pe(t[l].text);n.push({id:a,name:r.name??c.replace(/\.md$/,""),description:r.description})}),n}async function fe(s,t){try{return(await window.api.config.listDir(s,t)).entries.map(a=>a.name)}catch{return[]}}const Rt=[{key:"skills",label:"Skills"},{key:"mcp",label:"MCP Servers"},{key:"plugins",label:"Plugins"}],Lt={skills:"Add skill",mcp:"Add MCP server",plugins:"Add plugin"};function Dt(){const s=ie(),[t,n]=o.useState("skills");De("extensions",v=>{(v==="skills"||v==="mcp"||v==="plugins")&&(n(v),l(!1))});const[a,l]=o.useState(!1),[c,r]=o.useState({scope:"user",cwd:null}),x=o.useCallback(()=>l(!1),[]),u=o.useCallback(v=>{r(v),l(!0)},[]),f=o.useCallback(()=>l(!0),[]);return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"extensions",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-1.5 border-b border-line",children:[e.jsx(Fe,{options:Rt,active:t,onChange:v=>{n(v),l(!1)}}),s&&t==="skills"&&e.jsx(le,{path:`${s}/.claude/skills`,note:"Open ~/.claude/skills/"}),s&&t==="mcp"&&e.jsx(le,{path:`${s}/.claude.json`,keyPath:["mcpServers"]}),s&&t==="plugins"&&e.jsxs(e.Fragment,{children:[e.jsx(le,{path:`${s}/.claude/plugins/installed_plugins.json`}),e.jsx(le,{path:`${s}/.claude/settings.json`,keyPath:["enabledPlugins"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[t==="skills"&&e.jsx(Xe,{onAdd:f,scope:"user"}),t==="mcp"&&e.jsx(ut,{onAdd:u,scope:"user"}),t==="plugins"&&e.jsx(jt,{onAdd:f})]}),e.jsxs(Oe,{open:a,onClose:x,title:Lt[t],keyVals:[],children:[t==="skills"&&e.jsx(Ie,{}),t==="mcp"&&e.jsx(Be,{scope:c.scope,cwd:c.cwd}),t==="plugins"&&e.jsx(We,{})]})]})}const Ut=o.memo(Dt);export{Ut as Extensions};
@@ -1,25 +0,0 @@
1
- import{aJ as i,a$ as E,at as e,a5 as K,ag as vt,aN as kt,af as Nt,L as wt,b9 as jt,b0 as Ct,l as St}from"./index-CuAfFXNd.js";import{V as $t}from"./VoiceButton-C3NLotUZ.js";import"./monaco-editor-BsIlgG7c.js";function Mt(s){return!s||!s.trim()?"default":s.replace(/[^a-zA-Z0-9]/g,"-")}const De=["bg-accent","bg-sage-dark","bg-honey","bg-fg-dim","bg-fg-faint","bg-hive-teal","bg-butter","bg-delta-bad"],Ge=864e5,Et="MEMORY.md",Ie=2e3,we=s=>s.replace(/\.md$/,"");function At(s,t,n,l){var v,k,f;const x=new Map(((t==null?void 0:t.entries)??[]).map(o=>[o.name,o])),a=new Set(((v=t==null?void 0:t.index)==null?void 0:v.orphans)??[]),p=new Map;for(const o of(n==null?void 0:n.clusters)??[])for(const b of o.memberSlugs)p.has(b)||p.set(b,o.id);const m=s.filter(o=>o.name!==Et),c=new Map;for(const o of m){const b=we(o.name),u=((k=x.get(o.name))==null?void 0:k.outLinks)??((f=x.get(b))==null?void 0:f.outLinks)??[];for(const j of u){const M=we(j),y=c.get(M)??[];y.includes(b)||y.push(b),c.set(M,y)}}return m.map(o=>{const b=we(o.name),u=x.get(o.name)??x.get(b),j=(u==null?void 0:u.deadRefs)??[],M=(u==null?void 0:u.danglingLinks)??[],y=(u==null?void 0:u.stale)??!1;return{name:o.name,slug:b,path:o.path,description:(u==null?void 0:u.description)??"",bytes:o.bytes,mtimeMs:o.mtimeMs,ageDays:Math.floor((l-o.mtimeMs)/Ge),stale:y,staleReasons:(u==null?void 0:u.reasons)??[],ageOnlyStale:y&&j.length===0,deadRefs:j,broken:j.length>0||M.length>0,danglingLinks:M,outLinks:(u==null?void 0:u.outLinks)??[],inLinks:c.get(b)??[],notIndexed:a.has(o.name)||a.has(b),clusterId:p.get(b)??null,type:(u==null?void 0:u.type)??null,originSessionId:(u==null?void 0:u.originSessionId)??null}})}function Lt(s,t){const n=new Set(t.filter(l=>l.stale).map(l=>l.slug));return((s==null?void 0:s.clusters)??[]).map((l,x)=>({id:l.id,name:l.name,summary:l.summary,memberSlugs:l.memberSlugs,linkCount:l.links.length,retireCount:l.links.filter(a=>/retire/i.test(a.label??"")).length,staleCount:l.memberSlugs.filter(a=>n.has(a)).length,dotClass:De[x%De.length]}))}function Ye(s,t,n){const l=t.trim().toLowerCase(),x=l?s.filter(a=>a.slug.toLowerCase().includes(l)||a.description.toLowerCase().includes(l)):s;return n===void 0?x:x.slice(0,n)}function de(s,t,n){let l;return t==="ask"||t==="clusters"||t==="archived"?[]:(t==="all"?l=s:t==="stale"?l=s.filter(x=>x.stale):t==="broken"?l=s.filter(x=>x.broken):t==="recent"?l=s.filter(x=>Date.now()-x.mtimeMs<=7*Ge):t==="unindexed"?l=s.filter(x=>x.notIndexed):t==="cluster:unclustered"?l=s.filter(x=>x.clusterId===null):t.startsWith("cluster:")?l=s.filter(x=>x.clusterId===t.slice(8)):l=s,Ye(l,n))}function qe(s,t){const n=[...s];return t==="recent"?n.sort((l,x)=>x.mtimeMs-l.mtimeMs):t==="name"?n.sort((l,x)=>l.slug<x.slug?-1:l.slug>x.slug?1:0):n.sort((l,x)=>x.bytes-l.bytes),n}function Rt(s){return{all:s.length,stale:de(s,"stale","").length,broken:de(s,"broken","").length,recent:de(s,"recent","").length,unindexed:de(s,"unindexed","").length}}function Xe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"untitled_memory"}function Dt(s,t){const n=s===""?[]:s.split(`
2
- `),l=t===""?[]:t.split(`
3
- `);if(n.length>Ie||l.length>Ie)return[...n.map(k=>({sign:"−",text:k})),...l.map(k=>({sign:"+",text:k}))];const x=n.length,a=l.length,p=Array.from({length:x+1},()=>new Array(a+1).fill(0));for(let k=x-1;k>=0;k--)for(let f=a-1;f>=0;f--)p[k][f]=n[k]===l[f]?p[k+1][f+1]+1:Math.max(p[k+1][f],p[k][f+1]);const m=[];let c=0,v=0;for(;c<x&&v<a;)n[c]===l[v]?(c++,v++):p[c+1][v]>=p[c][v+1]?m.push({sign:"−",text:n[c++]}):m.push({sign:"+",text:l[v++]});for(;c<x;)m.push({sign:"−",text:n[c++]});for(;v<a;)m.push({sign:"+",text:l[v++]});return m}const F=s=>s instanceof Error?s.message:String(s);function Te(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return t?{front:t[0],body:s.slice(t[0].length)}:{front:"",body:s}}function It(s){return s.split(`
4
- `).map(t=>t.trim()).find(t=>t.length>0)??""}function Tt(s,t){const n=s.kind==="agent"?s.agent:null,l=n?`${n.name}|${n.memoryScope??""}`:"",x=n!==null&&n.memoryScope===null,a=i.useMemo(()=>x?null:n&&n.memoryScope?{agent:{name:n.name,scope:n.memoryScope},...t?{cwd:t}:{}}:{workspace:Mt(t),...t?{cwd:t}:{}},[l,x,t]),p=n===null,[m,c]=i.useState(!0),[v,k]=i.useState([]),[f,o]=i.useState(null),[b,u]=i.useState(null),[j,M]=i.useState(!1),[y,C]=i.useState(""),[I,W]=i.useState(!0),[ee,xe]=i.useState([]),[q,A]=i.useState([]),[U,L]=i.useState({}),[me,ye]=i.useState(()=>Date.now()),X=i.useRef(a);X.current=a;const T=i.useCallback(async()=>{if(!a){k([]),o(null),u(null),xe([]),C(""),c(!1);return}try{const h=await window.api.memory.list(a);if(X.current!==a)return;k(h.entries??[]),C(h.dir??""),W(h.autoMemoryEnabled!==!1),h.error&&E.error(`Memory list failed: ${h.error}`);const[d,N]=await Promise.all([window.api.memory.stale(a).catch(w=>(E.error(`Memory staleness check failed: ${F(w)}`),null)),window.api.memory.listArchived(a).catch(()=>({names:[],error:null}))]);if(X.current!==a)return;o(d),xe(N.names??[]),ye(Date.now())}catch(h){E.error(`Memory list failed: ${F(h)}`)}finally{c(!1)}},[a]);i.useEffect(()=>{c(!0),u(null),T(),a&&p&&a.workspace&&window.api.memory.aggregate(a.workspace,!1,t??void 0).then(h=>{X.current===a&&u(h)}).catch(h=>E.error(`Memory clusters failed: ${F(h)}`))},[T]),i.useEffect(()=>{let h=!1;return(async()=>{try{const{agents:d}=await window.api.memory.agents(t??void 0);if(h)return;A(d);const N={};await Promise.all(d.filter(w=>w.memoryScope).map(async w=>{const G=await window.api.memory.list({agent:{name:w.name,scope:w.memoryScope},...t?{cwd:t}:{}});N[w.name]=(G.entries??[]).filter(O=>O.name!=="MEMORY.md").length})),h||L(N)}catch(d){h||E.error(`Memory agents failed: ${F(d)}`)}})(),()=>{h=!0}},[t]),i.useEffect(()=>{if(!y)return;const h=y;window.api.config.watch([h]);const d=window.api.config.onChanged(({path:N})=>{(N===h||N.startsWith(h+"/"))&&T()});return()=>{d(),window.api.config.unwatch([h])}},[y,T]);const _=i.useMemo(()=>At(v,f,b,me),[v,f,b,me]),te=i.useMemo(()=>Lt(b,_),[b,_]),ve=i.useMemo(()=>({generatedAt:(b==null?void 0:b.generatedAt)??null,running:j}),[b,j]),R=i.useCallback(async h=>{if(!a)return null;try{const d=await window.api.memory.read(h,a);return d.error?(E.error(`Memory read failed: ${d.error}`),null):d.content}catch(d){return E.error(`Memory read failed: ${F(d)}`),null}},[a]),$=i.useCallback(async(h,d)=>{try{const N=await d();return N.ok?(await T(),!0):(E.error(`${h} failed: ${N.error??"unknown error"}`),!1)}catch(N){return E.error(`${h} failed: ${F(N)}`),!1}},[T]),Q=i.useCallback(async(h,d)=>{if(!a)return!1;const N=await R(h);if(N===null)return!1;const{front:w}=Te(N);return $("Memory save",()=>window.api.memory.write(h,w+d,a))},[a,R,$]),V=i.useCallback(async(h,d)=>{if(!a)return null;const N=Xe(h),w=It(d);if(!await $("Memory create",()=>window.api.memory.create(N,w,a)))return null;const O=`---
5
- name: ${N}
6
- description: ${w}
7
- ---
8
-
9
- ${d}
10
- `;return await $("Memory create",()=>window.api.memory.write(N,O,a))?N:null},[a,$]),H=i.useCallback(async h=>{var G,O;if(!a)return null;const d=await R(h);if(d===null||!await $("Memory delete",()=>window.api.memory.delete(h,a)))return null;const w=((O=(G=Te(d).front.match(/^description:\s*(.*)$/m))==null?void 0:G[1])==null?void 0:O.trim())??"";return async()=>{await $("Memory undo",()=>window.api.memory.create(h,w,a))&&await $("Memory undo",()=>window.api.memory.write(h,d,a))}},[a,R,$]),ue=i.useCallback(h=>a?$("Memory archive",()=>window.api.memory.archive(h,a)):Promise.resolve(!1),[a,$]),se=i.useCallback(h=>a?$("Memory restore",()=>window.api.memory.restore(h,a)):Promise.resolve(!1),[a,$]),ne=i.useCallback(h=>a?$("Memory verify",()=>window.api.memory.verify(h,a)):Promise.resolve(!1),[a,$]),re=i.useCallback(async(h,d)=>{if(!a)return!1;const N=await R(h);if(N===null)return!1;const w=N.split(`[[${d}]]`).join(d);return $("Memory link removal",()=>window.api.memory.write(h,w,a))},[a,R,$]),Z=i.useCallback(async()=>{if(!(!a||!p||!a.workspace)){M(!0);try{const h=await window.api.memory.aggregate(a.workspace,!0,t??void 0);h.error?E.error(`Memory clustering failed: ${h.error}`):u(h)}catch(h){E.error(`Memory clustering failed: ${F(h)}`)}finally{M(!1)}}},[a,p,t]),pe=i.useCallback(async(h,d)=>{const N=w=>({ok:!1,answer:"",citations:[],error:w});if(!a)return N("no memory store");try{const w=await window.api.memory.ask({question:h,target:a,contextName:d});return w.ok||E.error(`Memory ask failed: ${w.error??"unknown error"}`),w}catch(w){return E.error(`Memory ask failed: ${F(w)}`),N(F(w))}},[a]),z=i.useCallback(async h=>{const d=N=>({ok:!1,action:"keep",summary:"",reason:"",content:"",fold:null,error:N});if(!a)return d("no memory store");try{const N=await window.api.memory.proposeFix({name:h,target:a});return N.ok||E.error(`Memory fix failed: ${N.error??"unknown error"}`),N}catch(N){return E.error(`Memory fix failed: ${F(N)}`),d(F(N))}},[a]),ae=i.useMemo(()=>({refresh:T,read:R,saveBody:Q,create:V,remove:H,archive:ue,restore:se,verify:ne,removeLink:re,regenerateClusters:Z,ask:pe,proposeFix:z}),[T,R,Q,V,H,ue,se,ne,re,Z,pe,z]);return{loading:m,target:a,dir:y,autoMemoryEnabled:I,rows:_,clusters:te,clustersMeta:ve,index:f==null?void 0:f.index,archived:ee,agents:q,agentCounts:U,actions:ae}}const _t={user:"user — all projects",project:"project — shared via git",local:"local — this machine only"},J="text-[10px] tracking-[.08em] font-semibold text-fg-faint",Qe="flex items-center gap-2 h-7 px-2.5 rounded-[5px] text-[13px] cursor-pointer hover:bg-muteband text-left w-full";function _e(s,t){return s.memoryScope===null?"off":String(t[s.name]??0)}function je({id:s,label:t,count:n,dot:l,active:x,mono:a,onClick:p,check:m}){return e.jsxs("button",{type:"button","data-testid":`mx-nav-${s}`,onClick:p,className:`${Qe} ${x?"bg-bg font-semibold text-fg":"text-fg-dim"}`,children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-sm shrink-0 ${l||"bg-transparent"}`}),e.jsx("span",{className:`flex-1 min-w-0 truncate ${a?"font-mono text-xs":""}`,children:t}),n!==void 0&&e.jsx("span",{className:`font-mono text-[11px] ${m&&n===0?"text-sage-dark":x?"text-fg":"text-fg-faint"}`,children:m&&n===0?"✓":n})]})}function Oe({label:s,value:t,max:n,tone:l}){const x=Math.min(100,Math.round(t/Math.max(1,n)*100));return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:[s," ",t,"/",n]}),e.jsx("div",{className:"h-1 rounded-full bg-bg-muteband overflow-hidden",children:e.jsx("div",{className:`h-full ${l}`,style:{width:`${x}%`}})})]})}const Ot=i.memo(function(t){var k,f;const[n,l]=i.useState(!1),x=i.useRef(null),a=t.scope.kind==="agent";i.useEffect(()=>{if(!n)return;const o=u=>{u.key==="Escape"&&l(!1)},b=u=>{x.current&&!x.current.contains(u.target)&&l(!1)};return document.addEventListener("keydown",o),document.addEventListener("mousedown",b),()=>{document.removeEventListener("keydown",o),document.removeEventListener("mousedown",b)}},[n]);const p=o=>{l(!1),t.onScope(o)},m=(o,b,u,j,M)=>e.jsx(je,{id:o,label:b,dot:u,count:j,check:M,active:t.view===o,onClick:()=>t.onView(o)}),c=t.scope.kind==="agent"?t.scope.agent:null,v=(k=t.index)!=null&&k.overBudget?"bg-accent":(f=t.index)!=null&&f.nearBudget?"bg-honey":"bg-sage-dark";return e.jsxs("nav",{"data-testid":"mx-nav",className:"w-[232px] shrink-0 flex flex-col gap-4 bg-bg-elev border-r border-rule-structural px-2.5 py-3.5 overflow-y-auto",children:[e.jsxs("div",{ref:x,className:"relative",children:[e.jsxs("button",{type:"button","data-testid":"mx-scope-card",onClick:()=>l(o=>!o),className:"w-full flex flex-col gap-0.5 px-2.5 py-2 border border-rule-structural rounded-md bg-bg cursor-pointer text-left hover:border-fg-faint",children:[e.jsx("span",{className:J,children:c?"SUBAGENT":"WORKSPACE"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-xs text-fg flex-1 min-w-0 truncate",children:c?c.name:t.workspaceName}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"▾"})]}),e.jsx("span",{className:"font-mono text-[10px] text-fg-faint truncate",children:c?c.agentFile:t.workspacePath}),c&&c.memoryScope&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:_t[c.memoryScope]})]}),n&&e.jsxs("div",{"data-testid":"mx-scope-menu",className:`absolute left-0 right-0 top-full mt-1 ${K.dialog} bg-bg-hi border border-rule-structural rounded-[7px] shadow-lg p-1 flex flex-col`,children:[e.jsxs("button",{type:"button",onClick:()=>p({kind:"workspace"}),className:"flex items-center gap-2 px-2 py-1.5 rounded-[5px] text-left hover:bg-bg-elev",children:[e.jsx("span",{className:"w-3 text-[11px] text-sage-dark",children:c?"":"✓"}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs text-fg truncate",children:t.workspaceName}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:"workspace"})]}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:t.workspaceCount})]}),t.agents.map(o=>e.jsxs("button",{type:"button",onClick:()=>p({kind:"agent",agent:o}),className:"flex items-center gap-2 px-2 py-1.5 rounded-[5px] text-left hover:bg-bg-elev",children:[e.jsx("span",{className:"w-3 text-[11px] text-sage-dark",children:(c==null?void 0:c.name)===o.name?"✓":""}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs text-fg truncate",children:o.name}),e.jsxs("span",{className:"text-[10.5px] text-fg-faint",children:["subagent",o.memoryScope?` · ${o.memoryScope}`:""]})]}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:_e(o,t.agentCounts)})]},o.name))]})]}),e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"BROWSE"}),m("all","All memories","",t.counts.all),m("ask","Ask",""),m("clusters","Clusters","",t.clusters.length)]}),e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"REVIEW"}),m("stale","Stale","bg-honey",t.counts.stale,!0),m("broken","Broken references","bg-accent",t.counts.broken,!0),m("recent","Changed this week","",t.counts.recent),m("unindexed","Not in index","",t.counts.unindexed,!0),t.archivedCount>0&&m("archived","Archived","",t.archivedCount)]}),!a&&e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"CLUSTERS"}),t.clusters.map(o=>e.jsx(je,{id:`cluster:${o.id}`,label:o.name,dot:o.dotClass,count:t.clusterCounts[o.id]??0,active:t.view===`cluster:${o.id}`,onClick:()=>t.onView(`cluster:${o.id}`)},o.id)),t.unclusteredCount>0&&e.jsx(je,{id:"cluster:unclustered",label:"Unclustered",dot:"bg-rule",count:t.unclusteredCount,active:t.view==="cluster:unclustered",onClick:()=>t.onView("cluster:unclustered")})]}),t.agents.length>0&&e.jsxs("div",{className:"flex flex-col gap-px",children:[e.jsx("div",{className:`px-2.5 pb-1.5 ${J}`,children:"SUBAGENT SCOPES"}),t.agents.map(o=>e.jsxs("button",{type:"button","data-testid":`mx-nav-agent:${o.name}`,onClick:()=>t.onScope({kind:"agent",agent:o}),className:`${Qe} text-fg-dim ${(c==null?void 0:c.name)===o.name?"bg-bg font-semibold":""}`,children:[e.jsx("span",{className:"font-mono text-xs flex-1 truncate",children:o.name}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint",children:_e(o,t.agentCounts)})]},o.name))]}),t.index&&e.jsxs("div",{"data-testid":"mx-index-footer",className:"mt-auto flex flex-col gap-1.5 pt-3 border-t border-rule-inner",children:[e.jsx("span",{className:J,children:"MEMORY.md"}),e.jsx(Oe,{label:"lines",value:t.index.lines,max:t.index.maxLines,tone:v}),e.jsx(Oe,{label:"KB",value:Math.round(t.index.bytes/1024),max:Math.round(t.index.maxBytes/1024),tone:v}),t.index.dangling.length>0&&e.jsxs("span",{className:"text-[10.5px] text-accent-dark",children:[t.index.dangling.length," index lines point at missing files"]})]})]})}),Ft={recent:"name",name:"size",size:"recent"},Bt={recent:"Recent",name:"Name",size:"Size"},Ce="text-[9.5px] font-semibold tracking-[.06em] px-[5px] py-px rounded-[3px]";function Pt(s){return`${vt(s.bytes)} · ${s.ageDays>0?`${s.ageDays}d ago`:"just now"}`}const Kt=i.memo(function(t){return e.jsxs("div",{"data-testid":"mx-list",className:"flex flex-col min-h-0 border-r border-rule-structural",children:[e.jsxs("div",{className:"flex flex-col gap-[10px] px-[14px] pt-[14px] pb-[10px] border-b border-rule-structural",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:t.title}),e.jsx("span",{className:"text-[12px] text-fg-dim",children:t.rows.length}),e.jsx("span",{className:"flex-1"}),e.jsx("button",{type:"button","data-testid":"mx-list-new",onClick:t.onNew,className:"text-[12px] font-medium h-[26px] px-[10px] border border-rule-structural rounded-[5px] bg-bg-hi text-fg flex-none hover:border-fg",children:"+ New"})]}),e.jsxs("div",{className:"flex gap-[6px] items-center",children:[e.jsx("input",{"data-testid":"mx-list-filter",value:t.query,onChange:n=>t.onQuery(n.target.value),placeholder:"Filter by name or content…",className:"flex-1 min-w-0 h-7 border border-rule-structural rounded-[5px] px-[9px] text-[12px] text-fg bg-bg-hi outline-none"}),e.jsx("button",{type:"button","data-testid":"mx-list-sort",onClick:()=>t.onSort(Ft[t.sort]),className:"h-7 px-[9px] border border-rule-structural rounded-[5px] flex items-center text-[12px] text-fg whitespace-nowrap hover:border-fg-faint",children:`${Bt[t.sort]} ⇅`})]})]}),e.jsxs("div",{className:"overflow-auto flex-1 p-[6px]",children:[t.rows.map(n=>e.jsxs("div",{"data-testid":`mx-list-row-${n.name}`,onClick:()=>t.onSelect(n.name),className:`px-[10px] py-2 rounded-md cursor-pointer flex flex-col gap-[3px] hover:bg-bg-elev ${t.selected===n.name?"bg-muteband":""}`,children:[e.jsxs("div",{className:"flex items-center gap-[7px]",children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-[2px] flex-none ${t.clusterDot(n.clusterId)}`}),e.jsx("span",{className:"text-[13px] font-medium flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:n.slug}),n.stale&&e.jsx("span",{className:`${Ce} bg-butter/40 text-honey-dark`,children:"STALE"}),n.broken&&!n.stale&&e.jsx("span",{className:`${Ce} bg-accent-muted/30 text-accent-dark`,children:"BROKEN"}),n.notIndexed&&e.jsx("span",{className:`${Ce} bg-rule-inner text-fg-dim`,children:"NOT INDEXED"})]}),e.jsx("div",{className:"text-[11.5px] text-fg-dim pl-[14px] overflow-hidden text-ellipsis whitespace-nowrap",children:n.description}),e.jsx("div",{className:"font-mono text-[10.5px] text-fg-dim pl-[14px]",children:Pt(n)})]},n.name)),t.empty&&t.rows.length===0&&e.jsxs("div",{"data-testid":"mx-list-empty",className:"px-[18px] py-10 flex flex-col gap-2 items-start",children:[e.jsx("span",{className:"font-serif text-[17px] text-fg",children:t.empty.title}),e.jsx("span",{className:"text-[12.5px] leading-normal text-fg-dim",children:t.empty.body}),e.jsx("button",{type:"button",onClick:t.empty.onAction,className:"mt-[6px] text-[12px] font-medium h-7 px-3 border border-rule-structural rounded-[5px] bg-bg-hi text-fg",children:t.empty.action})]})]})]})}),Se="text-xs font-medium h-[26px] px-2.5 border border-rule-structural rounded-[5px] bg-bg text-fg hover:border-fg",ge="px-[7px] py-0.5 rounded bg-bg-elev",be="px-2.5 py-[7px] rounded-[5px] text-left text-[12.5px] hover:bg-bg-elev",Wt="max-w-[640px] text-sm leading-[1.65] text-fg flex flex-col gap-3 [&_p]:m-0 [&_h4]:mt-1.5 [&_h4]:mb-0 [&_h4]:text-[11px] [&_h4]:tracking-[.08em] [&_h4]:font-semibold [&_h4]:text-accent [&_code]:font-mono [&_code]:text-[12.5px] [&_code]:bg-bg-elev [&_code]:px-1 [&_code]:rounded-[3px] [&_ul]:m-0 [&_ul]:pl-5 [&_ul]:list-disc [&_ol]:m-0 [&_ol]:pl-5 [&_ol]:list-decimal",Fe={update:{apply:"Apply",hint:"Writes the file"},delete:{apply:"Archive",hint:"Moves to .archive — undoable"},keep:{apply:"Mark verified",hint:"Touches the file, clears age staleness"},fold:{apply:"Copy for an Epic",hint:"Memory stays until the doc change lands"}};function Ut(s){var t;return s.action==="delete"?"Suggested: archive this memory":s.action==="fold"?`Suggested: move into ${((t=s.fold)==null?void 0:t.target)??"a doc"}`:s.action==="keep"?"Looks accurate — keep":"Suggested update"}function Vt(s){return s<1024?`${s} B`:`${(s/1024).toFixed(1)} KB`}function Ht(s){return s<=0?"just now":`${s}d ago`}function zt(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return(t?s.slice(t[0].length):s).trim()}function Gt(s){return s.replace(/^\*\*Why:\*\*[ \t]*/gim,`#### WHY
11
-
12
- `).replace(/^\*\*How to apply:\*\*[ \t]*/gim,`#### HOW TO APPLY
13
-
14
- `)}const Yt=i.memo(function(t){const{row:n,fix:l}=t,[x,a]=i.useState(!1),p=i.useMemo(()=>t.content===null||t.mode!=="read"?"":kt(Gt(zt(t.content))),[t.content,t.mode]),m=c=>()=>{a(!1),c()};return e.jsxs("div",{"data-testid":"mx-reader",className:"flex flex-col flex-1 min-w-0 min-h-0",children:[e.jsxs("div",{className:"px-[22px] pt-3.5 pb-3 border-b border-rule-structural flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-sm ${t.clusterDot}`}),e.jsx("span",{children:t.clusterName}),e.jsx("span",{className:"flex-1"}),!t.archived&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex border border-rule-structural rounded-[5px] overflow-hidden",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-mode-read",onClick:()=>t.onMode("read"),className:`px-2.5 py-[3px] text-fg ${t.mode==="read"?"bg-muteband":""}`,children:"Read"}),e.jsx("button",{type:"button","data-testid":"mx-reader-mode-source",onClick:()=>t.onMode("source"),className:`px-2.5 py-[3px] text-fg border-l border-rule-structural ${t.mode==="source"?"bg-muteband":""}`,children:"Source"})]}),e.jsx("button",{type:"button","data-testid":"mx-reader-edit",onClick:t.onEdit,className:Se,children:"Edit"}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-more",onClick:()=>a(c=>!c),className:`${Se} !px-2`,children:"⋯"}),x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`fixed inset-0 ${K.dialog}`,onClick:()=>a(!1)}),e.jsxs("div",{className:`absolute right-0 top-8 w-[200px] ${K.dialog} bg-bg-hi border border-rule-structural rounded-[7px] shadow-lg p-1 flex flex-col text-fg`,children:[e.jsx("button",{type:"button",className:be,onClick:m(t.onCopyPath),children:"Copy path"}),e.jsx("button",{type:"button",className:be,onClick:m(t.onReveal),children:"Reveal in folder"}),e.jsx("div",{className:"h-px bg-rule-inner mx-1.5 my-1"}),e.jsx("button",{type:"button",className:be,onClick:m(t.onArchive),children:"Archive"}),e.jsx("button",{type:"button",className:`${be} text-accent`,onClick:m(t.onAskDelete),children:"Delete…"})]})]})]})]})]}),e.jsx("div",{className:"font-mono text-[18px] font-medium text-fg break-all",children:n.slug}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[11.5px] text-fg-dim",children:[n.type&&e.jsxs("span",{className:ge,children:["type · ",n.type]}),e.jsx("span",{className:ge,children:Vt(n.bytes)}),e.jsxs("span",{className:ge,children:["modified ",Ht(n.ageDays)]}),n.originSessionId&&e.jsxs("span",{className:`${ge} font-mono text-[10.5px]`,children:["session ",n.originSessionId.slice(0,8)]})]})]}),!t.archived&&!n.stale&&l.state==="idle"&&e.jsxs("div",{className:"mx-[22px] mt-3 flex items-center gap-2 text-[11px] text-fg-dim",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-fix",onClick:t.onFix,className:"text-xs font-medium h-[26px] px-2.5 rounded-[5px] border border-rule-structural text-fg hover:border-fg",children:"Review with assistant"}),e.jsx("span",{children:"uses Claude"})]}),t.archived&&e.jsxs("div",{className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-bg-elev flex items-center gap-2.5 text-[12.5px] text-fg-dim",children:[e.jsx("span",{className:"flex-1",children:"Archived — read-only. Claude no longer loads this memory."}),e.jsx("button",{type:"button","data-testid":"mx-reader-restore",onClick:t.onRestore,className:Se,children:"Restore"})]}),!t.archived&&n.stale&&l.state==="idle"&&e.jsxs("div",{"data-testid":"mx-reader-stale",className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-butter/40 text-honey-dark flex gap-2.5 items-center text-[12.5px]",children:[e.jsxs("div",{className:"flex-1 flex flex-col gap-0.5",children:[e.jsx("b",{className:"font-semibold",children:t.appliedStill?`Applied — still flagged: ${n.staleReasons[0]??"needs review"}`:`Stale — ${n.staleReasons[0]??"needs review"}`}),n.deadRefs.length>0&&e.jsx("span",{className:"font-mono text-[11px]",children:n.deadRefs.join(" · ")})]}),e.jsx("span",{className:"text-[11px]",children:"uses Claude"}),e.jsx("button",{type:"button","data-testid":"mx-reader-fix",onClick:t.onFix,className:"text-xs font-medium h-[26px] px-2.5 rounded-[5px] bg-fg text-bg",children:"Fix with assistant"}),n.ageOnlyStale&&e.jsx("button",{type:"button","data-testid":"mx-reader-verify",onClick:t.onVerify,className:"text-xs font-medium h-[26px] px-2.5 rounded-[5px] border border-honey text-honey-dark",children:"Mark verified"})]}),!t.archived&&l.state==="checking"&&e.jsxs("div",{className:"mx-[22px] mt-3 p-3 rounded-md border border-dashed border-honey bg-butter/20 text-[12.5px] text-honey-dark flex items-center gap-2.5",children:[e.jsx("span",{className:"font-mono text-accent",children:"●○○"}),"Assistant is checking ",n.deadRefs.length>0?`${n.deadRefs.length} references`:"this memory"," against the repo…"]}),!t.archived&&l.state==="proposed"&&e.jsxs("div",{className:"mx-[22px] mt-3 border border-honey rounded-md overflow-hidden bg-bg-hi",children:[e.jsx("div",{className:"px-3 py-[9px] bg-butter/40 text-[12.5px] text-honey-dark font-semibold",children:Ut(l)}),e.jsxs("div",{className:"px-3 py-2 text-[12.5px] text-fg flex flex-col gap-0.5",children:[e.jsx("span",{"data-testid":"mx-reader-summary",children:l.summary}),l.reason&&e.jsx("span",{"data-testid":"mx-reader-reason",className:"text-fg-dim",children:l.reason})]}),l.action==="fold"&&l.fold&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-1.5 border-t border-rule-inner text-[11.5px] text-fg-dim font-mono break-all",children:[l.fold.target," · ",l.fold.anchor||"append at end"]}),l.fold.insert.split(`
15
- `).map((c,v)=>e.jsxs("div",{className:"grid grid-cols-[20px_1fr] px-3 py-1.5 font-mono text-xs leading-normal border-t border-rule-inner bg-sage/20 text-sage-dark",children:[e.jsx("span",{children:"+"}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:c})]},v))]}),l.action==="update"&&l.diff.map((c,v)=>e.jsxs("div",{className:`grid grid-cols-[20px_1fr] px-3 py-1.5 font-mono text-xs leading-normal border-t border-rule-inner ${c.sign==="−"?"bg-accent-muted/30 text-accent-dark":c.sign==="+"?"bg-sage/20 text-sage-dark":"text-fg-dim"}`,children:[e.jsx("span",{children:c.sign}),e.jsx("span",{className:"whitespace-pre-wrap break-words",children:c.text})]},v)),e.jsxs("div",{className:"flex gap-2 px-3 py-2.5 border-t border-rule-structural items-center",children:[e.jsx("button",{type:"button","data-testid":"mx-reader-apply",onClick:t.onApplyFix,className:"text-xs font-medium h-7 px-3 rounded-[5px] bg-fg text-bg",children:Fe[l.action].apply}),e.jsx("button",{type:"button","data-testid":"mx-reader-discard",onClick:t.onDiscardFix,className:"text-xs font-medium h-7 px-3 rounded-[5px] border border-rule text-fg",children:"Discard"}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-[11.5px] text-fg-dim",children:Fe[l.action].hint})]})]}),n.broken&&!n.stale&&e.jsx("div",{className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-accent-muted/30 text-[12.5px] text-accent-dark",children:"Broken reference — a link or path in this memory points at nothing. See the red items in Links."}),n.notIndexed&&e.jsx("div",{className:"mx-[22px] mt-3 px-3 py-2.5 rounded-md bg-butter/40 text-[12.5px] text-honey-dark",children:"Claude won't load this — it has no line in MEMORY.md."}),e.jsx("div",{className:"flex-1 overflow-auto px-[22px] pt-4 pb-[22px]",children:t.content===null?e.jsx("div",{className:"text-xs text-fg-faint",children:"Loading…"}):t.mode==="source"?e.jsx("pre",{className:"m-0 px-4 py-3.5 bg-fg text-bg-elev rounded-md font-mono text-xs leading-[1.7] whitespace-pre-wrap",children:t.content}):e.jsxs("div",{className:Wt,children:[n.description&&e.jsx("p",{className:"font-serif text-[17px] leading-normal text-fg",children:n.description}),e.jsx("div",{className:"contents",dangerouslySetInnerHTML:{__html:p}})]})}),e.jsx("div",{className:"px-[22px] py-2 border-t border-rule-structural font-mono text-[10.5px] text-fg-dim whitespace-nowrap overflow-hidden text-ellipsis",children:n.path})]})});function qt({mode:s,name:t,title:n,onTitle:l,body:x,onBody:a,onSave:p,onCancel:m,saving:c,dirty:v}){if(s==="none")return e.jsxs("div",{"data-testid":"mx-editor-none",className:"flex-1 flex flex-col items-center justify-center text-center gap-1.5 p-10",children:[e.jsx("div",{className:"font-serif text-[18px] text-fg",children:"No memory selected"}),e.jsx("div",{className:"text-[13px] text-fg-dim",children:"Pick one from the list, or press /."})]});const k=c||s==="edit"&&!v,f=o=>{(o.metaKey||o.ctrlKey)&&o.key.toLowerCase()==="s"?(o.preventDefault(),k||p()):o.key==="Escape"&&(o.preventDefault(),m())};return e.jsxs("div",{"data-testid":"mx-editor",className:"flex-1 min-h-0 flex flex-col",onKeyDown:f,children:[e.jsxs("div",{className:"flex items-center gap-2 px-[22px] pt-3.5 pb-3 border-b border-rule-structural",children:[e.jsx("h2",{className:"flex-1 min-w-0 truncate font-mono text-[15px] font-medium text-fg",children:s==="new"?"New memory":`Editing ${t??""}`}),e.jsx("button",{type:"button","data-testid":"mx-editor-cancel",onClick:m,className:"h-7 px-3 rounded-[5px] border border-rule-structural bg-bg text-xs font-medium text-fg",children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"mx-editor-save",disabled:k,onClick:p,className:"h-7 px-3.5 rounded-[5px] bg-accent text-white text-xs font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:"Save"})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col gap-2.5 px-[22px] py-4",children:[s==="new"&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{htmlFor:"mx-editor-name",className:"text-[11px] tracking-[.06em] font-semibold text-fg-faint",children:"NAME"}),e.jsx("input",{id:"mx-editor-name","data-testid":"mx-editor-name",value:n,onChange:o=>l(o.target.value),placeholder:"e.g. deploy freeze fridays",className:"h-8 px-2.5 rounded-[5px] border border-rule bg-bg-hi font-mono text-[13px] font-normal text-fg outline-none"}),n.trim()!==""&&e.jsxs("div",{className:"font-mono text-[11px] text-fg-faint",children:["→ ",Xe(n),".md"]})]}),e.jsx("textarea",{"data-testid":"mx-editor-body",value:x,onChange:o=>a(o.target.value),spellCheck:!1,className:"flex-1 min-h-0 w-full resize-none px-3.5 py-3 rounded-md border border-rule bg-bg-hi font-mono text-[13px] leading-[1.7] text-fg outline-none"}),e.jsxs("div",{className:"flex items-center gap-2 text-[11.5px] text-fg-faint",children:[e.jsx("span",{children:`Markdown. Frontmatter is ${s==="new"?"added":"kept"} on save. Saving marks the memory verified.`}),v&&s==="edit"&&e.jsx("span",{className:"text-accent font-semibold",children:"unsaved"})]})]})]})}const Be=i.memo(qt),Pe="text-[10px] tracking-[.08em] font-semibold text-fg-dim",Xt="flex flex-col gap-px px-2 py-[6px] rounded-[5px] cursor-pointer bg-bg border text-left hover:border-fg-faint";function Ke({testid:s,slug:t,sub:n,dangling:l,onClick:x}){return e.jsxs("button",{type:"button","data-testid":s,onClick:x,className:`${Xt} ${l?"border-accent-muted":"border-rule-inner"}`,children:[e.jsx("span",{className:`text-[12px] font-medium overflow-hidden text-ellipsis whitespace-nowrap ${l?"text-accent":""}`,children:t}),e.jsx("span",{className:`text-[10.5px] ${l?"text-accent":"text-fg-dim"}`,children:n})]})}const Qt=i.memo(function({row:t,onOpen:n,onRemoveLink:l,onAskAbout:x}){return e.jsx("aside",{"data-testid":"mx-links",className:"bg-bg-elev border-l border-rule-structural px-[14px] py-4 flex flex-col gap-[18px] overflow-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-[6px]",children:[e.jsxs("span",{className:Pe,children:["LINKS TO · ",t.outLinks.length]}),t.outLinks.map(a=>{const p=t.danglingLinks.includes(a);return e.jsx(Ke,{testid:`mx-link-out-${a}`,slug:a,dangling:p,sub:p?"missing · click to remove link":"wikilink",onClick:()=>p?l(a):n(a)},a)}),t.outLinks.length===0&&e.jsx("span",{className:"text-[12px] text-fg-dim",children:"No outgoing links."})]}),e.jsxs("div",{className:"flex flex-col gap-[6px]",children:[e.jsxs("span",{className:Pe,children:["LINKED FROM · ",t.inLinks.length]}),t.inLinks.map(a=>e.jsx(Ke,{testid:`mx-link-in-${a}`,slug:a,dangling:!1,sub:"wikilink",onClick:()=>n(a)},a)),t.inLinks.length===0&&e.jsx("span",{className:"text-[12px] text-fg-dim",children:"Nothing links here yet."})]}),e.jsxs("button",{type:"button","data-testid":"mx-links-ask",onClick:x,className:"mt-auto flex flex-col gap-[6px] p-[10px] border border-dashed border-rule rounded-[6px] cursor-pointer text-left hover:border-fg",children:[e.jsx("span",{className:"text-[12px] text-fg",children:"Ask about this memory"}),e.jsx("span",{className:"h-7 border border-rule-structural rounded-[5px] bg-bg-hi px-2 flex items-center text-[11.5px] text-fg-dim",children:"Is this still accurate?"})]})]})})}),Zt=["What changed this week?","Find contradictions","Summarize stale memories","remember …"],Jt=["Is this still accurate?","What links here?","Summarize it"],es=/^remember\b[\s:,-]*/i,We="text-xs font-medium h-[26px] px-2.5 rounded-[5px] bg-fg text-bg",ts=s=>s.charAt(0).toUpperCase()+s.slice(1),ss=i.memo(function({rows:t,context:n,onClearContext:l,onAsk:x,onOpen:a,onReverify:p,onDraft:m}){const[c,v]=i.useState(""),[k,f]=i.useState(!1),[o,b]=i.useState(null),u=async()=>{const y=c.trim();if(!y||k)return;if(/^remember\b/i.test(y)){b({kind:"draft",question:y,text:ts(y.replace(es,""))}),v("");return}f(!0);let C=null;try{C=await x(y,n)}catch{C=null}f(!1),!(!C||!C.ok)&&(b({kind:"answer",question:y,answer:C.answer,citations:C.citations}),v(""))},j=(o==null?void 0:o.kind)==="answer"?o.citations.map(y=>({slug:y,row:t.find(C=>C.slug===y||C.name===y)})):[],M=j.filter(y=>{var C;return(C=y.row)==null?void 0:C.stale}).length;return e.jsxs("div",{"data-testid":"mx-ask",className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"px-7 py-4 border-b border-rule-structural flex items-center gap-2.5",children:[e.jsx("span",{className:"font-serif text-[20px]",children:"Ask"}),e.jsx("span",{className:"text-xs text-fg-dim flex-1",children:"Search and edit this scope's memories in plain language. Answers cite the files they used."}),n&&e.jsxs("span",{"data-testid":"mx-ask-context",className:"flex items-center gap-1.5 pl-2 pr-1 py-[3px] border border-rule rounded-[5px] bg-bg-elev text-xs",children:["About ",e.jsx("span",{className:"font-mono text-[11.5px]",children:n}),e.jsx("button",{"aria-label":"Clear context",onClick:l,className:"px-1.5 text-fg-dim hover:text-accent",children:"×"})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-7 py-6 flex flex-col gap-5 max-w-[820px]",children:[!o&&!k&&e.jsxs("div",{className:"my-auto flex flex-col gap-1.5 text-fg-dim text-[13px]",children:[e.jsx("span",{className:"font-serif text-[20px] text-fg",children:"What do you want to know?"}),e.jsx("span",{children:'Ask about a symptom, a file or a past decision, or start with "remember" to save something new.'})]}),o&&e.jsx("div",{className:"self-end max-w-[520px] px-3.5 py-2.5 rounded-[10px] bg-fg text-bg text-[14px]",children:o.question}),(o==null?void 0:o.kind)==="answer"&&e.jsxs("div",{className:"flex flex-col gap-2.5 text-[14px] leading-[1.65] text-fg max-w-[680px]",children:[e.jsx("p",{className:"m-0",children:o.answer}),e.jsx("div",{className:"flex flex-wrap gap-1.5 items-center",children:j.map((y,C)=>{var I;return e.jsxs("button",{"data-testid":`mx-ask-cite-${y.slug}`,onClick:()=>{var W;return a(((W=y.row)==null?void 0:W.name)??y.slug)},className:"flex items-center gap-1.5 px-[9px] py-1 border border-rule-structural rounded-[5px] bg-bg text-xs hover:border-fg",children:[e.jsxs("span",{className:"font-mono text-[10.5px] text-accent",children:["[",C+1,"]"]}),e.jsx("span",{children:y.slug}),y.row&&e.jsxs("span",{className:"text-fg-dim",children:[y.row.ageDays,"d"]}),((I=y.row)==null?void 0:I.stale)&&e.jsx("span",{className:"text-[9.5px] font-semibold px-1 rounded-[3px] bg-butter/40 text-honey-dark",children:"STALE"})]},y.slug)})}),M>0&&e.jsxs("div",{className:"px-3 py-2.5 rounded-md bg-butter/40 text-[12.5px] text-fg flex items-center gap-2.5",children:[e.jsxs("span",{className:"flex-1",children:[M," of these ",M===1?"is":"are"," flagged stale. Re-verify against the current code?"]}),e.jsx("button",{onClick:p,className:We,children:"Re-verify"})]})]}),(o==null?void 0:o.kind)==="draft"&&e.jsxs("div",{className:"max-w-[560px] border border-rule rounded-lg bg-bg-hi p-3.5 flex flex-col gap-2",children:[e.jsx("span",{"data-testid":"mx-ask-draft",className:"text-[10px] tracking-[.08em] text-sage-dark font-semibold",children:"DRAFT MEMORY · NOT SAVED YET"}),e.jsx("span",{className:"font-serif text-base",children:o.text}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>m(o.text),className:`${We} h-7 px-3`,children:"Review draft"}),e.jsx("span",{className:"text-xs text-fg-dim self-center",children:"Opens it in the editor before anything is written"})]})]}),k&&e.jsx("span",{className:"text-xs text-fg-dim",children:"Thinking…"})]}),e.jsxs("div",{className:"px-7 pt-3 pb-4 border-t border-rule-structural flex flex-col gap-2.5",children:[e.jsx("div",{className:"flex gap-1.5 flex-wrap items-center",children:(n?Jt:Zt).map(y=>e.jsx("button",{onClick:()=>v(y),className:"px-2.5 py-1 border border-rule-structural rounded-[14px] text-xs text-fg-dim hover:bg-bg-elev",children:y},y))}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{"data-testid":"mx-ask-input",value:c,onChange:y=>v(y.target.value),onKeyDown:y=>{y.key==="Enter"&&u()},placeholder:"Ask, or say “remember …” to add a memory",className:"flex-1 h-11 border border-rule rounded-md bg-bg-hi px-3 text-[13px] text-fg focus:outline-none focus:border-fg-faint"}),e.jsx($t,{}),e.jsx("button",{"data-testid":"mx-ask-send",onClick:()=>void u(),disabled:k,className:"h-11 px-4 rounded-md bg-accent text-white text-[13px] font-medium disabled:opacity-40",children:"Send"}),e.jsx("span",{className:"text-[10px] text-fg-faint",children:"uses Claude"})]})]})]})}),Ue="text-xs font-medium h-[26px] px-2.5 border border-rule-structural rounded-[5px] bg-bg text-fg hover:border-fg disabled:opacity-50 disabled:cursor-default",Ve="text-[11px] text-fg-faint",ns=i.memo(function({clusters:t,rows:n,generatedAt:l,running:x,unclusteredCount:a,available:p,onRegenerate:m,onOpenCluster:c,onOpen:v}){const k=i.useMemo(()=>new Map(n.map(f=>[f.slug,f])),[n]);return p?l===null&&t.length===0?e.jsxs("div",{"data-testid":"mx-clusters",className:"flex-1 flex flex-col items-center justify-center gap-2 p-6 text-center",children:[e.jsx("div",{className:"font-serif text-[20px] text-fg",children:"No clusters yet"}),e.jsx("button",{type:"button","data-testid":"mx-clusters-regenerate",className:Ue,disabled:x,onClick:m,children:x?"Generating…":"Generate"}),e.jsx("span",{className:Ve,children:"uses Claude · up to 3 min"})]}):e.jsxs("div",{"data-testid":"mx-clusters",className:"flex-1 min-w-0 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-rule-structural flex items-center gap-2.5",children:[e.jsx("span",{className:"font-serif text-[20px] text-fg",children:"Clusters"}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["Generated ",Nt(l,Date.now())," from shared references and links"]}),e.jsx("span",{className:"flex-1"}),a>0&&e.jsxs("span",{className:"text-xs text-honey-dark px-2 py-0.5 rounded bg-butter/40",children:[a," unclustered"]}),e.jsx("button",{type:"button","data-testid":"mx-clusters-regenerate",className:Ue,disabled:x,onClick:m,children:x?"Generating…":"Regenerate"}),e.jsx("span",{className:Ve,children:"uses Claude"})]}),e.jsx("div",{className:"flex-1 overflow-auto px-6 py-[18px] grid grid-cols-2 gap-4 content-start",children:t.map(f=>e.jsxs("div",{"data-testid":`mx-cluster-${f.id}`,className:"bg-bg-hi border border-rule-structural rounded-lg p-4 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-[9px] h-[9px] rounded-[2px] shrink-0 ${f.dotClass}`}),e.jsx("span",{className:"font-serif text-[17px] text-fg min-w-0 flex-1",children:f.name}),e.jsxs("button",{type:"button","data-testid":`mx-cluster-open-${f.id}`,className:"text-xs text-accent hover:text-fg",onClick:()=>c(f.id),children:["Open ",f.memberSlugs.length," →"]})]}),e.jsx("span",{className:"text-[12.5px] leading-normal text-fg-dim",children:f.summary}),e.jsx("div",{className:"flex flex-wrap gap-[5px] items-center",children:f.memberSlugs.map(o=>{const b=k.get(o);return e.jsx("button",{type:"button",className:`font-mono text-[11px] px-[7px] py-[3px] rounded border border-rule-inner text-fg hover:border-fg ${b!=null&&b.stale?"bg-butter/40":"bg-bg"}`,onClick:()=>v((b==null?void 0:b.name)??`${o}.md`),children:o},o)})}),e.jsxs("div",{className:"flex gap-3.5 text-[11.5px] text-fg-dim border-t border-rule-inner pt-[9px]",children:[e.jsxs("span",{children:[f.linkCount," links"]}),e.jsxs("span",{children:[f.retireCount," retires"]}),e.jsxs("span",{className:"text-honey-dark",children:[f.staleCount," stale"]})]})]},f.id))})]}):e.jsx("div",{"data-testid":"mx-clusters",className:"flex-1 p-6 text-[13px] text-fg-dim",children:"Clusters are available for workspace memory."})});function rs({open:s,rows:t,clusterDot:n,onPick:l,onAsk:x,onClose:a}){const[p,m]=i.useState(""),[c,v]=i.useState(0);if(i.useEffect(()=>{s&&(m(""),v(0))},[s]),!s)return null;const k=Ye(qe(t,"recent"),p,6),f=k.length,o=u=>{u===f?x(p):l(k[u].name)},b=u=>{u.key==="ArrowDown"?(u.preventDefault(),v(j=>Math.min(j+1,f))):u.key==="ArrowUp"?(u.preventDefault(),v(j=>Math.max(j-1,0))):u.key==="Enter"?(u.preventDefault(),o(Math.min(c,f))):u.key==="Escape"&&(u.preventDefault(),a())};return e.jsxs("div",{"data-testid":"mx-palette",children:[e.jsx("div",{className:`absolute inset-0 ${K.dialog} bg-fg/30`,onClick:a}),e.jsxs("div",{className:`absolute left-1/2 top-[84px] -translate-x-1/2 w-[580px] ${K.dialog} bg-bg-hi border border-rule rounded-[10px] shadow-2xl overflow-hidden`,children:[e.jsx("input",{"data-testid":"mx-palette-input",autoFocus:!0,value:p,onChange:u=>{m(u.target.value),v(0)},onKeyDown:b,placeholder:"Search memories or ask a question…",className:"w-full h-[50px] border-0 border-b border-rule-inner px-[18px] text-[15px] text-fg bg-transparent outline-none"}),e.jsxs("div",{className:"p-[6px] flex flex-col max-h-[380px] overflow-auto",children:[k.map((u,j)=>e.jsxs("div",{"data-testid":"mx-palette-row",onClick:()=>o(j),onMouseEnter:()=>v(j),className:`flex items-center gap-[9px] px-3 py-2 rounded-[6px] cursor-pointer ${j===c?"bg-bg-deep":""}`,children:[e.jsx("span",{className:`w-[7px] h-[7px] rounded-[2px] flex-none ${n(u.clusterId)}`}),e.jsx("span",{className:"font-mono text-[12.5px] text-fg flex-none",children:u.slug}),e.jsx("span",{className:"text-[12px] text-fg-dim overflow-hidden text-ellipsis whitespace-nowrap",children:u.description})]},u.name)),e.jsxs("div",{"data-testid":"mx-palette-ask",onClick:()=>o(f),onMouseEnter:()=>v(f),className:`flex items-center gap-[9px] px-3 py-[10px] mt-1 border-t border-rule-inner cursor-pointer text-[13px] text-accent ${c===f?"bg-bg-deep":""}`,children:[e.jsx("span",{className:"font-mono text-[11px]",children:"↵"}),"Ask “",p,"” …",e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-[11px] text-fg-dim",children:"opens Ask"})]})]}),e.jsxs("div",{className:"px-[14px] py-2 border-t border-rule-inner text-[11px] text-fg-dim flex gap-[14px]",children:[e.jsx("span",{children:"↑↓ move"}),e.jsx("span",{children:"↵ open"}),e.jsx("span",{children:"esc close"})]})]})]})}const $e="text-[12.5px] font-medium h-8 px-3 rounded-[5px] cursor-pointer text-fg";function as({open:s,name:t,inbound:n,onArchive:l,onCancel:x,onConfirm:a}){return i.useEffect(()=>{if(!s)return;const p=m=>{m.key==="Escape"&&x()};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s,x]),s?e.jsxs("div",{"data-testid":"mx-delete-dialog",children:[e.jsx("div",{className:`absolute inset-0 ${K.dialog} bg-fg/30`,onClick:x}),e.jsxs("div",{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[440px] ${K.dialog} bg-bg-hi border border-rule rounded-[10px] shadow-lg p-5 flex flex-col gap-3`,children:[e.jsx("span",{className:"font-serif text-[20px] text-fg",children:"Delete this memory?"}),e.jsxs("span",{className:"font-mono text-[12.5px] text-fg",children:[t,".md"]}),n>0&&e.jsxs("div",{className:"px-3 py-[10px] rounded-[6px] bg-accent-muted/30 text-[12.5px] leading-normal text-accent-dark",children:[n," memories link here. Those links will show as broken until removed."]}),e.jsx("span",{className:"text-[12.5px] text-fg-dim",children:"The file is removed from disk. You can undo for a few seconds afterwards. To keep it out of sessions without deleting it, use Archive."}),e.jsxs("div",{className:"flex gap-2 justify-end mt-1",children:[e.jsx("button",{type:"button",onClick:l,className:`${$e} border border-rule mr-auto`,children:"Archive instead"}),e.jsx("button",{type:"button",onClick:x,className:`${$e} border border-rule bg-bg`,children:"Cancel"}),e.jsx("button",{type:"button","data-testid":"mx-delete-confirm",onClick:a,className:`${$e} border-0 px-[14px] bg-accent text-white`,children:"Delete"})]})]})]}):null}const os=6e3;function ls({message:s,onUndo:t,onClose:n}){return i.useEffect(()=>{if(s===null)return;const l=setTimeout(n,os);return()=>clearTimeout(l)},[s]),s===null?null:e.jsxs("div",{"data-testid":"mx-undo-bar",className:`absolute bottom-[22px] left-1/2 -translate-x-1/2 ${K.dialog} flex items-center gap-[14px] py-[10px] pl-4 pr-3 rounded-lg bg-fg text-bg text-[13px] shadow-lg whitespace-nowrap`,children:[e.jsx("span",{children:s}),t&&e.jsx("button",{type:"button","data-testid":"mx-undo",onClick:t,className:"font-semibold text-accent-muted hover:text-white",children:"Undo"}),e.jsx("button",{type:"button",onClick:n,"aria-label":"Dismiss",className:"text-fg-faint hover:text-white px-1",children:"×"})]})}const Ze="sm.memoryTab.scope",ce="agent:",Me=`One-line summary of the fact or rule.
16
-
17
- **Why:**
18
-
19
- **How to apply:**`,B={state:"idle",diff:[],summary:"",action:"update",reason:"",fold:null},He=s=>s.replace(/\.md$/,""),ze=s=>s?s.split(/[\\/]/).filter(Boolean).pop()??s:"workspace";function Ee(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return(t?s.slice(t[0].length):s).replace(/^\s*\n/,"")}function is(){try{const s=localStorage.getItem(Ze);return s&&s.startsWith(ce)?s:"workspace"}catch{return"workspace"}}function ds({cwd:s}){const[t,n]=i.useState(is),[l,x]=i.useState([]),[a,p]=i.useState(0),m=i.useMemo(()=>{if(!t.startsWith(ce))return"workspace";const f=t.slice(ce.length);return l.some(o=>o.name===f)?t:"workspace"},[t,l]),c=i.useMemo(()=>{if(m==="workspace")return{kind:"workspace"};const f=l.find(o=>o.name===m.slice(ce.length));return f?{kind:"agent",agent:f}:{kind:"workspace"}},[m]),v=i.useCallback(f=>{const o=f.kind==="agent"?`${ce}${f.agent.name}`:"workspace";try{localStorage.setItem(Ze,o)}catch{}n(o)},[]),k=i.useCallback(f=>{f.length>0&&x(f)},[]);return e.jsx(cs,{scope:c,cwd:s,onScope:v,onAgents:k,wsCount:a,onWsCount:p},m)}function cs({scope:s,cwd:t,onScope:n,onAgents:l,wsCount:x,onWsCount:a}){var Re;const p=Tt(s,t),{actions:m,rows:c,clusters:v}=p,k=s.kind==="agent"?s.agent:null,f=k!==null&&k.memoryScope===null,o=k?k.name:ze(t),[b,u]=i.useState("all"),[j,M]=i.useState(null),[y,C]=i.useState("read"),[I,W]=i.useState(""),[ee,xe]=i.useState("recent"),[q,A]=i.useState(null),[U,L]=i.useState(B),[me,ye]=i.useState(""),[X,T]=i.useState(null),[_,te]=i.useState(null),[ve,R]=i.useState(null),[$,Q]=i.useState(""),[V,H]=i.useState(""),[ue,se]=i.useState(""),[ne,re]=i.useState(!1),[Z,pe]=i.useState(null);i.useEffect(()=>{l(p.agents)},[p.agents,l]),i.useEffect(()=>{!k&&!p.loading&&a(c.length)},[k,p.loading,c.length,a]);const z=i.useMemo(()=>p.archived.map(r=>({name:r,slug:He(r),path:`${p.dir}/${r}`,description:"",bytes:0,mtimeMs:0,ageDays:0,stale:!1,staleReasons:[],ageOnlyStale:!1,deadRefs:[],broken:!1,danglingLinks:[],outLinks:[],inLinks:[],notIndexed:!1,clusterId:null,type:null,originSessionId:null})),[p.archived,p.dir]),ae=b!=="ask"&&b!=="clusters",h=i.useMemo(()=>{if(b==="archived"){const r=I.trim().toLowerCase();return z.filter(g=>!r||g.slug.toLowerCase().includes(r))}return qe(de(c,b,I),ee)},[b,c,z,I,ee]),d=i.useMemo(()=>c.find(r=>r.name===j)??z.find(r=>r.name===j)??null,[c,z,j]),N=d!==null&&!c.some(r=>r.name===d.name),w=i.useCallback(r=>{var g;return((g=v.find(S=>S.id===r))==null?void 0:g.dotClass)??"bg-rule"},[v]),G=r=>{var g;return((g=v.find(S=>S.id===r))==null?void 0:g.name)??"Unclustered"},O=i.useCallback(r=>{M(r),C("read"),L(B),T(null),A(null)},[]),P=i.useCallback(r=>{u(r),W(""),A(null),L(B),C(g=>g==="edit"||g==="new"?"read":g)},[]);i.useEffect(()=>{var r;p.loading||!ae||y==="new"||d&&h.some(g=>g.name===d.name)||M(((r=h[0])==null?void 0:r.name)??null)},[p.loading,ae,y,d,h]);const oe=d&&!N?d.name:null,Je=d==null?void 0:d.mtimeMs;i.useEffect(()=>{if(!oe)return;let r=!0;return m.read(oe).then(g=>{r&&pe({name:oe,text:g})}),()=>{r=!1}},[oe,Je,m.read]);const Y=N?"":Z&&Z.name===oe?Z.text:null;i.useEffect(()=>{const r=g=>{var he,ie;if(g.key!=="/"||g.metaKey||g.ctrlKey||g.altKey)return;const S=g.target,fe=((he=S==null?void 0:S.tagName)==null?void 0:he.toLowerCase())??"";fe==="input"||fe==="textarea"||S!=null&&S.isContentEditable||(ie=S==null?void 0:S.closest)!=null&&ie.call(S,".monaco-editor")||(g.preventDefault(),A("palette"))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[]);const D=(r,g)=>te({message:r,undo:g}),ke=(r="")=>{f||((b==="ask"||b==="clusters")&&u("all"),M(null),Q(""),H(r),se(""),L(B),A(null),C("new"))},Ne=r=>{P("all"),O(r)},et=r=>{const g=c.find(S=>S.slug===r);g?O(g.name):E.error(`${r} is not in this scope`)},tt=()=>{if(Y===null)return;const r=Ee(Y);H(r),se(r),C("edit")},st=async()=>{if(!ne){re(!0);try{if(y==="new"){const r=await m.create($,V);if(!r)return;const g=r.endsWith(".md")?r:`${r}.md`;P("all"),O(g),D(`Created ${He(g)}`)}else if(y==="edit"&&d){if(!await m.saveBody(d.name,V))return;C("read"),D(`Saved ${d.slug}`)}}finally{re(!1)}}},nt=()=>{C("read"),d||M(null)},rt=async()=>{if(!d||Y===null)return;const r=d;L({...B,state:"checking"});const g=await m.proposeFix(r.name);if(!g.ok){L(B);return}ye(g.content),L({state:"proposed",diff:g.action==="update"?Dt(Y,g.content):[],summary:g.summary,action:g.action,reason:g.reason,fold:g.fold})},at=async()=>{if(!d||Y===null)return;const r=d;if(U.action==="delete"){if(!await m.archive(r.name))return;L(B),D(`Archived ${r.slug}`,()=>{m.restore(r.name)})}else if(U.action==="keep"){if(!await m.verify(r.name))return;L(B),D(`Marked ${r.slug} verified`)}else if(U.action==="fold"){if(!U.fold)return;const{target:g,anchor:S,insert:fe}=U.fold,he=`Fold memory ${r.slug} into ${g}.
20
- Insert after the line: ${S||"(append at end)"}
21
- ---
22
- ${fe}
23
- ---
24
- Tread lightly: add only these lines, do not restructure the doc. Once committed, archive the memory ${r.slug} from the Memory page.
25
- Memory file: ${r.path}`,ie=await window.api.clipboard.writeText(he);if(!ie.ok){E.error(`Copy failed: ${ie.error??"unknown error"}`);return}L(B),D("Fold copied — paste it into a New Epic")}else{const g=Ee(Y);if(!await m.saveBody(r.name,Ee(me)))return;L(B),T(r.slug),D(`Applied fix to ${r.slug}`,()=>{m.saveBody(r.name,g)})}},ot=async()=>{if(!d)return;const r=d;await m.verify(r.name)&&D(`Marked ${r.slug} verified`)},Ae=async()=>{if(!d)return;const r=d;A(null),await m.archive(r.name)&&D(`Archived ${r.slug}`,()=>{m.restore(r.name)})},lt=async()=>{if(!d)return;const r=d;await m.restore(r.name)&&D(`Restored ${r.slug}`)},it=async()=>{if(!d)return;const r=d;A(null);const g=await m.remove(r.name);if(!g)return;const S=r.inLinks.length;D(`Deleted ${r.slug}${S>0?` · ${S} inbound links now broken`:""}`,()=>{g()})},dt=async()=>{if(!d)return;const r=await window.api.clipboard.writeText(d.path);r.ok?D("Path copied"):E.error(`Copy failed: ${r.error??"unknown error"}`)},ct=()=>{d&&window.api.shell.open({as:"revealPath",path:d.path})},xt=async r=>{if(!d)return;const g=d;await m.removeLink(g.name,r)&&D(`Dead link removed from ${g.slug}`)},mt=()=>{d&&(R(d.slug),P("ask"))},ut=r=>{var g;return r?((g=c.find(S=>S.slug===r))==null?void 0:g.name)??`${r}.md`:void 0},pt=i.useMemo(()=>Rt(c),[c]),ft=i.useMemo(()=>{const r={};for(const g of c)g.clusterId&&(r[g.clusterId]=(r[g.clusterId]??0)+1);return r},[c]),Le=i.useMemo(()=>c.filter(r=>r.clusterId===null).length,[c]),ht=i.useMemo(()=>new Set(c.map(r=>r.slug)),[c]),gt=b.startsWith("cluster:")?b==="cluster:unclustered"?"Unclustered":((Re=v.find(r=>r.id===b.slice(8)))==null?void 0:Re.name)??"Cluster":{all:"All memories",stale:"Stale",broken:"Broken references",recent:"Changed this week",unindexed:"Not in index",archived:"Archived"}[b]??"All memories";let le=null;h.length===0&&(f?le={title:`${o} has no persistent memory`,body:"Add `memory: project` (or user/local) to its frontmatter in the Agent Library to turn it on.",action:"Back to workspace",onAction:()=>n({kind:"workspace"})}:I.trim()?le={title:`No memories match “${I}”`,body:"Filter checks names and descriptions in this view.",action:"Clear filter",onAction:()=>W("")}:c.length===0&&b==="all"?le={title:`${o} has no memories yet`,body:"They appear when this subagent saves one, or add one now.",action:"+ New memory",onAction:()=>ke(Me)}:le={title:"All clear",body:b==="stale"?"Nothing is stale in this scope.":"Nothing in this view.",action:"Back to all memories",onAction:()=>P("all")});const bt=!p.autoMemoryEnabled,yt=wt.memory;return e.jsxs("div",{"data-testid":"mx-shell",className:"relative h-full flex flex-col bg-bg text-fg leading-[normal]",children:[e.jsxs("div",{className:"relative shrink-0 flex items-center gap-3 px-6 py-4 border-b border-rule-structural",children:[e.jsxs("div",{className:"flex items-baseline gap-3 pt-1",children:[e.jsx("span",{className:"text-[11px] tracking-[.08em] font-medium text-fg-dim",children:"CONFIGURE"}),e.jsx("span",{className:"font-serif text-[28px] leading-none",children:"Memory"}),e.jsx("span",{className:"text-xs text-fg-dim",children:"Claude Code's own memory files · stored on this machine"})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{type:"button","data-testid":"mx-search-trigger",onClick:()=>A("palette"),className:"flex items-center gap-2 h-[30px] px-2.5 border border-rule-structural rounded-md bg-bg-elev w-[300px] text-xs text-fg-dim hover:border-fg-faint",children:[e.jsx("span",{children:"Search all memories, or ask a question…"}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"font-mono text-[10px] px-[5px] py-px border border-rule-structural rounded-[3px] text-fg-dim",children:"/"})]}),e.jsx("button",{type:"button","data-testid":"mx-learn",onClick:()=>A(r=>r==="learn"?null:"learn"),className:`text-[11px] tracking-[.08em] font-semibold px-1 py-1.5 hover:text-fg ${q==="learn"?"text-fg":"text-accent"}`,children:"LEARN"}),q==="learn"&&e.jsxs("div",{"data-testid":"mx-learn-popover",className:`absolute right-5 top-[58px] w-[360px] ${K.dialog} bg-bg-hi border border-rule-structural rounded-lg shadow-2xl p-4 flex flex-col gap-2.5 text-[13px] leading-[1.55] text-fg`,children:[e.jsx("span",{className:"font-serif text-[17px]",children:"How memory works"}),e.jsx("span",{children:yt.intro}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-testid":"mx-learn-close",onClick:()=>A(null),className:"text-xs font-medium h-7 px-3 rounded-[5px] bg-fg text-bg",children:"Got it"})})]})]}),bt&&e.jsx("div",{"data-testid":"mx-auto-off",className:"shrink-0 w-full px-6 py-2 bg-butter/40 text-honey-dark text-[12.5px]",children:"Auto memory is off — Claude Code is not reading or writing any of these files."}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(Ot,{scope:s,agents:p.agents,agentCounts:p.agentCounts,workspaceName:ze(t),workspacePath:t??"",workspaceCount:k?x:c.length,onScope:n,view:b,onView:P,counts:pt,clusters:v,clusterCounts:ft,unclusteredCount:Le,archivedCount:p.archived.length,index:p.index}),e.jsxs("main",{className:"flex-1 min-w-0 min-h-0 flex",children:[b==="ask"&&e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ss,{rows:c,context:ve,onClearContext:()=>R(null),onAsk:(r,g)=>m.ask(r,ut(g)),onOpen:Ne,onReverify:()=>P("stale"),onDraft:r=>ke(r)})}),b==="clusters"&&e.jsx(ns,{clusters:v,rows:c,generatedAt:p.clustersMeta.generatedAt,running:p.clustersMeta.running,unclusteredCount:Le,available:!k,onRegenerate:()=>{m.regenerateClusters()},onOpenCluster:r=>P(`cluster:${r}`),onOpen:Ne}),ae&&e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 grid grid-cols-[316px_minmax(0,1fr)_236px]",children:[e.jsx(Kt,{title:gt,rows:h,clusterDot:w,selected:j,onSelect:O,query:I,onQuery:W,sort:ee,onSort:xe,onNew:()=>ke(Me),empty:le}),e.jsx("div",{className:"flex flex-col min-w-0 min-h-0",children:y==="edit"||y==="new"?e.jsx(Be,{mode:y,name:(d==null?void 0:d.slug)??null,title:$,onTitle:Q,body:V,onBody:H,onSave:()=>{st()},onCancel:nt,saving:ne,dirty:y==="new"?$.trim()!==""||V!==Me:V!==ue}):d?e.jsx(Yt,{row:d,content:Y,clusterName:G(d.clusterId),clusterDot:w(d.clusterId),archived:N,mode:y,onMode:C,onEdit:tt,onCopyPath:()=>{dt()},onReveal:ct,onArchive:()=>{Ae()},onRestore:()=>{lt()},onAskDelete:()=>A("delete"),fix:U,appliedStill:X===d.slug&&d.stale,onFix:()=>{rt()},onApplyFix:()=>{at()},onDiscardFix:()=>L(B),onVerify:()=>{ot()}}):e.jsx(Be,{mode:"none",name:null,title:"",onTitle:Q,body:"",onBody:H,onSave:()=>{},onCancel:()=>{},saving:!1,dirty:!1})}),e.jsx(Qt,{row:N||y==="new"?null:d,known:ht,onOpen:et,onRemoveLink:r=>{xt(r)},onAskAbout:mt})]})]})]}),e.jsx(rs,{open:q==="palette",rows:c,clusterDot:w,onPick:Ne,onAsk:()=>{R(null),P("ask")},onClose:()=>A(null)}),e.jsx(as,{open:q==="delete"&&d!==null,name:(d==null?void 0:d.slug)??"",inbound:(d==null?void 0:d.inLinks.length)??0,onArchive:()=>{Ae()},onCancel:()=>A(null),onConfirm:()=>{it()}}),e.jsx(ls,{message:(_==null?void 0:_.message)??null,onUndo:_!=null&&_.undo?()=>{const r=_.undo;te(null),r==null||r()}:void 0,onClose:()=>te(null)})]})}function xs(){const s=jt(),t=Ct();return s?e.jsx(ds,{cwd:(t==null?void 0:t.cwd)??null}):e.jsx(St,{title:"loading…"})}const fs=i.memo(xs);export{fs as Memory};