claude-code-session-manager 0.130.2 → 0.130.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/bin/cli.cjs +19 -2
- package/dist/assets/AgentLibrary-BmrXNwK8.js +2 -0
- package/dist/assets/{AppSettings-Bpwynea4.js → AppSettings-Cs4POznd.js} +1 -1
- package/dist/assets/{Button-DSoqrxCB.js → Button-UUr5giu8.js} +1 -1
- package/dist/assets/DocumentEditorPane-C46Hj0lz.js +1 -0
- package/dist/assets/Extensions-B9QdiNOV.js +2 -0
- package/dist/assets/{History-DzMo9Otn.js → History-Bndupj87.js} +2 -2
- package/dist/assets/{Library-C5wKMTSn.js → Library-DFn0YPIW.js} +5 -5
- package/dist/assets/{ListDetail-DDQ1S0yu.js → ListDetail-DjMn8a_3.js} +1 -1
- package/dist/assets/{Panel-B-3NWUlv.js → Panel-CIvb-XXN.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-BQQRtMdK.js +25 -0
- package/dist/assets/{ProvenanceBadge-CUChwz4Z.js → ProvenanceBadge-ej8W2ZIK.js} +1 -1
- package/dist/assets/{Scheduler-CkGHMXvo.js → Scheduler-DSVBWqRK.js} +8 -8
- package/dist/assets/Settings-DqxUna06.js +2 -0
- package/dist/assets/{SkillReferenceGraph-C6JEdypC.js → SkillReferenceGraph-BEMTdxdD.js} +1 -1
- package/dist/assets/Skills-DTXehVS7.js +12 -0
- package/dist/assets/{SourceChip-DcBNYYhe.js → SourceChip-BrPci8FX.js} +1 -1
- package/dist/assets/SystemPrompt-B43hNP0X.js +1 -0
- package/dist/assets/{TiptapBody-DiVYC-_O.js → TiptapBody-B-R2Bpda.js} +1 -1
- package/dist/assets/{Toggle-Cs3k6I96.js → Toggle-DKb4x1BP.js} +1 -1
- package/dist/assets/ViewTabs-CcJdFZgv.js +1 -0
- package/dist/assets/{VoiceButton-C3NLotUZ.js → VoiceButton-BSH0UI3u.js} +1 -1
- package/dist/assets/{historyTotals-f-E0L9Xw.js → historyTotals-5oUEu_fe.js} +1 -1
- package/dist/assets/index-C9w-dVzo.js +3090 -0
- package/dist/assets/{index-Bp8XE9A6.css → index-CMCcT2yg.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +420 -416
- package/package.json +1 -1
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +15 -5
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +8 -4
- package/src/main/agentLibrary.cjs +81 -29
- package/src/main/agentsIpc.cjs +21 -16
- package/src/main/build-info.json +4 -4
- package/src/main/ipcSchemas.cjs +7 -1
- package/src/main/lib/epic/epicWorktreeMerge.cjs +11 -9
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
- package/src/main/lib/git/gitWorktree.cjs +216 -43
- package/src/main/lib/mdNetworkScan.cjs +555 -0
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +18 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +9 -2
- package/src/main/lib/scheduler/terminalRunOutcome.cjs +61 -15
- package/src/main/projectPages.cjs +32 -7
- package/src/main/scheduler/gitTreeGuard.cjs +85 -12
- package/src/main/scheduler.cjs +16 -5
- package/src/preload/api.d.ts +91 -6
- package/src/preload/apiSurface.json +7 -0
- package/src/preload/index.cjs +1 -0
- package/dist/assets/AgentLibrary-Bfj862qf.js +0 -2
- package/dist/assets/Extensions-BziIutWV.js +0 -13
- package/dist/assets/Memory-Bq5T33d2.js +0 -25
- package/dist/assets/Settings-DGxvyajs.js +0 -2
- package/dist/assets/SystemPrompt-CfozyVQx.js +0 -1
- package/dist/assets/ViewTabs-DFXH03tb.js +0 -1
- package/dist/assets/index-CuAfFXNd.js +0 -3086
|
@@ -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};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b3 as T,at as e,a$ as A,aJ as j,b9 as L,b0 as V,bb as z,bi as H,P as ce,l as C,a3 as de,v as ue,Q as Y,S,a as pe,bk as B,be as me,ax as xe,aB as he,J as fe,ap as ge}from"./index-CuAfFXNd.js";import{P as F}from"./Panel-B-3NWUlv.js";import{P as be,H as ye,S as Z}from"./Library-C5wKMTSn.js";import{S as I}from"./SourceChip-DcBNYYhe.js";import{V as U}from"./ViewTabs-DFXH03tb.js";import{r as Q}from"./claude-settings-schema-COigsajx.js";import{L as je}from"./ListDetail-DDQ1S0yu.js";import{P as ve}from"./ProvenanceBadge-CUChwz4Z.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-DSoqrxCB.js";function ke(t){const s=t??{},n={...s.$defs??{},...s.definitions??{}},a=i=>{if(!i)return{};if(!i.$ref)return l(i);const d=/^#\/(\$defs|definitions)\/(.+)$/.exec(i.$ref);if(!d)return l(i);const h=n[d[2]];return h?a({...h,...p(i)}):l(i)},o=new Set(["__proto__","constructor","prototype"]),r=i=>{if(!i)return{};const d={};for(const[h,g]of Object.entries(i))o.has(h)||(d[h]=g);return d},l=i=>{if(!i.allOf||i.allOf.length===0)return i;const d={...i};delete d.allOf;for(const h of i.allOf){const g=a(h);Object.assign(d,{properties:{...r(d.properties),...r(g.properties)},required:we([...d.required??[],...g.required??[]])}),!d.description&&g.description&&(d.description=g.description),d.default===void 0&&g.default!==void 0&&(d.default=g.default),!d.type&&g.type&&(d.type=g.type)}return d},p=i=>{const{$ref:d,...h}=i;return h},u=(i,d)=>{let h=a(i);for(const g of d){if(!h)return null;if(/^\d+$/.test(g)){const k=Array.isArray(h.items)?h.items[Number(g)]:h.items;h=k?a(k):null;continue}const N=h.properties;if(N&&!o.has(g)&&g in N){h=a(N[g]);continue}const b=h.additionalProperties;if(b&&typeof b=="object"){h=a(b);continue}return null}return h},c=(i,d,h)=>{if(!i)return null;const g={};if(i.description&&(g.description=i.description),i.type&&(g.type=i.type),i.default!==void 0&&(g.default=i.default),i.enum&&(g.enum=i.enum),i.const!==void 0&&(g.const=i.const),i.deprecated&&(g.deprecated=!0),i.examples&&(g.examples=i.examples),i.properties&&(g.knownChildren=Object.keys(i.properties)),h&&(d!=null&&d.includes(h))&&(g.required=!0),i.items&&!Array.isArray(i.items)){const N=a(i.items),b=c(N,void 0,null);b&&(g.itemsInfo=b)}return(i.additionalProperties===!0||typeof i.additionalProperties=="object")&&(g.open=!0),g},x=i=>d=>{if(d.length===0)return c(a(i),void 0,null);const h=u(i,d.slice(0,-1));if(!h)return null;const g=d[d.length-1],N=u(h,[g]);return c(N,h.required,g)},v=i=>{const d=a(i);return Object.keys(d.properties??{})},f=i=>({at:x(i),rootKeys:()=>v(i),rootedAt:d=>{const h=u(i,d);return f(h??{})}});return f(s)}function we(t){return Array.from(new Set(t))}let D=null;function X(){return D||(D=ke(Q)),D}const Ne=["allow","deny","ask"],J="This settings file has invalid JSON. Fix it in the Settings raw editor first; Permissions will not overwrite it.";function Se(t){if(t.trim()==="")return{perms:{},full:{},err:null};try{const s=JSON.parse(t);if(s===null||typeof s!="object"||Array.isArray(s))return{perms:{},full:{},err:"settings file is not a JSON object"};const n=s;return{perms:n.permissions??{},full:n,err:null}}catch(s){return{perms:{},full:{},err:s.message}}}function Ce({scope:t="user"}={}){const s=L(),n=V(),a=(n==null?void 0:n.cwd)??null,o=z(i=>i.navFace),[r,l]=j.useState("rules");j.useEffect(()=>{o==="project"&&r==="presets"&&l("rules")},[o,r]);const u=H(ce,s,a)[t]??null,c=T(i=>i.files),x=e.jsx(U,{options:[{key:"rules",label:"Rules"},...o==="home"?[{key:"presets",label:"Presets"}]:[]],active:r,onChange:l});if(!s)return e.jsx(C,{title:"loading…"});if(r==="presets")return e.jsx(F,{toolbar:x,children:e.jsx(be,{})});const v=i=>i!=="user"&&!a,f=u?c[u]:null;return e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[x,e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:u??"—"}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings#permissions",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"rule syntax ↗"})]}),children:v(t)?e.jsx(C,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):u&&f?e.jsx(ee,{scope:t,cwd:a,activePath:u}):e.jsx(C,{title:"resolving…"})})}j.memo(Ce);function ee({scope:t,cwd:s,activePath:n}){const a=T(c=>c.files[n]),{perms:o,err:r}=a?Se(a.draftRaw):{perms:{},err:null},l=(c,x)=>{if(r){A.error(J);return}window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:s,keyPath:["permissions",c],value:x}).catch(v=>A.error(v instanceof Error?v.message:String(v)))},p=(c,x)=>{const v=x.trim();if(!v)return;const f=o[c]??[];f.includes(v)||l(c,[...f,v])},u=(c,x)=>{const v=o[c]??[];l(c,v.filter((f,i)=>i!==x))};return e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[r&&e.jsxs("div",{role:"alert",className:"text-xs text-red-400 border border-red-400/40 rounded px-3 py-2",children:[J," (",r,")"]}),e.jsx(_e,{value:o.defaultMode??"default",onChange:c=>l("defaultMode",c)}),Ne.map(c=>e.jsx(Ee,{list:c,rules:o[c]??[],disabled:!!r,onAdd:x=>p(c,x),onRemove:x=>u(c,x)},c)),e.jsx(Pe,{dirs:o.additionalDirectories??[],disabled:!!r,onChange:c=>l("additionalDirectories",c)})]})}function _e({value:t,onChange:s}){var r;const a=(((r=X().at(["permissions","defaultMode"]))==null?void 0:r.enum)??[]).filter(l=>typeof l=="string"),o=t&&!a.includes(t)?[...a,t]:a;return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Default Mode"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:o.map(l=>e.jsx("button",{onClick:()=>s(l),className:`px-2.5 py-1 text-xs transition-colors ${t===l?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:l},l))})]})}function Ee({list:t,rules:s,onAdd:n,onRemove:a,disabled:o}){const[r,l]=j.useState(""),p=t==="allow"?"text-green-400":t==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${p}`,children:t}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:r,disabled:o,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(n(r),l(""))},placeholder:t==="allow"?"e.g. Bash(ls:*) or Read(~/.claude/**)":"e.g. Write(/etc/**)",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"}),e.jsx("button",{onClick:()=>{n(r),l("")},disabled:o||!r.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),s.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:s.map((u,c)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:u}),e.jsx("button",{onClick:()=>a(c),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${c}-${u}`))})]})}function Pe({dirs:t,onChange:s,disabled:n}){const[a,o]=j.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:a,disabled:n,onChange:r=>o(r.target.value),onKeyDown:r=>{r.key==="Enter"&&a.trim()&&(s([...t,a.trim()]),o(""))},placeholder:"/absolute/path/to/dir",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"})}),e.jsx("ul",{className:"space-y-0.5",children:t.map((r,l)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:r}),e.jsx("button",{onClick:()=>s(t.filter((p,u)=>u!==l)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${l}-${r}`))})]})}const Te={UserPromptSubmit:{when:"Fires just before the user prompt is sent to the model.",payload:"{ prompt: string }",example:"Block submission if the prompt mentions a secret."},UserPromptExpansion:{when:"Fires when a slash command expands into its final prompt text.",payload:"{ command: string, expanded: string }",example:"Audit which slash commands actually run, post-expansion."},PreToolUse:{when:"Fires before any tool runs. Can block the call.",payload:"{ tool_name: string, tool_input: object }",example:'matcher="Bash" — block dangerous shell commands.'},PostToolUse:{when:"Fires after a tool completes successfully.",payload:"{ tool_name: string, tool_input: object, tool_result: string }",example:'matcher="Write|Edit" — run a linter on changed files.'},PostToolUseFailure:{when:"Fires after a tool errors out (non-zero exit, exception, or refusal).",payload:"{ tool_name: string, tool_input: object, error: string }",example:"Pipe failed Bash runs into a desktop notification."},PostToolBatch:{when:"Fires once after a parallel batch of tool calls all complete.",payload:"{ tool_uses: Array<{ tool_name, tool_input, tool_result? }> }",example:"Aggregate file-edit batches into a single commit message."},Stop:{when:"Fires when the model emits end_turn.",payload:"{ stop_reason: string, output_tokens: number }",example:"Play a chime when the agent finishes a long task."},StopFailure:{when:"Fires when a turn aborts without end_turn (rate-limit, network, OOM).",payload:'{ reason: "rate_limit"|"network"|"oom"|"killed"|string }',example:"Auto-resume on transient failures."},SessionStart:{when:"Fires once when a session boots (claude or claude -p).",payload:'{ source: "startup"|"resume", model: string, agent_type: string }',example:"Inject a project-specific system prompt addendum."},SessionEnd:{when:"Fires once when the session terminates.",payload:'{ reason: "user_quit"|"timeout"|"error"|string }',example:"Persist transcript summary to ~/.claude/projects/<>."},Setup:{when:"Fires during interactive setup (claude /setup, /init).",payload:'{ mode: "init"|"reconfigure"|string }'},PreCompact:{when:"Fires before transcript compaction runs.",payload:'{ transcript_path: string, trigger: "manual"|"auto" }',example:"Snapshot the pre-compact transcript for later diffing."},PostCompact:{when:"Fires after compaction; the active transcript is the compacted one.",payload:'{ transcript_path: string, trigger: "manual"|"auto" }'},InstructionsLoaded:{when:"Fires after CLAUDE.md and any imported memory files are loaded.",payload:'{ source: "session_start"|"reload" }'},Notification:{when:"Fires when Claude Code emits a desktop notification.",payload:"{ title: string, message: string }",example:"Forward to your own notify-send / osascript pipeline."},PermissionRequest:{when:"Fires when a tool needs user permission (per the permissions block).",payload:"{ tool_name: string, tool_input?: object }",example:"Auto-allow npm test invocations."},PermissionDenied:{when:"Fires when the user (or policy) denies a permission request.",payload:"{ tool_name: string, retry: boolean }",example:"Track which tools the user habitually rejects."},SubagentStart:{when:"Fires when a subagent (Task tool) spawns.",payload:"{ agent_type: string }",example:'matcher="security-reviewer" — log every security scan.'},SubagentStop:{when:"Fires when a subagent finishes.",payload:'{ agent_type: string, reason: "end_turn"|"error"|string }'},TeammateIdle:{when:"Fires when a teammate agent goes idle (waiting for input).",payload:"{ teammate_id?: string }"},TaskCreated:{when:"Fires when a new Task is created via the Task tool.",payload:"{ task: { description: string, ...} }",example:"Track each spawned task in an external queue."},TaskCompleted:{when:"Fires when a Task completes (success or failure).",payload:"{ task: { description: string, ...} }"},ConfigChange:{when:"Fires when settings.json (any scope) is mutated mid-session.",payload:'{ source: "user_settings"|"project_settings"|"local_settings" }',example:"Reload tooling that depends on env vars on config change."},CwdChanged:{when:"Fires when the working directory changes (e.g. agent cd-ing).",payload:"{ old_cwd: string, new_cwd: string }",example:"Refresh project-scoped indexers when cwd drifts."},FileChanged:{when:"Fires when a watched file outside Claude Code's edits changes.",payload:'{ file_path: string, change_type: "modified"|"created"|"deleted" }',example:"Re-run typecheck when any .ts file changes."},WorktreeCreate:{when:"Fires after a git worktree is created via /worktree or subagent isolation.",payload:"{ worktree_path?: string, branch?: string }"},WorktreeRemove:{when:"Fires after a git worktree is removed.",payload:"{ worktree_path?: string }"},Elicitation:{when:"Fires when Claude asks the user a multiple-choice question.",payload:'{ action: "accept"|"reject", ...}'},ElicitationResult:{when:"Fires after the user resolves an elicitation prompt.",payload:"{ choice?: string }"}},te=["UserPromptSubmit","UserPromptExpansion","PreToolUse","PostToolUse","PostToolUseFailure","PostToolBatch","Stop","StopFailure","SessionStart","SessionEnd","Setup","PreCompact","PostCompact","InstructionsLoaded","Notification","PermissionRequest","PermissionDenied","SubagentStart","SubagentStop","TeammateIdle","TaskCreated","TaskCompleted","ConfigChange","CwdChanged","FileChanged","WorktreeCreate","WorktreeRemove","Elicitation","ElicitationResult"],Fe=new Set(te),Oe=["command","http","prompt","agent","mcp_tool"],Ae={UserPromptSubmit:{prompt:"hello"},UserPromptExpansion:{command:"/example",expanded:"hello"},PreToolUse:{tool_name:"Bash",tool_input:{command:"ls"}},PostToolUse:{tool_name:"Bash",tool_input:{command:"ls"},tool_result:""},PostToolUseFailure:{tool_name:"Bash",tool_input:{command:"ls"},error:""},PostToolBatch:{tool_uses:[]},Stop:{stop_reason:"end_turn",output_tokens:0},StopFailure:{reason:"rate_limit"},SessionStart:{source:"startup",model:"",agent_type:""},SessionEnd:{reason:"user_quit"},Setup:{mode:"init"},PreCompact:{transcript_path:"",trigger:"manual"},PostCompact:{transcript_path:"",trigger:"manual"},InstructionsLoaded:{source:"session_start"},Notification:{title:"test",message:"test notification"},PermissionRequest:{tool_name:"Bash"},PermissionDenied:{tool_name:"Bash",retry:!1},SubagentStart:{agent_type:"general-purpose"},SubagentStop:{agent_type:"general-purpose",reason:"end_turn"},TeammateIdle:{},TaskCreated:{task:{description:""}},TaskCompleted:{task:{description:""}},ConfigChange:{source:"user_settings"},CwdChanged:{old_cwd:"",new_cwd:""},FileChanged:{file_path:"",change_type:"modified"},WorktreeCreate:{},WorktreeRemove:{},Elicitation:{action:"accept"},ElicitationResult:{}},K="This settings file has invalid JSON. Fix it in the Settings raw editor first; Hooks will not overwrite it.";function Re(t){if(t.trim()==="")return{full:{},hooks:{},err:null};try{const s=JSON.parse(t);if(s===null||typeof s!="object"||Array.isArray(s))return{full:{},hooks:{},err:"settings file is not a JSON object"};const n=s;return{full:n,hooks:n.hooks??{},err:null}}catch(s){return{full:{},hooks:{},err:s.message}}}function Me(t,s){return(t[s]??[]).reduce((n,a)=>{var o;return n+(((o=a.hooks)==null?void 0:o.length)??0)},0)}function $e({scope:t="user"}={}){const s=L(),n=V(),a=(n==null?void 0:n.cwd)??null,o=z(x=>x.navFace),[r,l]=j.useState("events");j.useEffect(()=>{o==="project"&&r==="library"&&l("events")},[o,r]);const u=H(Y,s,a)[t]??null,c=e.jsx(U,{options:[{key:"events",label:"Events"},...o==="home"?[{key:"library",label:"Library"}]:[]],active:r,onChange:l});return s?r==="library"?e.jsx(F,{toolbar:c,children:e.jsx(ye,{})}):t!=="user"&&!a?e.jsx(F,{toolbar:e.jsx(e.Fragment,{children:c}),children:e.jsx(C,{title:"no active project"})}):u?e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[c,e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:u}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/hooks",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"hook reference ↗"})]}),children:e.jsx(se,{scope:t,cwd:a,path:u})}):e.jsx(C,{title:"loading…"}):e.jsx(C,{title:"loading…"})}function se({scope:t,cwd:s,path:n}){const[a,o]=j.useState("PreToolUse"),[r,l]=j.useState(null),p=(b,k)=>{window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:s,keyPath:b,value:k}).catch(m=>A.error(m instanceof Error?m.message:String(m)))},u=T(b=>b.files[n]),{hooks:c,err:x}=u?Re(u.draftRaw):{hooks:{},err:null},v=Object.keys(c).filter(b=>!Fe.has(b)),f=v.reduce((b,k)=>b+(c[k]??[]).reduce((m,y)=>{var w;return m+(((w=y.hooks)==null?void 0:w.length)??0)},0),0),i=(b,k)=>{if(x){A.error(K);return}p(["hooks",b],k)},d=c[a]??[],h=()=>{i(a,[...d,{matcher:"",hooks:[{type:"command",command:""}]}])},g=(b,k)=>{const m=d.slice();m[b]=k,i(a,m)},N=b=>{i(a,d.filter((k,m)=>m!==b))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full",children:[x?e.jsxs("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:[K," (",x,")"]}):null,f>0?e.jsxs("div",{className:"px-3 py-2 border-b border-line text-xs bg-bg-elev text-fg-dim",children:[e.jsx("span",{className:"text-yellow-400",children:"⚠"})," ",f," hook(s) configured under unknown event names: ",e.jsx("span",{className:"font-mono text-fg",children:v.join(", ")}),e.jsx("span",{className:"text-fg-faint",children:" · these are ignored by Claude Code 2026; edit settings.json directly to remove."})]}):null,e.jsx(je,{sidebarWidth:"14rem",sidebar:e.jsx("div",{className:"py-1",children:te.map(b=>{const k=Me(c,b),m=Te[b],y=m?e.jsxs("span",{className:"block space-y-1",children:[e.jsx("span",{className:"block text-fg",children:m.when}),e.jsxs("span",{className:"block text-fg-faint font-mono",children:["payload: ",m.payload]}),m.example?e.jsxs("span",{className:"block text-fg-faint italic",children:["e.g. ",m.example]}):null]}):e.jsx("span",{className:"text-fg-faint italic",children:"no documentation yet"});return e.jsx("div",{className:"[&>span]:w-full",children:e.jsx(de,{content:y,align:"bottom-center",children:e.jsxs("button",{onClick:()=>o(b),title:m==null?void 0:m.when,className:`w-full text-left px-3 py-1 text-xs ${a===b?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:b}),k>0&&e.jsx("span",{className:"text-accent shrink-0 ml-2",children:k})]}),m?e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:m.when}):e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 italic font-normal truncate",children:"no documentation yet"})]})})},b)})}),detail:e.jsxs("div",{className:"p-4 space-y-3 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg",children:a}),e.jsx("button",{onClick:h,disabled:!!x,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"+ add group"})]}),d.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no hooks for this event"}):d.map((b,k)=>e.jsx(Ie,{group:b,jsonInvalid:!!x,onChange:m=>g(k,m),onRemove:()=>N(k),onTestFire:m=>l({event:a,matcher:b.matcher??"",command:m.command??""})},k))]})})]}),r?e.jsx(Be,{event:r.event,matcher:r.matcher,command:r.command,onClose:()=>l(null)}):null]})}j.memo($e);function M({value:t,onCommit:s,onDraft:n,...a}){const[o,r]=j.useState(t);j.useEffect(()=>r(t),[t]);const l=()=>{o!==t&&s(o)};return e.jsx("input",{...a,value:o,onChange:p=>{r(p.target.value),n==null||n(p.target.value)},onBlur:l,onKeyDown:p=>{p.key==="Enter"&&l()}})}function Ie({group:t,jsonInvalid:s,onChange:n,onRemove:a,onTestFire:o}){const r=()=>n({...t,hooks:[...t.hooks??[],{type:"command",command:""}]}),l=(u,c)=>{const x=t.hooks.slice();x[u]=c,n({...t,hooks:x})},p=u=>n({...t,hooks:t.hooks.filter((c,x)=>x!==u)});return e.jsxs("div",{className:"border border-line rounded p-3 bg-bg-elev space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-fg-faint w-16",children:"matcher"}),e.jsx(M,{value:t.matcher??"",disabled:s,onCommit:u=>n({...t,matcher:u}),placeholder:"tool name regex or exact match (optional)",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:a,disabled:s,className:"text-fg-faint hover:text-red-400 text-xs disabled:opacity-40",title:"remove group",children:"× group"})]}),(t.hooks??[]).map((u,c)=>e.jsx(Le,{rule:u,jsonInvalid:s,onChange:x=>l(c,x),onRemove:()=>p(c),onTestFire:()=>o(u)},c)),e.jsx("button",{onClick:r,disabled:s,className:"text-xs text-fg-faint hover:text-fg disabled:opacity-40",children:"+ add hook"})]})}function De(t){var n,a,o;const s=((a=(n=Q.$defs)==null?void 0:n.hookCommand)==null?void 0:a.anyOf)??[];for(const r of s){const l=r.properties;if(((o=l==null?void 0:l.type)==null?void 0:o.const)!==t)continue;const p=l.timeout;if(typeof(p==null?void 0:p.default)=="number")return p.default;const u=/default:\s*(\d+)/.exec((p==null?void 0:p.description)??"");return u?Number(u[1]):null}return null}function G(t){return/^\d+$/.test(t.trim())&&Number(t)>0?Number(t):null}function Le({rule:t,jsonInvalid:s,onChange:n,onRemove:a,onTestFire:o}){const r=i=>({command:"e.g. node ./scripts/lint.js $FILE",http:"e.g. https://hooks.example.com/notify",prompt:"e.g. Review this change for security issues",agent:"e.g. security-reviewer",mcp_tool:"e.g. mcp__server__tool"})[i],l=t.type==="command"?"command":t.type==="http"?"url":t.type==="prompt"?"prompt":t.type==="mcp_tool"?"mcpTool":"agent",p=t[l]??"",u=(t.args??[]).join(" "),[c,x]=j.useState(null),v=De(t.type),f={type:"hook",name:p||t.type,command:t.type==="command"?t.command:void 0,url:t.type==="http"?t.url:void 0};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{value:t.type,disabled:s,onChange:i=>n({type:i.target.value}),className:"bg-bg border border-line rounded px-1 py-0.5 text-xs text-fg",children:Oe.map(i=>e.jsx("option",{value:i,children:i},i))}),e.jsx(ve,{interactive:!1,input:f}),e.jsx(M,{value:p,disabled:s,onCommit:i=>n({...t,[l]:i}),placeholder:r(t.type),className:`flex-1 bg-bg border rounded px-2 py-0.5 text-xs text-fg font-mono ${s?"border-red-500/70":p.trim()?"border-line":"border-yellow-600/50"}`}),s?e.jsx("span",{className:"text-red-400 text-xs",title:"The enclosing settings.json is malformed; fix the JSON before editing.",children:"× invalid"}):null,e.jsx(M,{value:t.timeout!=null?String(t.timeout):"",disabled:s,"aria-label":"timeout (seconds)","aria-invalid":c?!0:void 0,title:c??"Timeout in seconds",onDraft:i=>{x(!i.trim()||G(i)!=null?null:"Timeout must be a positive whole number of seconds")},onCommit:i=>{if(!i.trim()){n({...t,timeout:void 0});return}const d=G(i);d!=null&&n({...t,timeout:d})},placeholder:v!=null?`${v} (seconds)`:"seconds",className:`w-24 bg-bg border rounded px-2 py-0.5 text-xs text-fg ${c?"border-red-500/70":"border-line"}`}),c?e.jsx("span",{role:"alert",className:"text-red-400 text-xs",children:c}):null,t.type==="command"?e.jsx("button",{onClick:o,disabled:s||!p.trim(),className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",title:"Run this command with a fake event payload",children:"test fire"}):null,e.jsx("button",{onClick:a,disabled:s,className:"text-fg-faint hover:text-red-400 text-xs disabled:opacity-40",children:"×"})]}),t.type==="command"?e.jsxs("div",{className:"flex items-center gap-2 pl-[3.75rem]",children:[e.jsx("span",{className:"text-xs text-fg-faint w-12",children:"args"}),e.jsx(M,{value:u,disabled:s,onCommit:i=>n({...t,args:i.trim()?i.split(/\s+/).filter(Boolean):void 0}),placeholder:"argv array (v2.1.139+ exec form, no shell)",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"})]}):null,e.jsxs("div",{className:"flex items-center gap-2 pl-[3.75rem]",children:[e.jsx("span",{className:"text-xs text-fg-faint w-12",children:"term"}),e.jsx(M,{value:t.terminalSequence??"",disabled:s,onCommit:i=>n({...t,terminalSequence:i||void 0}),placeholder:"terminalSequence — e.g. \\\\a (bell), v2.1.141+",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"})]})]})}function He(t){return JSON.stringify(Ae[t]??{},null,2)}function Ue(t,s){if(!t.trim())return{matched:!0,target:null,note:"empty matcher → matches all"};const n=s&&typeof s=="object"&&"tool_name"in s?String(s.tool_name??""):null;if(n==null)return{matched:!1,target:null,note:"payload has no tool_name to match against"};try{return{matched:new RegExp(`^(?:${t})$`).test(n),target:n}}catch{return{matched:t===n,target:n,note:"matcher not valid regex; fell back to exact match"}}}function Be({event:t,matcher:s,command:n,onClose:a}){const[o,r]=j.useState(()=>He(t)),[l,p]=j.useState(!1),[u,c]=j.useState(null),[x,v]=j.useState(null);let f=null;try{JSON.parse(o)}catch(d){f=d.message}const i=async()=>{p(!0),c(null);let d=null;try{d=JSON.parse(o)}catch{}v(Ue(s,d));try{const h=await window.api.app.testFireHook({command:n,payload:o,timeoutMs:5e3});c(h)}finally{p(!1)}};return e.jsx(ue,{open:!0,onClose:a,title:`Test fire — ${t}`,children:e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"resolved command"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1 break-all",children:n})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1",children:s||e.jsx("span",{className:"text-fg-faint",children:"(empty — matches all)"})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-fg-faint",children:"fake event payload (stdin)"}),f?e.jsxs("span",{className:"text-red-400",children:["× ",f]}):null]}),e.jsx("textarea",{value:o,onChange:d=>r(d.target.value),rows:8,className:`w-full bg-bg border rounded px-2 py-1 font-mono text-fg ${f?"border-red-500/70":"border-line"}`})]}),x?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher result"}),e.jsxs("div",{className:"font-mono",children:[e.jsx("span",{className:x.matched?"text-green-400":"text-red-400",children:x.matched?"✓ match":"✗ no match"}),x.target!=null?e.jsxs("span",{className:"text-fg-dim",children:[' · target tool_name="',x.target,'"']}):null,x.note?e.jsx("div",{className:"text-fg-faint",children:x.note}):null]})]}):null,u?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-fg-faint",children:["exit ",u.exitCode," · ",u.durationMs,"ms"]}),u.stdout?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"stdout"}),e.jsx("pre",{className:"bg-bg border border-line rounded p-2 font-mono text-fg whitespace-pre-wrap break-all max-h-40 overflow-auto",children:u.stdout})]}):null,u.stderr?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"stderr"}),e.jsx("pre",{className:"bg-bg border border-line rounded p-2 font-mono text-red-300 whitespace-pre-wrap break-all max-h-40 overflow-auto",children:u.stderr})]}):null]}):null,e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:a,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"close"}),e.jsx("button",{onClick:i,disabled:l||!!f||!n.trim(),className:"px-2 py-0.5 text-xs border border-line rounded text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:l?"running…":"run"})]})]})})}const ne=[{id:"permissions",label:"Permissions",tab:"permissions",keys:["permissions"]},{id:"hooks",label:"Hooks",tab:"hooks",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",label:"MCP Servers",tab:null,keys:["enabledMcpjsonServers","disabledMcpjsonServers","enableAllProjectMcpServers"]},{id:"plugins",label:"Plugins",tab:null,keys:["enabledPlugins"]}],W=new Set(ne.flatMap(t=>t.keys)),Je=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],Ke={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function re(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((a,o)=>{const r=Ke[a];return r||(o===0?a.charAt(0).toUpperCase()+a.slice(1):a)}).join(" ")}function ae(t){const s=new Set,n=[];for(const o of Je){const r=o.keys.filter(l=>t.has(l)&&!W.has(l));r.forEach(l=>s.add(l)),r.length!==0&&n.push({id:o.id,title:o.title,summary:o.summary,advanced:!!o.advanced,keys:r})}const a=Array.from(t).filter(o=>!s.has(o)&&o!=="$schema"&&!W.has(o)).sort();return a.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:a}),n}function Ge(t,s){return ae(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(a=>s.has(a)).length}))}const We={};function oe(t,s){if(s)return{text:s,authored:!1};const n=We[t];return n?{text:n,authored:!0}:null}const qe={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},Ve=["user","project","local","default"],ze={user:"user",project:"project",local:"local",default:"default"};function Ye({node:t,targetScope:s,onOverride:n,schema:a}){const[o,r]=j.useState(""),[l,p]=j.useState(!1),[u,c]=j.useState(!0),x=t.kind==="object"?t:null,v=x?Object.keys(x.children):[],f=a.rootKeys(),i=new Set([...v,...f]),d=j.useMemo(()=>ae(i),[Array.from(i).sort().join(",")]),h=j.useMemo(()=>Ge(i,new Set(v)),[Array.from(i).sort().join(","),v.join(",")]),[g,N]=j.useState(null),b=j.useRef(null),k=y=>{const w=d.find(_=>_.id===y);w!=null&&w.advanced&&!l&&p(!0),N(y)};j.useEffect(()=>{if(!g)return;N(null);const y=b.current,w=document.getElementById(`settings-group-${g}`);if(!y||!w)return;const _=w.getBoundingClientRect().top-y.getBoundingClientRect().top;y.scrollBy({top:_,behavior:"smooth"})},[g]);const m=j.useMemo(()=>d.filter(y=>l||!y.advanced).map(y=>({...y,keys:y.keys.filter(w=>{const _=(x==null?void 0:x.children[w])!==void 0;if(!u&&!_)return!1;if(!o.trim())return!0;const E=a.at([w]);return[w,re(w),(E==null?void 0:E.description)??""].join(" ").toLowerCase().includes(o.toLowerCase())})})).filter(y=>y.keys.length>0),[d,o,l,u,x,a]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:S[s].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:y=>c(y.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:y=>p(y.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:o,onChange:y=>r(y.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(Ze,{groups:h,onJump:k}),e.jsxs("div",{ref:b,className:"flex-1 overflow-auto py-3",children:[m.map(y=>e.jsx(Qe,{id:y.id,title:y.title,summary:y.summary,advanced:y.advanced,children:y.keys.map(w=>{const _=x==null?void 0:x.children[w],E=a.at([w]);return e.jsx(Xe,{keyName:w,node:_,info:E,targetScope:s,onOverride:(R,$)=>n([w],R,$)},w)})},y.id)),m.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',o,'"']})]})]})]})}function Ze({groups:t,onJump:s}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:t.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${n.title}`,children:[e.jsx(pe,{name:qe[n.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:n.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[n.setCount,"/",n.total]})]},n.id))})}function Qe({id:t,title:s,summary:n,advanced:a,children:o}){const[r,l]=j.useState(!0);return e.jsxs("section",{id:`settings-group-${t}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>l(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:s}),a&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:n})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:o})]})}function Xe({keyName:t,node:s,info:n,targetScope:a,onOverride:o}){const[r,l]=j.useState(!1),[p,u]=j.useState(!1),c=re(t),x=s!==void 0,f=(s==null?void 0:s.kind)==="leaf"?s:null,i=(s==null?void 0:s.kind)==="object"||(s==null?void 0:s.kind)==="array",d=n==null?void 0:n.default,h=f&&d!==void 0&&le(f.value,d),g=it({isSet:x,leafNode:f,defaultVal:d,isDefault:!!h,node:s}),N=et(f,d),b=N.length>=2,k=!!f&&!h,m=oe(t,n==null?void 0:n.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>l(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:c}),e.jsx(lt,{kind:g.kind,label:g.label}),b&&e.jsxs("button",{onClick:y=>{y.stopPropagation(),r||l(!0),u(w=>!w)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",N.map(y=>ze[y]).join(" · ")]}),k&&f&&e.jsx("button",{onClick:y=>{y.stopPropagation(),o(void 0,f.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${S[f.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(n==null?void 0:n.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),m&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${m.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:m.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:ct(m.text)}),r&&p&&f&&e.jsx(tt,{leaf:f,defaultVal:d,onReset:y=>o(void 0,y)}),r&&e.jsx(st,{keyName:t,node:s,info:n,targetScope:a,onOverride:y=>o(y)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(ot,{node:s,info:n,onSet:y=>{o(y)},disabled:i&&x})})]})})}function et(t,s){if(!t)return[];const n=new Set;n.add(t.winner);for(const a of t.shadowed)n.add(a.scope);return s!==void 0&&n.add("default"),Ve.filter(a=>n.has(a))}function tt({leaf:t,defaultVal:s,onReset:n}){const a={};a[t.winner]={value:t.value,winner:!0};for(const o of t.shadowed)a[o.scope]={value:o.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(o=>{const r=a[o],l=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:S[o].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:l?O(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),l?e.jsx("button",{onClick:()=>n(o),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${S[o].label}`,children:"↺"}):e.jsx("span",{})]},o)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:s!==void 0?O(s):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function st({keyName:t,node:s,info:n,targetScope:a,onOverride:o}){const l=(s==null?void 0:s.kind)==="leaf"?s:null,p=oe(t,n==null?void 0:n.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:O(n.default)})]}),(n==null?void 0:n.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(u=>String(u)).join(" | ")})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:O(l.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",S[l.winner].label]})]})]}),l&&l.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:l.shadowed.map((u,c)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[O(u.value)," —"," ",e.jsx("span",{className:"no-underline",children:S[u.scope].label})]},c))})]}),(s==null?void 0:s.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[s.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(nt,{keyName:t,node:s,info:n,onChange:o,targetScope:a})})]})}function nt({node:t,info:s,onChange:n,targetScope:a}){const r=(t==null?void 0:t.kind)==="leaf"?t.value:s==null?void 0:s.default,l=ie(s==null?void 0:s.type);if(l==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:u,label:c})=>e.jsx("button",{onClick:()=>n(u),className:`px-3 py-0.5 text-xs transition-colors ${p===u?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:c},c))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",S[a].label]})]})}return s!=null&&s.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),s.enum.map(p=>{const u=le(r,p);return e.jsx("button",{onClick:()=>n(p),className:`px-2 py-0.5 text-xs rounded border ${u?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",S[a].label]})]}):l==="integer"||l==="number"?e.jsx(rt,{value:typeof r=="number"?r:void 0,integer:l==="integer",onCommit:n,target:S[a].label}):l==="string"?e.jsx(at,{value:typeof r=="string"?r:"",onCommit:n,target:S[a].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",l??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function rt({value:t,integer:s,onCommit:n,target:a}){const[o,r]=j.useState(t!==void 0?String(t):""),l=()=>{const p=s?parseInt(o,10):parseFloat(o);Number.isNaN(p)||n(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:o,onChange:p=>r(p.target.value),onBlur:l,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:l,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",a]})]})}function at({value:t,onCommit:s,target:n}){const[a,o]=j.useState(t);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:a,onChange:r=>o(r.target.value),onKeyDown:r=>{r.key==="Enter"&&s(a)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>s(a),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",n]})]})}function ot({node:t,info:s,onSet:n,disabled:a}){const o=(t==null?void 0:t.kind)==="leaf",r=ie(s==null?void 0:s.type);if(a)return null;if(r==="boolean"){const l=o&&t.value===!0;return e.jsx("button",{onClick:()=>n(!l),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${l?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:l?"on":"off"})}return null}function it({isSet:t,leafNode:s,defaultVal:n,isDefault:a,node:o}){return t?(o==null?void 0:o.kind)==="array"?{kind:"accumulated",label:`${o.items.length} items`}:(o==null?void 0:o.kind)==="object"?{kind:"set",label:"configured"}:s?a?{kind:"default",label:`= default · ${S[s.winner].label}`}:s.shadowed.length>0?{kind:"override",label:`overriding ${s.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${S[s.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${O(n)}`}:{kind:"unset",label:"not configured"}}function lt({kind:t,label:s}){const n={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[t];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:s})}function ie(t){if(t)return Array.isArray(t)?t.find(n=>n!=="null")??t[0]:t}function le(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(s):!1}function ct(t){const s=t.trim().split(`
|
|
2
|
-
`)[0],n=s.match(/^([^.!?]+[.!?])/);return n?n[1]:s.length>120?s.slice(0,120)+"…":s}function O(t){if(typeof t=="string")return t===""?'""':JSON.stringify(t);if(t===null)return"null";if(t===void 0)return"—";if(typeof t=="object"){const s=JSON.stringify(t);return s.length>60?s.slice(0,60)+"…":s}return String(t)}function dt({cwd:t}){const[s,n]=j.useState(!1),[a,o]=j.useState(!1),[r,l]=j.useState(!1),[p,u]=j.useState(!1);j.useEffect(()=>{var i,d;let f=!1;return n(!1),Promise.resolve((d=(i=window.api.promptSessions)==null?void 0:i.getWorktreeDisabled)==null?void 0:d.call(i,{cwd:t})).then(h=>{f||(o((h==null?void 0:h.disabled)??!1),l((h==null?void 0:h.disabled)??!1),n(!0))},()=>{f||n(!0)}),()=>{f=!0}},[t]);const c=s&&r!==a,x=()=>{var f,i;u(!0),Promise.resolve((i=(f=window.api.promptSessions)==null?void 0:f.setWorktreeDisabled)==null?void 0:i.call(f,{cwd:t,disabled:r})).then(d=>{o((d==null?void 0:d.disabled)??r),l((d==null?void 0:d.disabled)??r)}).catch(d=>A.error(d instanceof Error?d.message:String(d))).finally(()=>u(!1))},v=()=>l(a);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:!s||p,onChange:f=>l(f.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),c&&e.jsx(Z,{dirty:c,busy:p,onSave:x,onRevert:v})]})}const q={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function ut({effective:t,onOpenTab:s}){return e.jsx("ul",{"data-testid":"settings-owned-summaries",className:"px-3 py-2 space-y-1 text-[11.5px] border-b border-line",children:ne.map(n=>{const a=n.keys.filter(r=>ge(t,[r])!==null),o=a.length?`${a.length} of ${n.keys.length} keys set (${a.join(", ")})`:"nothing set";return e.jsxs("li",{"data-testid":`owned-summary-${n.id}`,className:"flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg w-28 shrink-0",children:n.label}),e.jsx("span",{className:"truncate",children:o}),n.tab?e.jsxs("button",{type:"button",onClick:()=>s(n.tab),className:"ml-auto text-accent hover:underline shrink-0",children:["edit in ",n.label," tab →"]}):e.jsxs("span",{className:"ml-auto text-fg-faint shrink-0",children:["managed on the ",n.label," page"]})]},n.id)})})}function pt({scope:t="user"}={}){const s=L(),n=B(m=>m.tabs),a=B(m=>m.activeTabId),o=n.find(m=>m.id===a)??null,r=(o==null?void 0:o.cwd)??null,[l,p]=j.useState("general");me("settings",m=>{(m==="general"||m==="permissions"||m==="hooks"||m==="raw")&&p(m)});const u=H(Y,s,r),c=u[t]??null,x=T(m=>m.files),v=T(m=>m.setDraft),f=T(m=>m.saveJson),i=T(m=>m.revert),[d,h]=j.useState(null),g=j.useMemo(()=>xe(he(x,u)),[x,u]),N=(m,y,w)=>{var $;const _=w??t,E=u[_];if(!E)return;const R=(($=x[E])==null?void 0:$.draftRaw)??"";if(R.trim())try{JSON.parse(R)}catch(P){h(`${E} is not valid JSON (${P instanceof Error?P.message:String(P)}) — fix it in Raw before editing from General.`);return}h(null),window.api.claudeConfig.patch({fileId:"settings",scope:_,cwd:r,keyPath:m,value:y}).catch(P=>A.error(P instanceof Error?P.message:String(P)))};if(!s)return e.jsx(C,{title:"loading…"});const b=c?x[c]:null,k=m=>m!=="user"&&!r;return e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(U,{options:[{key:"general",label:"General"},{key:"permissions",label:"Permissions"},{key:"hooks",label:"Hooks"},{key:"raw",label:"Raw"}],active:l,onChange:p}),e.jsx(e.Fragment,{children:e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:l==="general"?`overrides → ${c??"—"}`:c??"—"})}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:l==="raw"&&c&&b?e.jsx(Z,{dirty:b.dirty,busy:b.busy,parseError:d||b.parseError,lastSavedAt:b.lastSavedAt,leading:b.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{h(null);const m=await f(c);m.ok||h(m.error??"save failed")},onRevert:()=>{h(null),i(c)}}):null,children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:q[t].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:q[t].body}),c&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:c})]}),d&&l!=="raw"&&e.jsx("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:d}),t==="project"&&r&&e.jsx(dt,{cwd:r}),k(t)?e.jsx(C,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):l==="general"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c??""})}),e.jsx(ut,{effective:g,onOpenTab:p}),e.jsx(Ye,{node:g,targetScope:t,onOverride:N,schema:X()})]}):l==="permissions"?c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c,keyPath:["permissions"]})}),e.jsx(ee,{scope:t,cwd:r,activePath:c})]}):e.jsx(C,{title:"resolving…"}):l==="hooks"?c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c,keyPath:["hooks"]})}),e.jsx(se,{scope:t,cwd:r,path:c})]}):e.jsx(C,{title:"resolving…"}):c&&b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c})}),e.jsx(fe,{path:c,value:b.draftRaw,onChange:m=>{h(null),v(c,m)}})]}):e.jsx(C,{title:"resolving…"})]})})}const wt=j.memo(pt);export{q as SETTINGS_SCOPE_NOTES,wt as Settings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aJ as a,b3 as g,at as e,a7 as M,a$ as B,b8 as $,ar as z,as as H,aX as J,ab as V,f as W,i as U,s as A,r as F,j as X,ae as q,b9 as G,C as K,l as I,ad as Q}from"./index-CuAfFXNd.js";import{P as Y}from"./Panel-B-3NWUlv.js";import{S as Z,I as ee}from"./Library-C5wKMTSn.js";import{S as te}from"./SourceChip-DcBNYYhe.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-DSoqrxCB.js";const se=300;function re({activePath:r,selectedPath:s,onSelect:n}){const[u,t]=a.useState([]),p=a.useRef(0),N=a.useRef(n);N.current=n;const j=g(i=>{var o;return r?(o=i.files[r])==null?void 0:o.diskRaw:void 0}),m=a.useRef(null);if(a.useEffect(()=>{N.current(null)},[r]),a.useEffect(()=>{if(p.current+=1,!r){m.current=null,t([]);return}const i=m.current!==r;m.current=r;let o=!1;const f=()=>{p.current+=1;const h=p.current;window.api.config.parseImports(r).then(b=>{o||p.current!==h||(b.ok?t(b.imports):(t([]),B.error(b.error||"failed to parse @-imports")))})},y=i?null:setTimeout(f,se);return i&&f(),()=>{o=!0,y&&clearTimeout(y)}},[r,j]),u.length===0||!r)return null;const d=s===r||s===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",u.length+1]}),e.jsxs("button",{type:"button",onClick:()=>n(null),"aria-current":d,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:M(r)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:r,children:"this system prompt"})]}),u.map(i=>{const o=!i.ok||!i.exists,f=s===i.path;return e.jsxs("button",{type:"button",onClick:()=>n(i),"aria-current":f,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${f?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:M(i.path)}),o&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:i.path,children:i.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[i.sizeBytes.toLocaleString()," bytes · ~",i.tokenEstimate.toLocaleString()," tokens"]})]},i.path)})]})}function ne({path:r,value:s,onChange:n,onSave:u,readOnly:t,defaultMode:p,headerRight:N,hideStatusBar:j}){const m=$(),d=z(r),i=H(r),o=J(r),[f,y]=a.useState(()=>t&&i?"preview":p??V(r)),[h,b]=a.useState(!0),[D,v]=a.useState(null),C=a.useRef(null),k=a.useRef(null),x=a.useCallback(c=>{C.current=c},[]),S=a.useCallback(()=>C.current,[]),R=t?i?["preview","edit"]:[]:o?["edit","preview","split"]:i?["edit","preview"]:[],w=i?f:"edit",E=e.jsx(W,{path:r,name:M(r),value:s,onChange:n,onSave:()=>u==null?void 0:u(),onReady:x,onCursor:v,readOnly:t});return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"document-editor-pane",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-7 shrink-0 border-b border-line bg-bg-elev",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg truncate",children:M(r)}),t&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-fg-faint border border-line",children:"read-only"}),e.jsx("div",{className:"flex-1"}),N,d&&(w==="preview"||w==="split")&&e.jsx("button",{onClick:()=>b(c=>!c),"data-testid":"document-outline-toggle",className:`px-2 py-0.5 text-[10px] border border-line rounded ${h?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),R.length>0&&e.jsx("div",{className:"flex items-center ml-1 rounded border border-line overflow-hidden","data-testid":"document-mode-toggle",children:R.map(c=>e.jsx("button",{onClick:()=>y(c),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${w===c?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:c},c))})]}),e.jsx("div",{className:"flex-1 min-h-0",children:w==="split"&&d?e.jsxs("div",{className:"flex h-full",children:[h&&e.jsx(U,{text:s,scrollRef:k}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[!t&&e.jsx(A,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:E})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(F,{ref:k,text:s,flush:!0,wideMeasure:m.wideMeasure})})]}):w==="preview"&&d?e.jsxs("div",{className:"flex h-full",children:[h&&e.jsx(U,{text:s,scrollRef:k}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(F,{ref:k,text:s,wideMeasure:m.wideMeasure})})]}):d?e.jsxs("div",{className:"flex flex-col h-full",children:[!t&&e.jsx(A,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:E})]}):E}),!j&&e.jsx(X,{text:s,cursor:D,language:q(r)||void 0})]})}const O={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function le(){const r=G(),s=a.useMemo(()=>r?K.resolve("user",r,null):null,[r]),[n,u]=a.useState(null),t=(n==null?void 0:n.path)??s,[p,N]=a.useState({});a.useEffect(()=>{const l=n==null?void 0:n.path;if(!l||!n.ok||!n.exists)return;let L=!0;return Promise.resolve().then(()=>window.api.config.canWrite(l)).then(P=>{L&&N(_=>({..._,[l]:P===!1}))}).catch(()=>{}),()=>{L=!1}},[n]);const j=!!n&&p[n.path]===!0,m=!!n&&(!n.ok||!n.exists||j),d=g(l=>l.files),i=g(l=>l.loadText),o=g(l=>l.setDraft),f=g(l=>l.saveText),y=g(l=>l.revert),h=g(l=>l.watchFile),b=g(l=>l.unwatchFile);a.useEffect(()=>{if(s)return i(s,!0),h(s),()=>{b(s)}},[s]),a.useEffect(()=>{if(!(!t||t===s))return i(t,!0),h(t),()=>{b(t)}},[t,s]);const[D,v]=a.useState(null),C=a.useCallback(l=>{v(null),u(l)},[]);if(!r)return e.jsx(I,{title:"loading…"});const k=s?d[s]:null,x=t?d[t]:null,S=(x==null?void 0:x.draftRaw)??"",R=Q(S),w=S.length,E=m&&!j,c=m,T=async()=>{if(!t)return;v(null);const l=await f(t);l.ok||v(l.error??"save failed")};return e.jsx(Y,{toolbar:e.jsxs(e.Fragment,{children:[s&&e.jsx(ee,{path:s,disabled:!!n}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:t??"—"}),s&&e.jsx("span",{className:"ml-3",children:e.jsx(te,{path:s})}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[w.toLocaleString()," chars · ~",R.toLocaleString()," tokens"]})]}),footer:t&&x&&!c?e.jsx(Z,{dirty:x.dirty,busy:x.busy,parseError:D,lastSavedAt:x.lastSavedAt,leading:x.exists?n?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:T,onRevert:()=>{v(null),y(t)}}):null,children:s&&k?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:O.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:O.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:s})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(re,{activePath:s,selectedPath:t,onSelect:C}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[E&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),j&&n&&e.jsxs("div",{"data-testid":"system-prompt-readonly-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:["Read-only: ",e.jsx("span",{className:"font-mono",children:n.path})," is outside the folders Session Manager may write to."]}),t&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(ne,{path:t,value:S,readOnly:c,defaultMode:"split",onChange:l=>{v(null),o(t,l)},onSave:()=>{T()}},t)})]})]})]}):e.jsx(I,{title:"resolving…"})})}const ue=a.memo(le);export{ue as SystemPrompt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{at as t}from"./index-CuAfFXNd.js";function n({options:r,active:o,onChange:i}){return t.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:r.map(({key:e,label:s})=>t.jsx("button",{onClick:()=>i(e),className:`px-2 py-0.5 text-xs ${o===e?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},e))})}export{n as V};
|