claude-code-session-manager 0.129.0 → 0.130.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/assets/AgentLibrary-ctvNes4y.js +2 -0
- package/dist/assets/AppSettings-C03qTDSi.js +2 -0
- package/dist/assets/Button-fOCJry21.js +1 -0
- package/dist/assets/Extensions-BWiDwigT.js +13 -0
- package/dist/assets/{History-B2x-LMlT.js → History-BIQFPXM8.js} +2 -2
- package/dist/assets/Library-BGmD-xZN.js +32 -0
- package/dist/assets/ListDetail-BeO3lY8t.js +1 -0
- package/dist/assets/{Memory-CnalwnFf.js → Memory-BeXuYIcE.js} +8 -8
- package/dist/assets/{Panel-BzIklgKf.js → Panel-OUbLHNsS.js} +1 -1
- package/dist/assets/ProvenanceBadge-kr7arZqu.js +1 -0
- package/dist/assets/Scheduler-DycegnjH.js +16 -0
- package/dist/assets/Settings-BSq6VASG.js +2 -0
- package/dist/assets/{SkillReferenceGraph-DOhiCxuL.js → SkillReferenceGraph-CvPdxg56.js} +1 -1
- package/dist/assets/SourceChip-C2YMnlV8.js +1 -0
- package/dist/assets/SystemPrompt-fpXEK_Rm.js +1 -0
- package/dist/assets/{TiptapBody-Du6jRBoW.js → TiptapBody-DusJg0je.js} +1 -1
- package/dist/assets/{Toggle-Qdi2Z7VD.js → Toggle-BnJF4V6k.js} +1 -1
- package/dist/assets/ViewTabs-BYrRSHb6.js +1 -0
- package/dist/assets/VoiceButton-Bk66E-fP.js +1 -0
- package/dist/assets/{historyTotals-8ecP_6wF.js → historyTotals-DnuVADtI.js} +1 -1
- package/dist/assets/{index-DtdWBGrI.css → index-Bp8XE9A6.css} +1 -1
- package/dist/assets/index-DfWJO7nP.js +3086 -0
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +390 -406
- package/package.json +1 -1
- package/plugins/CLAUDE.md +2 -2
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +2 -2
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +2 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -3
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +62 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +169 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +183 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +39 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +79 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +400 -0
- package/scripts/scheduler-mcp-server.cjs +25 -6
- package/src/main/agentLibrary.cjs +36 -10
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +15 -0
- package/src/main/health.cjs +49 -22
- package/src/main/index.cjs +19 -3
- package/src/main/ipcSchemas.cjs +36 -3
- package/src/main/lib/claude/modelCatalog.cjs +15 -31
- package/src/main/lib/claudeConfig.cjs +156 -0
- package/src/main/lib/effectiveSettings.cjs +120 -0
- package/src/main/lib/epic/delegationReadiness.cjs +3 -3
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +84 -11
- package/src/main/lib/git/gitWorktree.cjs +400 -9
- package/src/main/lib/git/runtimeStateUntrack.cjs +124 -0
- package/src/main/lib/mcpToolCatalog.cjs +8 -2
- package/src/main/lib/memoryDirResolve.cjs +2 -8
- package/src/main/lib/opsOwnership.cjs +63 -2
- package/src/main/lib/persona-macro/builtinMacros.cjs +30 -0
- package/src/main/lib/persona-macro/macroLibrary.cjs +34 -6
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +22 -0
- package/src/main/lib/updateCheck.cjs +6 -1
- package/src/main/pluginInstall.cjs +100 -1
- package/src/main/scheduler.cjs +12 -2
- package/src/main/seedDevPlugin.cjs +2 -1
- package/src/main/templates/PRD_AUTHORING.md +3 -3
- package/src/main/updaterIpc.cjs +5 -1
- package/src/main/usage.cjs +5 -20
- package/src/main/voiceHotkey.cjs +16 -0
- package/src/main/voiceSettings.cjs +24 -0
- package/src/main/voiceWizard.cjs +27 -36
- package/src/preload/api.d.ts +53 -2
- package/src/preload/apiSurface.json +63 -7
- package/src/preload/index.cjs +12 -1
- package/src/seed/agents/demo-video-builder.md +2 -2
- package/src/seed/agents/validator.md +2 -2
- package/dist/assets/AgentLibrary-Cp250YHF.js +0 -2
- package/dist/assets/Button-DU5UF-6L.js +0 -1
- package/dist/assets/DataModel-CPf6f17e.js +0 -1
- package/dist/assets/Hooks-BWr33C4Q.js +0 -3
- package/dist/assets/Library-DBNLTAa8.js +0 -46
- package/dist/assets/ListDetail-BGBw6egp.js +0 -1
- package/dist/assets/McpServers-DywZ50Ec.js +0 -2
- package/dist/assets/Permissions-mgRifwQc.js +0 -3
- package/dist/assets/Plugins-CV42zfid.js +0 -2
- package/dist/assets/ProvenanceBadge-DYmX4xgB.js +0 -1
- package/dist/assets/SaveBar-DxrAfnlC.js +0 -1
- package/dist/assets/Scheduler-iyUl1NDl.js +0 -16
- package/dist/assets/ScopeSwitcher-CC8BDPgf.js +0 -1
- package/dist/assets/Settings-CWBnQghD.js +0 -4
- package/dist/assets/Skills-3Er-9YA9.js +0 -2
- package/dist/assets/SystemPrompt-BLxdvZ9K.js +0 -1
- package/dist/assets/TagLibrary-BZ6QHYMQ.js +0 -1
- package/dist/assets/ViewTabs-BKfFsziD.js +0 -1
- package/dist/assets/index-GI6F_j41.js +0 -3083
- package/dist/assets/listSkills-C1aWKf0T.js +0 -1
- package/dist/assets/settingsSchema-lHTHAabD.js +0 -1
- package/dist/assets/skillFrontmatter-8X1Uc282.js +0 -10
- package/dist/assets/useAgentsDirWatch-CcsoD1bp.js +0 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"name": "session-manager-dev",
|
|
15
15
|
"source": "./plugins/session-manager-dev",
|
|
16
16
|
"description": "Default end-to-end development skillset — pairs with the session-manager scheduler to form a develop → queue → validate → release loop.",
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.3.5",
|
|
18
18
|
"category": "development",
|
|
19
19
|
"strict": false
|
|
20
20
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b9 as X,b4 as ve,aJ as y,Y as P,b1 as Z,a$ as N,at as e,l as K,a_ as z,a6 as je,ay as A,bk as we,b as V,aY as Ne,bc as ee,M as ye,d as Y,E as $e}from"./index-DfWJO7nP.js";import{P as te}from"./Panel-OUbLHNsS.js";import{L as ne}from"./ListDetail-BeO3lY8t.js";import{V as Ce}from"./ViewTabs-BYrRSHb6.js";import{S as se}from"./SourceChip-C2YMnlV8.js";import{B as R}from"./Button-fOCJry21.js";import{r as ke}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";function ae(t,s){const a=X();ve([a?`${a}/.claude/agents`:null,t?`${t}/.claude/agents`:null],s)}function Se({onOpenPersona:t}){const[s,a]=y.useState(P[0].tag),{personas:d,refresh:l}=Z(o=>N.error(o.message||"failed to load agent personas"));ae(null,()=>{l()});const r=P.find(o=>o.tag===s)??null;return e.jsx(te,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[P.length," tag",P.length===1?"":"s"]}),children:e.jsx(ne,{sidebar:e.jsx("div",{className:"py-1",children:P.map(o=>{const p=z(o.tag),b=s===o.tag,c=(d==null?void 0:d.filter(v=>v.tags.includes(o.tag)).length)??0;return e.jsxs("button",{onClick:()=>{a(o.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${b?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${p.bg} ${p.text} ${p.border?"border border-current/30":""}`,children:["#",o.tag]}),e.jsx("span",{className:"truncate",children:o.label}),c>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:c})]},o.tag)})}),detail:r?e.jsx(Ee,{entry:r,personas:d,onOpenPersona:t}):e.jsx(K,{title:"select a tag"})})})}const Le=y.memo(Se);function Ee({entry:t,personas:s,onOpenPersona:a}){const d=z(t.tag),l=je(t.tag),r=(s==null?void 0:s.filter(o=>o.tags.includes(t.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${d.bg} ${d.text} ${d.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),s===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.map(o=>e.jsx("button",{onClick:()=>a==null?void 0:a(o.name),title:`Open ${o.name} in Personas`,className:"inline-flex items-center bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg hover:bg-bg-hi",children:o.name},o.name)),r.length===0&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:l.initialPromptTemplate})]})]})}const De=new Set(P.map(t=>t.tag));function oe(t){return t.filter(s=>De.has(s))}function Te(t,s={}){return{name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??void 0,color:t.color??"",tags:oe(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...s}}const Oe=t=>{const[s,a]=t.split(".");return Number(s)+(a?Number(a)/100:0)};function Re(t){const s=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!s)return[];const a=[];for(const d of s[1].split(/,\s*|\s+and\s+/)){const l=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(d.trim());l&&a.push({family:l[1].toLowerCase(),version:Oe(l[2])})}return a}var q,Q;const Pe=Re(String(((Q=(q=ke.properties)==null?void 0:q.effortLevel)==null?void 0:Q.description)??""));function Ae(t,s){const a=new RegExp(`${s}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(a)return Number(a[1])+(a[2]?Number(a[2])/100:0);const d=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${s}`,"i").exec(t);return d?Number(d[1])+(d[2]?Number(d[2])/100:0):null}function Fe(t,s=Pe){if(!t||t==="inherit"||s.length===0)return null;const a=A(t);if(!a)return null;const d=s.filter(r=>r.family===a);if(d.length===0)return!1;const l=Ae(t,a);return l===null?null:l>=Math.min(...d.map(r=>r.version))}const H=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Be=["","red","orange","yellow","green","cyan","blue","purple","pink"],re={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function _(t){return{name:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??"inherit",color:t.color??"",tags:t.tags,body:t.body}}const J={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""};function Me(t){return t.overridingProjects.map(s=>{var l;const a=(l=t.overrideDetails)==null?void 0:l.find(r=>r.project===s);if(!a)return s;const d=[...a.fields.filter(r=>r!=="name"),...a.bodyOverridden?["full body"]:[]];return`${s}: ${d.join(", ")||"overlay"}`}).join(`
|
|
2
|
+
`)}function Ve(){const[t,s]=y.useState("personas"),{personas:a,refresh:d}=Z(n=>N.error(n.message||"failed to load agent personas")),[l,r]=y.useState(null),[o,p]=y.useState(""),[b,c]=y.useState(null),[v,h]=y.useState(!1),[$,S]=y.useState(!1),[g,C]=y.useState(null),[L,k]=y.useState(!1),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1},[]);const i=we(n=>{var u;return((u=n.tabs.find(T=>T.id===n.activeTabId))==null?void 0:u.cwd)??null}),w=i?i.replace(/\/+$/,"").split("/").pop()||i:null,j=async n=>{await d()&&n&&r(n)};ae(i,()=>j()),y.useEffect(()=>{const n=Ne();n&&r(n);const u=T=>r(T.detail);return window.addEventListener("sm:select-persona",u),()=>window.removeEventListener("sm:select-persona",u)},[]);const O=e.jsx(Ce,{options:[{key:"personas",label:"Personas"},{key:"tags",label:"Tags"}],active:t,onChange:s});if(t==="tags")return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-line",children:O}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Le,{onOpenPersona:n=>{r(n),c(null),h(!1),s("personas")}})})]});if(a===null)return e.jsx(K,{title:"loading…"});const F=o.toLowerCase(),B=a.filter(n=>!F||n.name.toLowerCase().includes(F)||(n.description??"").toLowerCase().includes(F)),f=a.find(n=>n.name===l)??a[0]??null,x=b??(f?_(f):null),M=!!b&&!!f&&JSON.stringify(b)!==JSON.stringify(_(f)),m=v,I=n=>{c(null),h(!1),S(!1),C(null),r(n)},de=n=>c(u=>({...u??(f?_(f):J),...n})),ce=()=>{c({...J}),h(!0),S(!1)},fe=()=>{x&&(c({...x,name:x.name+"-copy"}),h(!0))},xe=()=>{c(null),h(!1)},me=async()=>{if(x){if(!/^[a-z][a-z0-9-]*$/.test(x.name)){N.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}k(!0);try{const n=m?null:f,u={name:x.name,originalName:n==null?void 0:n.name,description:x.description,tools:x.tools,model:x.model,effort:x.effort,color:x.color,tags:oe(x.tags),body:x.body},T=n?Te(n,u):u;await window.api.agents.savePersona(T),N.info(m?`created ${x.name}`:`saved ${x.name}`),c(null),h(!1),await j(x.name)}catch(n){N.error(n.message||"failed to save agent persona")}finally{k(!1)}}},ge=async()=>{if(f){k(!0);try{await window.api.agents.deletePersona({name:f.name}),N.info(`deleted ${f.name}`),S(!1),c(null),h(!1),await j()}catch(n){N.error(n.message||"failed to delete agent persona")}finally{k(!1)}}},he=async n=>{k(!0);try{await window.api.agents.deletePersona({name:n}),N.info(`deleted ${n}`),C(null),l===n&&(c(null),h(!1)),await j()}catch(u){N.error(u.message||"failed to delete agent persona")}finally{k(!1)}},pe=async n=>{if(f)try{await window.api.agents.removeOverride({name:f.name,projectName:n}),N.info(`removed ${n}'s override of ${f.name}`),await j(f.name)}catch(u){N.error(u.message||"failed to remove override")}},ue=async n=>{if(!(!f||!w)){k(!0);try{n.model==="inherit"&&n.effort==="inherit"?(await window.api.agents.removeOverride({name:f.name,projectName:w}),N.info(`cleared ${w}'s override of ${f.name}`)):(await window.api.agents.savePersona({name:f.name,projectName:w,description:"",tools:[],color:"",tags:[],body:"",model:n.model,effort:n.effort}),N.info(`saved ${w}'s override of ${f.name}`)),await j(f.name)}catch(u){N.error(u.message||"failed to save project override")}finally{k(!1)}}};return e.jsx(te,{toolbar:e.jsxs(e.Fragment,{children:[O,e.jsxs("span",{className:"text-fg-faint",children:[a.length," persona",a.length===1?"":"s"]}),e.jsx("input",{value:o,onChange:n=>p(n.target.value),placeholder:"filter…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-40"}),e.jsx("div",{className:"flex-1"}),e.jsx(R,{variant:"primary",onClick:ce,children:"+ New agent"})]}),children:e.jsx(ne,{sidebar:e.jsxs("div",{className:"py-1",children:[m&&e.jsx("div",{className:"w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 bg-bg-hi text-fg border-l-2 border-accent",children:e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsx("span",{className:"truncate font-mono",children:x==null?void 0:x.name}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-accent",children:"new"})]})}),B.length===0&&!m?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):B.map(n=>{const u=!m&&n.name===l,T=u&&M,be=g===n.name;return e.jsxs("div",{"data-agent-row":n.name,className:`group w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 border-l-2 cursor-pointer ${u?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,onClick:()=>I(n.name),children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:n.color?re[n.color]??n.color:"var(--fg-faint, #999)",opacity:n.color?1:.35}}),e.jsx("span",{className:"truncate font-mono",children:n.name})]}),e.jsxs("span",{className:"shrink-0 flex items-center gap-1.5",children:[T&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!T&&n.overridingProjects.length>0&&e.jsx("span",{title:Me(n),children:e.jsxs(V,{tone:"dim",children:[n.overridingProjects.length," override",n.overridingProjects.length>1?"s":""]})}),be?e.jsxs("span",{className:"flex items-center gap-1",onClick:W=>W.stopPropagation(),children:[e.jsx("button",{onClick:()=>he(n.name),disabled:L,title:`Delete ${n.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>C(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{onClick:W=>{W.stopPropagation(),C(n.name)},title:`Delete ${n.name}`,className:"opacity-0 group-hover:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})]}),n.description&&e.jsx("span",{className:"truncate text-fg-faint",children:n.description})]},n.name)})]}),detail:x?e.jsx(Ie,{obj:x,set:de,saved:f,dirty:M,isNew:m,busy:L,confirmDelete:$,setConfirmDelete:S,onDuplicate:fe,onRevert:xe,onSave:me,onDelete:ge,onDropOverride:pe,activeProject:w,activeCwd:i,onSaveOverride:ue}):e.jsx(K,{title:"select an agent"})})})}const qe=y.memo(Ve);function Ie({obj:t,set:s,saved:a,dirty:d,isNew:l,busy:r,confirmDelete:o,setConfirmDelete:p,onDuplicate:b,onRevert:c,onSave:v,onDelete:h,onDropOverride:$,activeProject:S,activeCwd:g,onSaveOverride:C}){const L=X(),k=!l&&a?a.path:`${L??"~"}/.claude/agents/${t.name}.md`,E=d||l;return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-line flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-fg font-mono",children:t.name}),l?e.jsx(V,{tone:"accent",children:"unsaved draft"}):d?e.jsx(V,{tone:"warn",children:"edited"}):e.jsx(V,{tone:"good",children:"saved"}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(se,{path:k})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(D,{label:"name",hint:"Filename on disk — lowercase, hyphenated.",children:e.jsx("input",{value:t.name,onChange:i=>s({name:i.target.value.toLowerCase()}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})}),e.jsx(D,{label:"description",hint:"Shown in the list and in agent pickers.",children:e.jsx("input",{value:t.description,onChange:i=>s({description:i.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})}),e.jsx(ie,{value:t.model,onChange:i=>s({model:i})}),e.jsx(le,{value:t.effort,model:t.model,onChange:i=>s({effort:i})}),!l&&a&&e.jsx(We,{saved:a,activeProject:S,activeCwd:g,busy:r,onSave:C}),e.jsx(D,{label:"tools",hint:`${t.tools.length} of ${H.length} granted. Anything not ticked is refused at call time.`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:H.map(i=>{const w=t.tools.includes(i);return e.jsx("button",{onClick:()=>s({tools:w?t.tools.filter(j=>j!==i):[...t.tools,i]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${w?"bg-sage/15 text-sage-dark border-sage/30":"bg-bg-hi text-fg-faint border-line"}`,children:i},i)})})}),e.jsx(D,{label:"color",children:e.jsx("div",{className:"flex gap-1.5",children:Be.map(i=>e.jsx("button",{title:i||"none",onClick:()=>s({color:i}),className:"w-5 h-5 rounded",style:{background:i?re[i]:"transparent",border:t.color===i?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},i||"none"))})}),e.jsx(D,{label:"tags",hint:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab.",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:P.map(i=>{const w=t.tags.includes(i.tag),j=z(i.tag);return e.jsxs("button",{onClick:()=>s({tags:w?t.tags.filter(O=>O!==i.tag):[...t.tags,i.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${w?`${j.bg} ${j.text} ${j.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",i.tag]},i.tag)})})}),e.jsx(D,{label:"definition",hint:"The system prompt this persona runs under.",children:e.jsx("textarea",{rows:9,value:t.body,onChange:i=>s({body:i.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono leading-relaxed resize-y"})}),e.jsx(D,{label:"project overrides",hint:"Open projects that shadow this definition with a local copy.",children:a&&a.overridingProjects.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.overridingProjects.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[i,e.jsx("button",{onClick:()=>$(i),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},i))}):e.jsx("div",{className:"text-xs text-fg-faint italic",children:l?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere."})})]}),e.jsx("div",{className:"px-4 py-2.5 border-t border-line flex items-center gap-2 flex-wrap",children:o?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx(R,{variant:"danger",onClick:h,disabled:r,children:"Delete"}),e.jsx(R,{onClick:()=>p(!1),children:"Keep"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:b,disabled:r,children:"Duplicate"}),!l&&e.jsx(R,{variant:"danger",onClick:()=>p(!0),disabled:r,children:"Delete"}),e.jsx("div",{className:"flex-1"}),E&&e.jsx("span",{className:"text-[11px] text-fg-faint",children:"unsaved changes"}),e.jsx(R,{onClick:c,disabled:!E||r,children:"Revert"}),e.jsx(R,{variant:"primary",onClick:v,disabled:!E||r,children:r?"Saving…":l?"Create":"Save"})]})})]})}function D({label:t,hint:s,children:a}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:t}),a,s&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:s})]})}const G="latest",U="Blocked by the availableModels allowlist in your Claude settings";function ie({value:t,onChange:s,label:a="default model",hint:d,testIdPrefix:l="",inheritLabel:r}){var x,M;const{catalog:o,loading:p,degraded:b,refresh:c}=ee(null),v=o?["inherit",...o.aliases]:[...ye],h=(o==null?void 0:o.availableModels)??null,$=m=>!!h&&m!=="inherit"&&!h.includes(m),S=(m,I)=>!!h&&!h.includes(m)&&!(I&&h.includes(I)),g=t||"inherit",C=((x=/\[[^\]]*\]$/.exec(g))==null?void 0:x[0])??"",L=v.includes(g),k=!L&&o&&A(g)&&v.includes(A(g)+C)?A(g)+C:null,E=L?g:k??g,i=A(E),w=((M=/\[[^\]]*\]$/.exec(E))==null?void 0:M[0])??"",j=!!o&&g!=="inherit"&&!!i&&v.includes(E),O=j?o.models.filter(m=>A(m)===i).map(m=>m+w):[],F=L?G:g,B={};if(o)for(const m of v)$(m)&&(B[m]=U);const f={};for(const m of O)S(m,i)&&(f[m]=U);return e.jsxs(D,{label:a,hint:d??"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls.",children:[e.jsx("div",{"data-testid":`${l}model-row`,children:e.jsx(Y,{options:v,value:E,onChange:s,mono:!0,blocked:B,labels:r?{inherit:r}:void 0})}),j&&e.jsxs("div",{className:"mt-2","data-testid":`${l}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(Y,{options:[G,...O],value:F,onChange:m=>s(m===G?E:m),mono:!0,blocked:f})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:o?`Models are live-read from the installed claude CLI${b?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:p?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${l}model-catalog-refresh`,onClick:()=>{c()},disabled:p,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function le({value:t,model:s,onChange:a,label:d="effort",testIdPrefix:l="",inheritLabel:r}){const{catalog:o}=ee(null),p=o&&o.effortLevels.length?["inherit",...o.effortLevels]:[...$e],b=(o==null?void 0:o.settingsEffortLevels)??[],c=o?p.filter($=>$!=="inherit"&&!b.includes($)):[],v=t||"inherit",h=v!=="inherit"&&Fe(s)===!1;return e.jsxs(D,{label:d,hint:o?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${c.length?`${c.join(", ")} ${c.length>1?"are":"is"} session-only — settings.json accepts ${b.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${l}effort-row`,children:e.jsx(Y,{options:p,value:v,onChange:a,mono:!0,labels:r?{inherit:r}:void 0})}),c.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${l}effort-session-only`,children:c.map($=>`${$} (session-only)`).join(" · ")}),h&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${l}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function We({saved:t,activeProject:s,activeCwd:a,busy:d,onSave:l}){var h,$,S;if(!s)return e.jsxs("div",{"data-testid":"project-override-none",className:"border border-dashed border-line rounded p-3 text-[11px] text-fg-faint",children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide mb-1 font-mono",children:"project override"}),"No active project — open a project tab to override this persona's model or effort for that project only."]});const r=(h=t.overrideDetails)==null?void 0:h.find(g=>g.project===s),o=!!(r!=null&&r.bodyOverridden),p=(($=r==null?void 0:r.values)==null?void 0:$.model)??"inherit",b=((S=r==null?void 0:r.values)==null?void 0:S.effort)??"inherit",c=t.model??"inherit",v=t.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override",className:"border border-accent/40 rounded p-3 space-y-3 bg-accent/5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-accent font-mono",children:"project override"}),e.jsxs(V,{tone:"accent",children:[s," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(se,{path:`${(a??"").replace(/\/+$/,"")}/.claude/agents/${t.name}.md`})})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint leading-snug",children:["Changes what the SCHEDULER (and new Epics) spawn for ",e.jsx("strong",{children:s})," only — a frontmatter-only overlay with just the keys you set; the persona's body stays the global one. The global model/effort rows edit the machine-wide persona and are never touched here."]}),o&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s,' already has a FULL-BODY override of this persona (its own definition text). It is shown as-is and not converted to a frontmatter-only overlay — edit that file directly, or drop it with × under "project overrides" below.']}),e.jsxs("fieldset",{disabled:d||o,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(ie,{value:p,onChange:g=>{o||l({model:g,effort:b})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(le,{value:b,model:p!=="inherit"?p:c,onChange:g=>{o||l({model:p,effort:g})},label:"project effort",testIdPrefix:"override-",inheritLabel:"use global"})]}),e.jsx("div",{"data-testid":"override-provenance",className:"text-[11px] font-mono text-fg-dim space-y-0.5",children:[["model",c,p],["effort",v,b]].map(([g,C,L])=>e.jsxs("div",{"data-testid":`override-provenance-${g}`,children:[g,": ",L!=="inherit"?e.jsxs(e.Fragment,{children:[C," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:L})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[C," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},g))})]})}export{qe as AgentLibrary};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{at as e,v as Me,n as Le,bn as P,aJ as o,ao as De,X as Oe,t as $e,aw as oe,D as _e,av as He,a0 as le,$ as de,a1 as V,aR as Be,_ as Fe,l as q,a2 as Ue,a9 as ze,a$ as xe,Z as We,a as H,bm as ee,b as L,b2 as Je,be as Ve,A as qe,a4 as Ge,b9 as Xe,b5 as Ye,d as Ke,aK as Ze,br as Qe}from"./index-DfWJO7nP.js";import{V as ye}from"./ViewTabs-BYrRSHb6.js";import{S as et}from"./SourceChip-C2YMnlV8.js";import{T as O}from"./Toggle-BnJF4V6k.js";import{V as tt,T as nt}from"./VoiceButton-Bk66E-fP.js";import{P as st}from"./Panel-OUbLHNsS.js";import"./monaco-editor-BsIlgG7c.js";function at({open:t,onClose:n,title:s,children:r,variant:i="overlay"}){return e.jsxs(Me,{open:t,onClose:n,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:i,children:[i==="overlay"&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[e.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:s}),e.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(Le,{children:r})})]})}function rt(){const t=P(g=>g.isRecording),n=P(g=>g.levelMeterEnabled),[s,r]=o.useState(0),[i,a]=o.useState(0),d=o.useRef(0);d.current=i;const[u,y]=o.useState(0),[p,f]=o.useState(!1),m=o.useRef(null);if(o.useEffect(()=>{if(!t||!n){r(0),a(0);return}let g=0,j=!1,v=null,N=null;const S=()=>{if(j)return;const w=N??De();if(!w){g=requestAnimationFrame(S);return}N!==w&&(N=w,v=new Uint8Array(new ArrayBuffer(w.fftSize)));const C=v;w.getByteTimeDomainData(C);let T=0;for(let R=0;R<C.length;R++){const F=C[R]-128;T+=F*F}const E=Math.sqrt(T/C.length)/128,b=E>0?20*Math.log10(E):-60,k=Math.max(0,Math.min(1,(b+60)/60));a(E),r(k),E>=.95&&(f(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>f(!1),150)),g=requestAnimationFrame(S)};g=requestAnimationFrame(S);const h=setInterval(()=>{j||y(Math.round(d.current*100))},250);return()=>{j=!0,cancelAnimationFrame(g),clearInterval(h),m.current&&(clearTimeout(m.current),m.current=null)}},[t,n]),!t||!n)return null;const c=p?"bg-red-500":i>=.7?"bg-amber-400":"bg-green-500";return e.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":u,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${p?"ring-1 ring-red-500":""}`,children:e.jsx("div",{className:`h-full ${c} transition-[width] duration-75 ease-out`,style:{width:`${s*100}%`}})})}function it({open:t,onClose:n,variant:s="overlay"}){return e.jsx(at,{open:t,onClose:n,title:"Voice / Microphone",variant:s,children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(ct,{}),e.jsx(Oe,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(tt,{}),e.jsx($e,{}),e.jsx(nt,{})]}),e.jsx(ot,{}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>P.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),e.jsx(dt,{})]}),e.jsx(rt,{})]})})}function ot(){const t=P(a=>a.isRecording),[n,s]=o.useState(null);if(o.useEffect(()=>{let a=!1;window.api.voice.getHotkeyConfig().then(u=>{a||s(u)}).catch(()=>{});const d=window.api.voice.onHotkeyConfigChanged(u=>s(u));return()=>{a=!0,d()}},[]),t||!n)return null;const r=n.mode==="hold"?"Hold":"Press",i=lt(n.accelerator);return e.jsxs("div",{className:"text-[11px] text-fg-faint",children:[e.jsxs("span",{children:[r," "]}),e.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:i}),e.jsx("span",{children:" to record"})]})}function lt(t){const n=typeof navigator<"u"&&/Mac/.test(navigator.platform);return t.replace(/CommandOrControl/g,n?"⌘":"Ctrl").replace(/CmdOrCtrl/g,n?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,n?"⌥":"Alt").replace(/Shift/g,n?"⇧":"Shift")}function dt(){const[t,n]=o.useState(null);if(o.useEffect(()=>{let r=!1;window.api.voice.getHotkeyConfig().then(a=>{r||n(a)}).catch(a=>oe.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(a)}));const i=window.api.voice.onHotkeyConfigChanged(a=>{n(a)});return()=>{r=!0,i()}},[]),!t)return null;const s=async r=>{if(t.mode===r)return;const i={...t,mode:r};n(i);try{await window.api.voice.setHotkeyConfig(i)}catch(a){oe.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:a instanceof Error?a.message:String(a)})}};return e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[e.jsx("input",{type:"radio",name:"hotkey-mode",checked:t.mode==="toggle",onChange:()=>s("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),e.jsx("span",{children:"Tap on/off"})]}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[e.jsx("input",{type:"radio",name:"hotkey-mode",checked:t.mode==="hold",onChange:()=>s("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),e.jsx("span",{children:"Hold to talk"})]})]})}function ct(){const t=P(a=>a.isRecording),n=P(a=>a.lastTranscript),s=P(a=>a.error),r=P(a=>a.modelStatus),i=P(a=>a.loadingProgress);return s?e.jsxs("div",{className:"text-[11px] text-red-400",title:s,children:["⚠ ",s]}):t?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),e.jsx("span",{className:"truncate",title:n,children:n||"Listening…"})]}):r==="loading"?e.jsxs("div",{className:"text-[11px] text-fg-faint",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"Loading speech model"}),e.jsxs("span",{className:"font-mono",children:[i,"%"]})]}),e.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${i}%`}})})]}):null}const pt=["dark","light","paper"];function mt(){const[t,n]=o.useState(_e),[s,r]=o.useState(!1);o.useEffect(()=>{let d=!1;return He().then(u=>{d||(n(u),r(!0))}),()=>{d=!0}},[]);const i=d=>{s&&n(u=>{const y={...u,...d};return Be(y),y})},a=d=>{i({fontSize:Math.min(de,Math.max(le,t.fontSize+d))})};return e.jsxs("section",{className:"mb-6","data-testid":"home-terminal-appearance",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Terminal appearance"}),e.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:"every terminal, this machine"})]}),e.jsxs("div",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsxs("p",{className:"mt-0 mb-4 text-[13px] text-fg-dim leading-relaxed",children:["Applies to ",e.jsx("strong",{className:"text-fg",children:"every terminal in the app at once"})," — project Terminal tabs, an Epic’s Terminal view of its session, and the inline permission prompt. It is not per project, per session, or per tab. It does not restyle the app chrome (there is no app theme switch), and the code editor keeps its own separate paper/dark setting in the Editor tab’s Display menu. Stored in"," ",e.jsx("code",{className:"font-mono text-[12px]",children:"~/.claude/session-manager/ui-settings-prefs.json"}),", applied live without restarting a session."]}),e.jsxs("div",{className:"grid gap-5",style:{gridTemplateColumns:"minmax(0,1fr) 220px"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-fg-faint mb-1.5",children:"Theme"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:pt.map(d=>e.jsxs("button",{type:"button",onClick:()=>i({theme:d}),disabled:!s,"aria-pressed":t.theme===d,"data-testid":`terminal-theme-${d}`,className:`px-2 py-2 rounded-lg text-[11px] font-medium border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${t.theme===d?"bg-bg border-accent text-fg":"bg-bg border-line text-fg-dim hover:text-fg hover:border-fg-faint"}`,children:[e.jsx(ut,{theme:d}),e.jsx("div",{className:"mt-1.5 capitalize",children:d})]},d))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-fg-faint",children:"Font size"}),e.jsxs("span",{className:"font-mono text-[11px] text-fg-dim",children:[t.fontSize,"px"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>a(-1),disabled:!s||t.fontSize<=le,"aria-label":"Decrease font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"−"}),e.jsx("button",{type:"button",onClick:()=>i({fontSize:Fe}),disabled:!s,className:"flex-1 py-1.5 rounded border border-line bg-bg text-[11px] text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"reset"}),e.jsx("button",{type:"button",onClick:()=>a(1),disabled:!s||t.fontSize>=de,"aria-label":"Increase font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"+"})]}),e.jsxs("div",{className:"mt-3 rounded border border-line px-3 py-2 font-mono",style:{background:V[t.theme].background,color:V[t.theme].foreground,fontSize:`${t.fontSize}px`,lineHeight:1.35},"aria-hidden":!0,children:[e.jsx("span",{style:{color:V[t.theme].green},children:"$"})," claude"]})]})]})]})]})}function ut({theme:t}){const n=V[t];return e.jsxs("div",{"aria-hidden":!0,className:"w-full h-5 rounded border relative overflow-hidden",style:{background:n.background,borderColor:"rgba(0,0,0,0.15)"},children:[e.jsx("div",{style:{position:"absolute",top:3,left:4,width:"40%",height:2,background:n.foreground}}),e.jsx("div",{style:{position:"absolute",top:9,left:4,width:"25%",height:2,background:n.green??n.foreground}}),e.jsx("div",{style:{position:"absolute",top:15,left:4,width:"55%",height:2,background:n.cyan??n.foreground}})]})}const ft=1440*60*1e3;function ce(t){if(!t)return"never";const n=new Date(t).getTime();return Number.isNaN(n)?"never":new Date(n).toLocaleString()}function pe(t){return t?new Date(t).toLocaleString():"never"}function gt(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(ht,{}),e.jsx("hr",{className:"border-line"}),e.jsx(xt,{})]})}function ht(){const[t,n]=o.useState(null),[s,r]=o.useState(null),[i,a]=o.useState(null),[d,u]=o.useState(null),[y,p]=o.useState(!1),[f,m]=o.useState(null),[c,g]=o.useState(null);if(o.useEffect(()=>{let h=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([w,C,T])=>{h||(n(w),a(w),r(C),u(T))}).catch(w=>{console.warn("[telemetry] load failed:",w==null?void 0:w.message)}),()=>{h=!0}},[]),!i||!t)return e.jsx(q,{title:"loading…"});const j=JSON.stringify(i)!==JSON.stringify(t),v=(h,w)=>{m(null),a({...i,[h]:w})},N=async()=>{p(!0),m(null);try{const h=await window.api.otel.setConfig(i);!h.ok&&h.error&&m(h.error),n(h.config),a(h.config),r(h.status),g(Date.now())}catch(h){m(h instanceof Error?h.message:String(h))}finally{p(!1)}},S=()=>{m(null),a(t)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),d&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:d})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(O,{checked:i.enabled,onChange:h=>v("enabled",h),label:i.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:i.endpoint,onChange:h=>v("endpoint",h.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:i.headers,onChange:h=>v("headers",h.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:i.serviceName,onChange:h=>v("serviceName",h.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(O,{checked:i.includeContent,onChange:h=>v("includeContent",h),label:i.includeContent?"on":"off"})]})]}),s&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:s.enabled?"text-accent":"text-fg-dim",children:String(s.enabled)})]}),s.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",s.error]}),!s.error&&s.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:N,disabled:!j||y,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:y?"saving…":"Save"}),e.jsx("button",{onClick:S,disabled:!j||y,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),f&&e.jsx("span",{className:"text-red-400 text-xs",children:f}),!f&&c&&!j&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function xt(){const[t,n]=o.useState(null),[s,r]=o.useState(null),[i,a]=o.useState("Copy"),[d,u]=o.useState(!1),[y,p]=o.useState(null),[f,m]=o.useState(null),[c,g]=o.useState(null),[j,v]=o.useState(!1),N=()=>{window.api.telemetry.status().then(r).catch(b=>{console.warn("[product-telemetry] status reload failed:",b==null?void 0:b.message)})};if(o.useEffect(()=>{let b=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([k,R])=>{b||(n(k),r(R))}).catch(k=>{console.warn("[product-telemetry] load failed:",k==null?void 0:k.message)}),()=>{b=!0}},[]),!t||!s)return e.jsx(q,{title:"loading…"});const S=async b=>{m(null);try{const k=await window.api.telemetry.setConfig(b);n(k.config),r(k.status),window.dispatchEvent(new CustomEvent(We,{detail:k.config}))}catch(k){m(k instanceof Error?k.message:String(k))}},h=b=>{S({...t,enabled:b})},w=async()=>{await ze(t.installId)?(a("Copied"),setTimeout(()=>a("Copy"),1500)):xe.error("Could not copy install id to the clipboard")},C=async()=>{u(!0),p(null);try{const b=await window.api.telemetry.flushNow();p(`sent ${b.sent.length}, failed ${b.failed.length}`),N()}catch(b){p(b instanceof Error?b.message:String(b))}finally{u(!1)}},T=async()=>{if(j){v(!1);return}try{const b=await window.api.telemetry.recentRecords();g(b),v(!0)}catch(b){console.warn("[product-telemetry] recentRecords failed:",b instanceof Error?b.message:b)}},E=t.lastDailyFlushAt?new Date(t.lastDailyFlushAt).getTime()+ft:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),e.jsx(Ue,{cfg:t,onSaved:(b,k)=>{n(b),r(k)}}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(O,{checked:t.enabled,onChange:h,label:t.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:t.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:w,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:i})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:t.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),f&&e.jsx("div",{className:"text-red-400 text-xs",children:f})]}),s.pendingCount>0&&s.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[s.pendingCount," record",s.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",pe(s.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",ce(E?new Date(E).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",s.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",s.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",s.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",s.evictedCount]}),s.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",s.backlog.reason,", ",ce(s.backlog.ranAt),"):"," ",s.backlog.linesEnqueued," enqueued, ",s.backlog.linesConfirmed," confirmed,"," ",s.backlog.watermarksRewound," watermarks rewound"]}),s.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",s.lastError.message," ","(",pe(s.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:C,disabled:d,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:d?"sending…":"Send now"}),y&&e.jsx("span",{className:"text-fg-faint text-xs",children:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:T,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:j?"Hide last records":"Inspect last records sent"}),j&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(c??[],null,2)})]})]})}function U({children:t,right:n}){return e.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[e.jsx("span",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint",children:t}),n]})}function K({kind:t="soft",icon:n,children:s,onClick:r,disabled:i,testId:a}){return e.jsxs("button",{type:"button","data-testid":a,onClick:r,disabled:i,className:`shrink-0 inline-flex items-center gap-2 rounded-lg px-3.5 py-2 text-[13px] font-semibold transition-colors disabled:opacity-50 ${t==="soft"?"bg-bg-hi border border-line text-fg hover:bg-bg":"text-fg-dim hover:text-fg"}`,children:[n&&e.jsx(H,{name:n,size:15}),s]})}function yt({icon:t,title:n,subtitle:s,badge:r,action:i,testId:a}){return e.jsxs("div",{"data-testid":a,className:"flex items-center gap-3.5 bg-bg-hi border border-line rounded-xl px-[18px] py-3.5",children:[e.jsx("span",{className:"w-[34px] h-[34px] rounded-lg bg-bg border border-line grid place-items-center text-fg-dim shrink-0",children:e.jsx(H,{name:t,size:17})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-0.5",children:[e.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:n}),r]}),e.jsx("div",{className:"font-mono text-[11.5px] text-fg-faint truncate",children:s})]}),i]})}function bt({onClick:t,disabled:n,testId:s,children:r="Revoke"}){return e.jsx("button",{"data-testid":s,onClick:t,disabled:n,className:"shrink-0 rounded-lg border border-line bg-bg text-accent px-3.5 py-1.5 text-[12.5px] font-semibold hover:bg-bg-hi disabled:opacity-50 transition-colors",children:r})}function me({code:t,onConfirm:n,testId:s,codeTestId:r,confirmTestId:i,peer:a="browser"}){return e.jsxs("div",{"data-testid":s,className:"flex items-start gap-3.5 px-5 py-4 rounded-2xl border border-accent/40 bg-accent/[0.06]",children:[e.jsx("span",{className:"w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center bg-bg-hi text-accent",children:e.jsx(H,{name:"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-fg",children:[e.jsx("strong",{className:"font-semibold",children:"Verify E2E session."})," Compare this code with the ",a," — they must match.",e.jsx("div",{"data-testid":r,className:"my-2 text-3xl font-mono tracking-[0.3em] text-center text-accent select-all",children:t}),e.jsx("p",{className:"text-[12.5px] text-fg-faint mb-3",children:"If the codes match, confirm below. Mutating commands are blocked until confirmed."}),e.jsx("button",{"data-testid":i,onClick:n,className:"rounded-lg bg-accent text-white px-4 py-2 text-[13px] font-semibold hover:opacity-90 transition-opacity",children:"Codes match — confirm"})]})]})}function jt({children:t,testId:n}){return e.jsx("div",{"data-testid":n,className:"bg-bg-hi border border-line rounded-xl p-5 text-center text-[13.5px] text-fg-faint italic font-serif",children:t})}function ue({label:t,hint:n,on:s,onChange:r,warn:i,disabled:a,first:d,testId:u}){return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-[18px] py-[15px] ${d?"":"border-t border-rule"} ${a?"opacity-50":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-fg mb-0.5",children:t}),e.jsxs("div",{className:`text-[12.5px] leading-snug flex items-center gap-1.5 ${i?"text-honey-dark":"text-fg-faint"}`,children:[i&&e.jsx("span",{"aria-hidden":!0,children:"⚠"}),n]})]}),e.jsx("span",{"data-testid":u,className:"inline-flex",children:e.jsx(O,{checked:s,onChange:a?()=>{}:r,disabled:a})})]})}function vt({device:t,online:n,onRevoke:s,revoking:r}){const i=t.lastConnectedAt?new Date(t.lastConnectedAt).toLocaleString():`paired ${new Date(t.issuedAt).toLocaleDateString()}`;return e.jsx(yt,{testId:"settings-remote-device",icon:"wifi",title:t.deviceName,badge:n?e.jsx(L,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.deviceId} · last seen ${i}`,action:e.jsx(bt,{testId:"settings-remote-revoke",onClick:()=>s(t.deviceId),disabled:r})})}const M=t=>(t==null?void 0:t.message)||String(t);function wt(){var ie;const t=ee(l=>l.show),[n,s]=o.useState(null),[r,i]=o.useState(!0),[a,d]=o.useState(!1),[u,y]=o.useState(!1),[p,f]=o.useState("idle"),[m,c]=o.useState(""),[g,j]=o.useState(null),[v,N]=o.useState(!1),[S,h]=o.useState([]),[w,C]=o.useState(!1),T=o.useRef(null);o.useEffect(()=>{let l=!1;const x=()=>window.api.webRemote.getStatus().then(I=>{l||s(I)}).catch(()=>{});window.api.webRemote.getStatus().then(I=>{l||(s(I),i(!1))}).catch(I=>{l||(t("error",`Remote status: ${M(I)}`),i(!1))});const Pe=window.api.webRemote.onStatus(I=>s(I)),Re=window.api.webRemote.onTokenRevoked(()=>{t("warn","Remote device token was revoked. Re-pair to reconnect."),x()}),Ae=window.api.webRemote.onRevokedAll(({revokedCount:I})=>{t("info",`Panic: all ${I} device(s) revoked and sessions torn down.`),x()});return()=>{l=!0,Pe(),Re(),Ae()}},[t]),o.useEffect(()=>{if(p!=="enter-otp")return;const l=setTimeout(()=>{var x;return(x=T.current)==null?void 0:x.focus()},50);return()=>clearTimeout(l)},[p]);const E=async()=>s(await window.api.webRemote.getStatus()),b=async()=>{if(n){d(!0);try{const l=n.enabled?await window.api.webRemote.disable():await window.api.webRemote.enable();l&&l.ok===!1&&t("error",l.error||"Failed to change remote state."),await E()}catch(l){t("error",`Failed: ${M(l)}`)}finally{d(!1)}}},k=async()=>{if(n){y(!0);try{const l=n.remoteControlEnabled?await window.api.webRemote.disableControl():await window.api.webRemote.enableControl();l&&l.ok===!1&&t("error",l.error||"Failed to change command writes."),await E()}catch(l){t("error",`Failed: ${M(l)}`)}finally{y(!1)}}},R=async()=>{const l=m.trim().toUpperCase();if(!/^[A-Z0-9]{8}$/.test(l)){t("warn","Pairing code must be 8 alphanumeric characters.");return}f("pairing");try{const x=await window.api.webRemote.pair(l);if(!x.ok){t("error",x.error||"Pairing failed."),f("enter-otp");return}t("info","Device paired successfully."),c(""),f("idle"),await E()}catch(x){t("error",`Pairing error: ${M(x)}`),f("enter-otp")}},F=async l=>{j(l);try{const x=await window.api.webRemote.revokeDevice(l);if(!x.ok){t("error",x.error||"Revoke failed.");return}await E()}catch(x){t("error",`Revoke error: ${M(x)}`)}finally{j(null)}},Se=async()=>{N(!0);try{const l=await window.api.webRemote.revokeAll();l.ok||t("error",l.error||"Panic revoke failed.")}catch(l){t("error",`Panic revoke error: ${M(l)}`)}finally{N(!1)}},Ce=async()=>{if(w){C(!1);return}try{const l=await window.api.webRemote.auditTail(100);if(!l.ok){t("error",`Audit log: ${l.error||"unavailable"}`);return}h(l.lines??[]),C(!0)}catch(l){t("error",`Audit log: ${M(l)}`)}},ne=async l=>{try{const x=await window.api.webRemote.confirmSas(l);x!=null&&x.ok||t("error",`SAS confirm failed: ${(x==null?void 0:x.error)??"unexpected state — reconnect the mobile app"}`)}catch(x){t("error",`SAS confirm failed: ${M(x)}`)}};if(r)return e.jsx("div",{className:"p-6 text-fg-faint text-sm",children:"Loading…"});const A=(n==null?void 0:n.enabled)??!1,X=(n==null?void 0:n.remoteControlEnabled)??!1,se=(n==null?void 0:n.connected)??!1,ae=(n==null?void 0:n.e2eActive)??!1,Ee=(n==null?void 0:n.e2eAuthenticated)??!1,Te=(n==null?void 0:n.e2eState)??"idle",re=(n==null?void 0:n.pendingSas)??null,Y=((n==null?void 0:n.clients)??[]).filter(l=>l.state==="pending_sas"&&l.pendingSas),$=(n==null?void 0:n.devices)??[],_=A&&se,Ie=se?((ie=$.reduce((l,x)=>x.lastConnectedAt&&(!l||(l.lastConnectedAt??"")<x.lastConnectedAt)?x:l,null))==null?void 0:ie.deviceId)??null:null;return e.jsxs("div",{"data-testid":"settings-remote",className:"p-4 max-w-[760px] space-y-[22px]",children:[Y.length>0?Y.map((l,x)=>e.jsxs("div",{"data-testid":"settings-remote-sas-row",children:[Y.length>1&&e.jsxs("div",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:["Browser ",x+1]}),e.jsx(me,{testId:x===0?"settings-remote-sas":void 0,codeTestId:x===0?"settings-remote-sas-code":void 0,confirmTestId:x===0?"settings-remote-sas-confirm":void 0,code:l.pendingSas,onConfirm:()=>ne(l.key)})]},l.key)):re&&e.jsx(me,{testId:"settings-remote-sas",codeTestId:"settings-remote-sas-code",confirmTestId:"settings-remote-sas-confirm",code:re,onConfirm:()=>ne()}),Te==="failed"&&e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 rounded-2xl border border-[#eccdbe] bg-[#f8e8e0]",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsxs("div",{className:"text-[13px] text-[#9a3f1f]",children:[e.jsx("strong",{className:"font-semibold",children:"E2E key exchange failed."})," ",e.jsx("span",{className:"text-fg-dim",children:"The session key could not be established. Reconnect the mobile app to retry."})]})]}),e.jsxs("div",{className:`flex items-center gap-3.5 px-5 py-4 rounded-2xl border ${_?"border-[#e8cdb9] bg-[#f5e9df]":"border-line bg-bg-hi"}`,children:[e.jsx("span",{className:`w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center ${_?"bg-[#f0d9c8] text-accent":"bg-[#e4ebd6] text-sage"}`,children:e.jsx(H,{name:_?"wifi":"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-fg mb-0.5",children:_?"Remote control is active":A?"Remote control is idle":"Remote control is off"}),e.jsx("div",{className:"text-[13px] text-fg-dim leading-snug",children:_?"A web session can send commands to this machine. Revoke below if unexpected.":A&&(n==null?void 0:n.linkState)==="repair-needed"?"The relay no longer recognises this device. Re-pair it with a new code to reconnect.":A?"The relay is on but no device is connected. Pair a device to begin.":"The relay connection is closed — no remote commands are accepted. Enable it below only when you need it."})]}),ae&&Ee?e.jsx(L,{tone:"default",className:"!text-sage !border-sage/40",children:"E2E authenticated"}):ae?e.jsx(L,{tone:"warn",children:"E2E · awaiting SAS"}):e.jsx(L,{tone:"dim",children:"relay only · not E2E yet"})]}),e.jsxs("div",{children:[e.jsx(U,{children:"Remote control"}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx(ue,{first:!0,testId:"settings-remote-enable",label:"Allow remote control from the web",hint:"Master switch. When off, the relay refuses every connection.",on:A,disabled:a,onChange:()=>{a||b()}}),e.jsx(ue,{testId:"settings-remote-control",label:"Allow command writes (pty + scheduler)",hint:X?"A paired device can run shell commands and queue jobs on this machine.":"Paired devices can watch session output but cannot send commands.",warn:X,disabled:!A||u,on:X&&A,onChange:()=>{A&&!u&&k()}})]})]}),e.jsxs("div",{children:[e.jsx(U,{children:"Pair a device"}),p==="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsxs("div",{"data-testid":"settings-remote-pair-hint",className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:["On your phone open ",e.jsx("strong",{className:"text-fg font-semibold",children:"bilko.run/projects/session-manager"}),", sign in, and tap"," ",e.jsx("strong",{className:"text-fg font-semibold",children:"Generate pairing code"}),". Enter the 8-character code here."]}),e.jsx(K,{testId:"settings-remote-pair-start",kind:"soft",icon:"link",onClick:()=>f("enter-otp"),children:"Pair Device…"})]}):e.jsxs("div",{className:"flex items-center gap-5 bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[22px]",children:[e.jsx("span",{className:"w-[52px] h-[52px] rounded-xl bg-bg border border-line grid place-items-center text-accent shrink-0",children:e.jsx(H,{name:"link",size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint mb-2",children:"Enter the code from your phone"}),e.jsx("input",{ref:T,"data-testid":"settings-remote-otp",value:m,onChange:l=>c(l.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")),onKeyDown:l=>{l.key==="Enter"&&R()},maxLength:8,placeholder:"XXXXXXXX",disabled:p==="pairing",className:"w-full bg-transparent border-0 outline-none font-mono text-[30px] font-semibold tracking-[6px] text-fg placeholder:text-fg-faint/40 disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(K,{testId:"settings-remote-pair-confirm",kind:"soft",onClick:R,disabled:p==="pairing"||m.length<8,children:p==="pairing"?"Pairing…":"Confirm"}),e.jsx(K,{kind:"ghost",onClick:()=>{f("idle"),c("")},disabled:p==="pairing",children:"cancel"})]})]})]}),e.jsxs("div",{children:[e.jsx(U,{right:$.length>0?e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[$.length," paired"]}):void 0,children:"Paired devices"}),$.length===0?e.jsx(jt,{children:"No devices paired yet."}):e.jsx("div",{className:"space-y-2",children:$.map(l=>e.jsx(vt,{device:l,online:l.deviceId===Ie,onRevoke:F,revoking:g===l.deviceId},l.deviceId))})]}),e.jsxs("div",{children:[e.jsx(U,{right:e.jsx("button",{"data-testid":"settings-remote-audit-toggle",onClick:Ce,className:"text-[12px] text-fg-faint hover:text-fg-dim transition-colors",children:w?"Hide":"Show last 100 · 0600, stays on this machine"}),children:"Audit log"}),w&&e.jsx("div",{className:"bg-bg-hi border border-line rounded-xl overflow-auto max-h-64 mb-2",children:S.length===0?e.jsx("p",{className:"p-4 text-[12.5px] text-fg-faint",children:"No entries today."}):e.jsx("pre",{"data-testid":"settings-remote-audit",className:"p-4 text-[12px] text-fg-dim font-mono whitespace-pre-wrap leading-relaxed",children:S.join(`
|
|
2
|
+
`)})}),e.jsxs("p",{className:"text-[12px] text-fg-faint",children:["Full log at"," ",e.jsx("code",{className:"font-mono text-fg-faint",children:"~/.claude/session-manager/logs/remote-audit-YYYY-MM-DD.log"})," ","(0600, never leaves this machine)"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-[#f8e8e0] border border-[#eccdbe] rounded-2xl px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsx("span",{className:"text-sm font-semibold text-[#9a3f1f]",children:"Panic — disconnect & revoke everything"})]}),e.jsx("div",{className:"text-[12.5px] text-fg-dim leading-snug max-w-[440px]",children:"Tears down every active session and invalidates all paired-device tokens. Devices must re-pair. Use if you suspect compromise."})]}),e.jsx("button",{"data-testid":"settings-remote-revoke-all",onClick:Se,disabled:v,className:"shrink-0 rounded-lg bg-accent text-white px-[18px] py-2 text-[13px] font-semibold hover:opacity-90 disabled:opacity-50 transition-opacity",children:v?"Revoking…":"Revoke all"})]})]})}const z="px-2 py-1 rounded border border-line text-xs text-fg hover:bg-bg-hi disabled:opacity-50";function kt(){const t=Je(),n=ee(u=>u.show),s=async u=>{try{const p=await u();p&&p.ok===!1&&n("error",p.error??"Update action failed")}catch(y){n("error",y instanceof Error?y.message:String(y))}};if(!t)return null;const{state:r}=t,i=r==="unsupported",a=t.latest?`v${t.latest}`:"—",d=()=>{window.confirm("Installing now will stop all running jobs and terminals. Continue?")&&s(()=>window.api.updater.install(!0))};return e.jsxs("section",{"data-testid":"settings-updates",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Updates"}),e.jsxs("div",{className:"text-fg-dim text-xs flex gap-4",children:[e.jsxs("span",{children:["Current v",t.current]}),e.jsxs("span",{children:["Latest ",a]})]})]}),i?e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Auto-update runs only in the installed Windows app or the Linux AppImage. npx builds update via npx."}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(O,{checked:t.enabled,onChange:u=>void s(()=>window.api.updater.setEnabled(u)),label:"Update automatically"}),e.jsx("button",{type:"button","data-testid":"updates-check",className:z,disabled:r==="checking"||r==="downloading",onClick:()=>void s(()=>window.api.updater.check()),children:"Check for updates"})]}),r==="checking"&&e.jsx("p",{className:"text-fg-dim text-xs",children:"Checking…"}),r==="downloading"&&e.jsxs("p",{className:"text-fg-dim text-xs",children:["Downloading… ",t.progress!=null?`${Math.round(t.progress)}%`:""]}),r==="ready"&&e.jsxs("button",{type:"button","data-testid":"updates-install",className:z,onClick:()=>void s(()=>window.api.updater.install(!1)),children:["Restart to install v",t.latest]}),r==="deferred"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-fg-dim text-xs",children:["Waiting for ",t.busyReason??"work"," to finish"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:z,onClick:d,children:"Install now"}),e.jsx("button",{type:"button",className:z,onClick:()=>void s(()=>window.api.updater.cancelDeferred()),children:"Cancel"})]})]}),r==="error"&&e.jsx("p",{className:"text-red-400 text-xs",children:t.error})]})}const Nt=[{key:"maxAgeDays",label:"Run logs: keep for",unit:"days",min:3,max:3650},{key:"runsArchiveDays",label:"Runs archive: keep for",unit:"days",min:1,max:3650},{key:"auditLogMonths",label:"Audit log: keep for",unit:"months",min:1,max:120},{key:"reservedMarkersKeep",label:"Reserved markers: keep",unit:"markers",min:1,max:1e5}],St="w-24 px-2 py-1 rounded border border-line bg-transparent text-xs text-fg";function fe(t,n){return n==="maxAgeDays"?t.runLogs.maxAgeDays:t[n]}function Ct(t,n){return t==="maxAgeDays"?{runLogs:{maxAgeDays:n}}:{[t]:n}}function be(t){if(!Number.isFinite(t)||t<=0)return"0 B";const n=["B","KB","MB","GB","TB"];let s=0,r=t;for(;r>=1024&&s<n.length-1;)r/=1024,s++;return`${s===0?r:r.toFixed(1)} ${n[s]}`}function Z(t,n,s){return`${t}: ${be(n)} in ${s.toLocaleString("en-US")} files`}function Et(){const t=ee(c=>c.show),[n,s]=o.useState(null),[r,i]=o.useState({}),[a,d]=o.useState(null),u=o.useCallback(c=>t("error",c instanceof Error?c.message:String(c)),[t]),y=o.useCallback(async()=>{try{d(await window.api.opsRetention.preview())}catch(c){u(c)}},[u]);o.useEffect(()=>{let c=!0;return window.api.opsRetention.get().then(g=>{c&&s(g)}).catch(g=>{c&&u(g)}),y(),()=>{c=!1}},[u,y]);const p=async c=>{if(!n)return;const g=r[c.key];if(g===void 0)return;const j=Number(g);if(i(N=>{const{[c.key]:S,...h}=N;return h}),g.trim()===""||!Number.isFinite(j))return;const v=Math.min(c.max,Math.max(c.min,Math.round(j)));if(v!==fe(n,c.key))try{s(await window.api.opsRetention.set(Ct(c.key,v))),await y()}catch(N){u(N)}},f=a?a.runLogs.bytes+a.runsArchive.bytes+a.tmp.bytes:0,m=a?a.runLogs.files+a.runsArchive.entries+a.tmp.files:0;return e.jsxs("section",{"data-testid":"settings-ops-retention",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Ops data retention"}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"How long the daily sweep keeps scheduler and audit data. Machine-wide."})]}),n&&e.jsxs("div",{className:"space-y-2",children:[Nt.map(c=>e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:"w-48",children:c.label}),e.jsx("input",{type:"number","data-testid":`ops-retention-${c.key}`,className:St,min:c.min,max:c.max,value:r[c.key]??String(fe(n,c.key)),onChange:g=>i(j=>({...j,[c.key]:g.target.value})),onBlur:()=>void p(c)}),e.jsx("span",{className:"text-fg-faint",children:c.unit})]},c.key)),e.jsx("p",{className:"text-fg-dim text-xs",children:"Archived transcripts: kept forever"})]}),a&&e.jsxs("div",{"data-testid":"ops-retention-preview",className:"space-y-1 text-xs text-fg-dim",children:[e.jsxs("div",{className:"text-fg",children:["Current policy would free ",be(f)," in ",m.toLocaleString("en-US")," files"]}),e.jsx("div",{children:Z("Run logs",a.runLogs.bytes,a.runLogs.files)}),e.jsx("div",{children:Z("Runs archive",a.runsArchive.bytes,a.runsArchive.entries)}),e.jsx("div",{children:Z("Stale temp files",a.tmp.bytes,a.tmp.files)}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Nothing is deleted until the daily sweep runs."})]})]})}const G=[{id:"project",label:"Project & Tab",realm:"machine",blurb:"A PROJECT is a cwd; a TAB is one open project.",tone:{chip:"bg-bg-elev text-fg-dim",border:"border-line",dot:"bg-fg-faint"}},{id:"epic",label:"Epic (PromptSession)",realm:"project",blurb:"The central aggregate root — one unit of work, one claude session.",tone:{chip:"bg-accent-muted text-accent-dark",border:"border-accent",dot:"bg-accent"}},{id:"scheduler",label:"Scheduler",realm:"project",blurb:"PRDs + the headless jobs that execute them.",tone:{chip:"bg-butter/30 text-honey-dark",border:"border-honey",dot:"bg-honey"}},{id:"agents",label:"Agents & Taxonomy",realm:"machine",blurb:"The ACTOR and MISSION halves of AIM.",tone:{chip:"bg-sage/20 text-sage-dark",border:"border-sage",dot:"bg-sage"}},{id:"memory",label:"Memory",realm:"machine",blurb:"Workspace, cross-project, and per-agent memory.",tone:{chip:"bg-hive-teal/20 text-hive-teal",border:"border-hive-teal",dot:"bg-hive-teal"}},{id:"transcript",label:"Transcript & Usage",realm:"machine",blurb:"The Claude CLI's own JSONL, classified events, and billing.",tone:{chip:"bg-bg-hi text-fg-dim",border:"border-rule",dot:"bg-fg-dim"}},{id:"brief",label:"Project Home & Publishing",realm:"project",blurb:"The synthesized Brief, generated pages, and bilko.run publish state.",tone:{chip:"bg-accent-muted/60 text-accent-dark",border:"border-accent-muted",dot:"bg-accent-muted"}},{id:"config",label:"Machine Config",realm:"machine",blurb:"Settings, layout, and the single-writer ownership map.",tone:{chip:"bg-line text-fg-faint",border:"border-rule",dot:"bg-fg-faint"}}];function je(t){const n=G.find(s=>s.id===t);if(!n)throw new Error(`unknown ErdGroupId: ${t}`);return n}const B=[{id:"project",name:"Project",aka:"cwd — Main Project",group:"project",store:{path:"identity only, no record of its own — folded at read time from ~/.claude/projects/<encoded>",format:"in-memory",definedIn:"src/renderer/lib/knownProjectAggregate.ts (aggregateProjectsByCwd) "},summary:"A folder whose cwd never resolved from transcript content is DROPPED, never guessed — the naive decode once reported 2044 phantom projects.",fields:[{name:"cwd",type:"string",key:"pk",note:"resolved working directory — the project's identity"},{name:"name",type:"string",note:"display name: the cwd's last path segment"},{name:"encoded",type:"string",note:"representative transcript folder (most recently active)"},{name:"encodedIds",type:"string[]",note:"every ~/.claude/projects/<encoded> folder that resolved to this cwd"},{name:"sessionCount",type:"number"},{name:"sizeBytes",type:"number"},{name:"lastSession",type:"number"}]},{id:"tab",name:"PersistedTab",aka:"TAB",group:"project",store:{path:"~/.claude/session-manager/tabs.json",format:"json",definedIn:"src/main/sessionsStore.cjs "},summary:"One TAB per project — extra sessions within a project are Epics, not tabs.",fields:[{name:"id",type:"string",key:"pk"},{name:"sessionId",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"label",type:"string"},{name:"presetId",type:"string | null"}]},{id:"epic",name:"PromptSession",aka:"EPIC",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> sessions[id]",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicMint.cjs (ensureEpic) + src/renderer/state/promptSessions.ts "},summary:"The central aggregate root — created in exactly ONE place, a human pressing New Epic.",fields:[{name:"id",type:"string",key:"pk"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"goalText",type:"string",note:"the original top-level prompt text that started this goal"},{name:"claudeSessionId",type:"string",note:"independently minted — never shared with any tab.sessionId"},{name:"status",type:"'proposed' | 'active' | 'completed'"},{name:"createdAt",type:"string"},{name:"completedAt",type:"string | null"},{name:"resumedFromId",type:"string",optional:!0,key:"fk",ref:"epic.id"},{name:"tag",type:"TicketTag",optional:!0,key:"fk",ref:"tag.tag"},{name:"openingPrompt",type:"string | null",optional:!0},{name:"source",type:"EpicSource",optional:!0,note:"{ producer, prdSlug?, runId?, sourceTabId?, fromCwd?, fromEpicId? }"},{name:"agentType",type:"string",optional:!0,key:"fk",ref:"agentPersona.name"},{name:"sections",type:"EpicIntakeSection[]",optional:!0},{name:"worktree",type:"{ dir, branch, baseCwd, status, conflictReason? }",optional:!0,note:"own git worktree on branch 'sm-epic/<id>' when Active"}],notes:["SINGLE-CREATOR LAW, fail-closed in epicMint.cjs — the New Epic IPC handler and crossProjectFeedback.cjs are the only mint authorities.","Every Epic is born proposed; nothing is created directly as active.","EPIC : claude-session is 1:1 — Chat and Terminal are two VIEWS over one session.","Title + objective are fixed for the life of the session — iterate in follow-up messages, don't repurpose."]},{id:"epicEvent",name:"PromptSessionEvent",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> events[]",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts + src/main/lib/epic/activeIndexMerge.cjs "},summary:"One step in an Epic's Prompt → PRD → Response → ... → Closed chain.",fields:[{name:"id",type:"string",key:"pk"},{name:"promptSessionId",type:"string",key:"fk",ref:"epic.id"},{name:"kind",type:"'prompt' | 'prd_created' | 'response' | 'closed'"},{name:"causedByEventId",type:"string | null",key:"fk",ref:"epicEvent.id",note:"must be the session's current tail event — a chain, not a tree"},{name:"at",type:"string"},{name:"prdSlug",type:"string",optional:!0,key:"fk",ref:"prd.slug"},{name:"text",type:"string",optional:!0},{name:"outcome",type:"'completed' | 'failed' | 'needs_review'",optional:!0},{name:"validation",type:"'unvalidated' | 'validating' | 'verified' | 'refuted'",optional:!0}]},{id:"epicTranscriptTurn",name:"PromptSessionTranscriptTurn",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/transcripts/<epicId>.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/promptSessionTranscript.cjs "},summary:"The durable per-Epic transcript store, kept alongside the CLI's own JSONL as a fallback source of turns.",fields:[{name:"v",type:"1"},{name:"epicId",type:"string",key:"fk",ref:"epic.id"},{name:"eventId",type:"string | null",key:"fk",ref:"epicEvent.id"},{name:"role",type:"'user' | 'assistant'"},{name:"at",type:"string"},{name:"text",type:"string"}]},{id:"epicArchive",name:"PromptSessionArchive",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/<epicId>.json",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts (promptSessionArchivePath) "},summary:"On-disk archive written once at completion — freezes the Epic, its events, and its transcript.",fields:[{name:"session",type:"PromptSession"},{name:"events",type:"PromptSessionEvent[]"},{name:"transcript",type:"string"},{name:"archivedAt",type:"string"},{name:"durableTurns",type:"Array<{ role, text, at }>",optional:!0}]},{id:"epicWorktreeConfig",name:"EpicWorktreeConfig",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/epic-worktree-config.json",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicWorktreeProjectConfig.cjs "},summary:"Per-project 'disable Epic worktree isolation' toggle, read by gitWorktree.cjs's isWorktreeDisabled('epic', cwd) on every worktree creation attempt.",fields:[{name:"disabled",type:"boolean"}],notes:["One-shot migration from the legacy machine-wide ~/.claude/session-manager/epic-worktree-project-config.json map, keyed by project cwd — that file is left in place, never deleted."]},{id:"exchange",name:"Exchange",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/exchanges.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/exchanges.cjs "},summary:"One durable NDJSON record per completed terminal-chat exchange, appended off the hot path.",fields:[{name:"ts",type:"string"},{name:"sessionId",type:"string",key:"fk",ref:"epic.claudeSessionId",note:"the tab's claude session id"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"prompt",type:"string"},{name:"result",type:"string"},{name:"summary",type:"string",note:"produced by the shared Haiku summarizer"},{name:"model",type:"string"},{name:"degraded",type:"string",optional:!0,note:"set when summarization failed — the exchange itself is never dropped"},{name:"promptId",type:"string",optional:!0,key:"fk",ref:"prd.slug",note:"originating PromptTicket.id when dispatched from the per-tab queue; forward-only, never backfilled"}],notes:["Written via raw fs O_APPEND (not config.cjs writeJson) for atomicity across concurrent writers — assertOpsWrite is called explicitly since raw fs bypasses the normal enforcement point.","Historical rows from before this store existed remain, untouched and unmigrated, in the old global ~/.claude/knowledge-log/exchanges/<encodeCwd(cwd)>.jsonl."]},{id:"prd",name:"PRD",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/epics/<epicId>/prds/<slug>.md",format:"markdown",writer:"scheduler",definedIn:"src/main/lib/prd/prdLocations.cjs + scheduler_create_prd MCP tool "},summary:"PRD authoring is API-only via the scheduler_create_prd MCP tool — a PRD joins an EXISTING Epic and never conjures one.",fields:[{name:"slug",type:"string",key:"pk",note:"<nn>-<kebab-title>.md filename stem"},{name:"title",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"epicId",type:"string | null",key:"fk",ref:"epic.id",note:"derived from the PRD's DIRECTORY — fact on disk"},{name:"sourcePromptId",type:"string",optional:!0,key:"fk",ref:"epic.id",note:"frontmatter intent — can disagree with epicId"},{name:"sourceTabId",type:"string",optional:!0},{name:"estimateMinutes",type:"number"},{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",optional:!0,key:"fk",ref:"tag.tag"},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug",note:"the SOLE ordering primitive"},{name:"goal",type:"string"},{name:"acceptanceCriteria",type:"string[]"},{name:"implementationNotes",type:"string"},{name:"outOfScope",type:"string[]",optional:!0},{name:"createdVia",type:"string",optional:!0},{name:"issuedAt",type:"string",optional:!0}],notes:["Flat scheduler/prds/ is RETIRED — auto-consolidated into prds-archived/ on every reconcile() pass.","epicId is derived from the DIRECTORY (fact on disk) while sourcePromptId is frontmatter intent and can disagree."]},{id:"scheduleJob",name:"ScheduleJob",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs + src/main/lib/scheduler/scheduleJobSchema.cjs "},summary:"dependsOn is the SOLE ordering primitive — parallelGroup is a display hint, never a barrier.",fields:[{name:"slug",type:"string",key:"pk",note:"shared identity with the PRD it executes"},{name:"title",type:"string"},{name:"cwd",type:"string | null",key:"fk",ref:"project.cwd"},{name:"parallelGroup",type:"number"},{name:"estimateMinutes",type:"number | null"},{name:"bodyPreview",type:"string"},{name:"status",type:"'pending' | 'running' | 'investigating' | 'completed' | 'failed' | 'needs_review' | 'quarantined'"},{name:"runId",type:"string | null",key:"fk",ref:"runLog.runId"},{name:"startedAt",type:"string | null"},{name:"finishedAt",type:"string | null"},{name:"exitCode",type:"number | null"},{name:"error",type:"string | null"},{name:"sessionId",type:"string",optional:!0},{name:"runtime",type:"ScheduleJobRuntime",optional:!0,note:"{ pid, runId, startedAt, sessionId?, cwd? }"},{name:"verifierVerdict",type:"string",optional:!0},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug"},{name:"originSessionId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"sourceTabId",type:"string | null",optional:!0},{name:"sourcePromptId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id",note:"authoritative — derived from the PRD directory"},{name:"statusHistory",type:"ScheduleJobStatusHistoryEntry[]",optional:!0}],notes:["Every launch must take a slot from lib/scheduler/sessionSlots.cjs — the single machine-wide concurrency limit.","--model is always pinned on every claude -p call site.","A job in needs_review is a QUESTION routed back to the authoring Epic and never creates work on its own."]},{id:"scheduleJobStatusHistory",name:"ScheduleJobStatusHistoryEntry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[].statusHistory[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/scheduleJobTransitions.cjs "},summary:"Bounded trail (~20 entries) of accepted status transitions for one ScheduleJob.",fields:[{name:"from",type:"string | null"},{name:"to",type:"string"},{name:"reason",type:"string | null"},{name:"source",type:"string | null"},{name:"at",type:"string"}]},{id:"scheduleHistoryEntry",name:"Schedule history entry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/history.jsonl",format:"jsonl",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs "},summary:"Terminal jobs aged out of queue.json land here, one JSON object per line.",fields:[{name:"slug",type:"string",key:"fk",ref:"prd.slug"},{name:"status",type:"ScheduleJobStatus"},{name:"finishedAt",type:"string | null"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"runId",type:"string | null",optional:!0,key:"fk",ref:"runLog.runId"}]},{id:"scheduleConfig",name:"ScheduleConfig",group:"scheduler",store:{path:"~/.claude/session-manager/scheduler-machine.json",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/schedulerConfig.cjs + src/main/lib/scheduler/queueStore.cjs "},summary:"Machine-level auto-fire policy and utilization gate (scheduler-machine.json, not per-project queue.json).",fields:[{name:"enabled",type:"boolean",note:"legacy on/off, kept for v0.4 backwards compat"},{name:"offsetMinutes",type:"number"},{name:"defaultCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"firePolicy",type:"'manual' | 'when-available'"},{name:"utilizationThreshold",type:"number"},{name:"schemaVersion",type:"1"}]},{id:"runLog",name:"Run log",group:"scheduler",store:{path:"~/.claude/session-manager/scheduled-plans/runs/<runId>/",format:"directory",definedIn:"src/main/scheduler.cjs (RUNS_DIR) "},summary:"One directory per headless claude -p invocation — stdout/stderr/exit capture for a ScheduleJob's run.",fields:[{name:"runId",type:"string",key:"pk"}]},{id:"agentPersona",name:"AgentPersona",aka:"ACTOR",group:"agents",store:{path:"~/.claude/agents/<name>.md",format:"markdown",definedIn:"src/main/agentLibrary.cjs + src/main/lib/persona-macro/agentPersonaSchema.cjs "},summary:"One global persona. The action/actionLabel frontmatter keys are retired legacy fields — no longer a live concept.",fields:[{name:"name",type:"string",key:"pk"},{name:"description",type:"string | null"},{name:"tools",type:"string[]"},{name:"model",type:"string | null",note:"wins over the Settings default for this Epic"},{name:"color",type:"string | null"},{name:"tags",type:"AgentPersonaTag[]",key:"fk",ref:"tag.tag"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd",note:"'*' means every project"},{name:"effort",type:"string | null",optional:!0,note:"per-Epic carve-out like model — persona frontmatter wins over the Settings default"},{name:"title",type:"string | null",optional:!0},{name:"path",type:"string"},{name:"body",type:"string"},{name:"overridingProjects",type:"string[]"}]},{id:"tag",name:"Tag",aka:"MISSION — EpicTag",group:"agents",store:{path:"src/renderer/lib/tagLibrary.ts (TAG_LIBRARY)",format:"code",definedIn:"src/renderer/lib/tagLibrary.ts + src/renderer/lib/agentTagDefs.ts "},summary:"The closed 7-tag union — Epic creation is agentType (who) + tag (what), two independent selections.",fields:[{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",key:"pk"},{name:"label",type:"string"},{name:"description",type:"string"},{name:"developEagerness",type:"'expected-default' | 'available-not-assumed'"},{name:"developsVia",type:"string"}]},{id:"macro",name:"Macro",aka:"HOT KEY",group:"agents",store:{path:"~/.claude/session-manager/macros.json",format:"json",writer:"src/main/lib/persona-macro/macroLibrary.cjs",definedIn:"src/main/lib/persona-macro/macroLibrary.cjs "},summary:"A saved (agent, tag, prompt) hot key — machine-local library shown per project; pressing it is the same act as New Session.",fields:[{name:"id",type:"string",key:"pk"},{name:"label",type:"string"},{name:"agentName",type:"string",key:"fk",ref:"agentPersona.name"},{name:"tag",type:"TicketTag",key:"fk",ref:"tag.tag"},{name:"prompt",type:"string"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd"},{name:"surface",type:"string"},{name:"builtin",type:"boolean",optional:!0},{name:"builtinVersion",type:"number",optional:!0},{name:"createdAt",type:"string"},{name:"updatedAt",type:"string"},{name:"inputs",type:"MacroInput[]",optional:!0},{name:"autoStartTargets",type:"string[]",optional:!0,key:"fk",ref:"project.cwd"}]},{id:"memoryEntry",name:"MemoryEntry",group:"memory",store:{path:"~/.claude/projects/<encodedCwd>/memory/<name>.md",format:"markdown",definedIn:"src/main/memoryTool.cjs "},summary:"One workspace memory file, semantically organized by topic.",fields:[{name:"name",type:"string",key:"pk"},{name:"path",type:"string"},{name:"mtimeMs",type:"number"},{name:"bytes",type:"number"},{name:"workspace",type:"string",key:"fk",ref:"project.cwd",note:"carried on MemoryListResult, denormalized here — the directory this entry lives under"}]},{id:"memoryCluster",name:"MemoryCluster",group:"memory",store:{path:"<cwd>/session-manager-operations/memory-clusters/clusters.json",format:"json",writer:"memory-clusters",definedIn:"src/main/memoryAggregate.cjs "},summary:"Derived grouping of related MemoryEntry files, computed and cached per workspace.",fields:[{name:"id",type:"string",key:"pk"},{name:"name",type:"string"},{name:"summary",type:"string"},{name:"memberSlugs",type:"string[]",key:"fk",ref:"memoryEntry.name"},{name:"links",type:"MemoryClusterLink[]",note:"{ from, to, label? }"}]},{id:"agentMemoryEntry",name:"AgentMemoryEntry",group:"memory",store:{path:"~/.claude/agent-memory/<agent>/ | .claude/agent-memory/<agent>/ | .claude/agent-memory-local/<agent>/",format:"directory",definedIn:"src/main/lib/memoryDirResolve.cjs (resolveAgentMemoryDir)"},summary:"Per-subagent memory in Claude Code's native agent-memory directories (user, project, local scope), keyed by agent name — markdown files with a MEMORY.md index.",fields:[{name:"agent",type:"string",key:"pk",ref:"agentPersona.name",note:"directory name under the scope root"},{name:"scope",type:"'user' | 'project' | 'local'",note:"selects which agent-memory root resolveAgentMemoryDir returns"},{name:"files",type:"markdown[]",note:"topic files plus MEMORY.md index, read live from disk"}]},{id:"claudeTranscript",name:"Claude transcript",group:"transcript",store:{path:"~/.claude/projects/<encodedCwd>/<sessionUuid>.jsonl",format:"jsonl",definedIn:"written by the Claude Code CLI; tailed by src/main/transcripts.cjs "},summary:"The CLI's own append-only transcript — Session Manager only tails and classifies it, never writes it.",fields:[{name:"sessionUuid",type:"string",key:"pk"},{name:"encodedCwd",type:"string",key:"fk",ref:"project.cwd"}]},{id:"transcriptEvent",name:"TranscriptEvent",group:"transcript",store:{path:"in-memory ring buffer, broadcast as transcript:event:<tabId>",format:"in-memory",definedIn:"src/main/transcripts.cjs -> src/renderer/state/live.ts "},summary:"Classified, bounded-preview view over one raw transcript line — never the source of truth.",fields:[{name:"kind",type:"TranscriptEventKind"},{name:"data",type:"unknown"},{name:"raw",type:"unknown"},{name:"previewText",type:"string"},{name:"ref",type:"TranscriptEventRef | null",note:"{ filePath, byteOffset, byteLength }"},{name:"tabId",type:"string",key:"fk",ref:"tab.id"}]},{id:"historyRollupDay",name:"History rollup day",group:"transcript",store:{path:"~/.claude/session-manager/history-rollup.jsonl",format:"jsonl",definedIn:"src/main/lib/historyRollup.cjs "},summary:"One finalized day-per-project analytics row (History tab is analytics/cost/charts only).",fields:[{name:"date",type:"string",key:"pk"},{name:"projectCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"promptCount",type:"number"},{name:"inputTokens",type:"number"},{name:"outputTokens",type:"number"},{name:"estimatedCostUsd",type:"number"}]},{id:"billingUsage",name:"UsageSnapshot",group:"transcript",store:{path:"~/.claude/session-manager/billing-cache.json",format:"json",definedIn:"src/main/usage.cjs (CACHE_PATH) "},summary:"Cached rolling-window utilization percentages from the account's billing API.",fields:[{name:"five_hour",type:"UsageWindow | null"},{name:"seven_day",type:"UsageWindow | null"},{name:"seven_day_sonnet",type:"UsageWindow | null"},{name:"seven_day_opus",type:"UsageWindow | null"},{name:"seven_day_oauth_apps",type:"UsageWindow | null"},{name:"extra_usage",type:"{ is_enabled, monthly_limit, used_credits, utilization, currency } | null"}]},{id:"projectBrief",name:"ProjectBrief",group:"brief",store:{path:"<cwd>/session-manager-operations/project-brief/brief.json",format:"json",writer:"project-home",definedIn:"src/main/projectBrief.cjs "},summary:"The synthesized project Brief — generated, with a hand-edit escape hatch.",fields:[{name:"version",type:"number"},{name:"synthesizedAt",type:"string"},{name:"editedAt",type:"string | null"},{name:"model",type:"string"},{name:"purpose",type:"string"},{name:"what",type:"string[]"},{name:"areas",type:"ProjectBriefArea[]",note:"{ name, files, note, epic, heat }"},{name:"scope",type:"ProjectBriefScopeEntry[]",note:"{ when, kind, text, src }"},{name:"conventions",type:"string[]"},{name:"pins",type:"{ what: boolean; conventions: boolean }"},{name:"pinned",type:"{ what: string[] | null; conventions: string[] | null }"}]},{id:"projectPages",name:"ProjectPagesOutput",group:"brief",store:{path:"<cwd>/session-manager-operations/project-pages/ (knowledge/<id>/, videos/<id>/, videos/_character/)",format:"directory",writer:"project-home",definedIn:"src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs (pages, videos and character routes)"},summary:"The Project Home library: Knowledge Pages and Video Pages, each a folder holding index.html + meta.json.",fields:[{name:"html",type:"string | null"},{name:"mtimeMs",type:"number | null"}]},{id:"settingsScope",name:"Settings (scoped)",group:"config",store:{path:"~/.claude/settings.json + <cwd>/.claude/settings.json + <cwd>/.claude/settings.local.json",format:"json",definedIn:"src/main/config.cjs + src/renderer/state/config.ts + src/renderer/lib/mergeScopes.ts "},summary:"Substrate, not per-Epic curation — model is the one field carved out per-Epic (persona wins over Settings).",fields:[{name:"scope",type:"'system' | 'project' | 'local'",key:"pk"},{name:"cwd",type:"string",optional:!0,key:"fk",ref:"project.cwd"},{name:"model",type:"string",optional:!0}]},{id:"layoutEnvelope",name:"LayoutEnvelope",group:"config",store:{path:"~/.claude/session-manager/workbench-layout.json",format:"json",definedIn:"src/main/layoutStore.cjs + src/renderer/state/layout.ts "},summary:"Persisted dockview panel layout, pruned against the live panel registry on hydrate.",fields:[{name:"version",type:"number"},{name:"panels",type:"string[]",key:"fk",ref:"tab.id"},{name:"dockview",type:"Record<string, unknown>",note:"opaque SerializedDockview blob"}]},{id:"opsNamespace",name:"Ops namespace ownership",aka:"the SINGLE-WRITER LAW",group:"config",store:{path:"src/main/lib/opsOwnership.cjs (OWNERS)",format:"code",definedIn:"src/main/lib/opsOwnership.cjs (assertOpsWrite) "},summary:"Fail-closed — a new top-level ops folder must land in OWNERS (or the deliberately-unowned list) in the same PR that creates it.",fields:[{name:"namespace",type:"string",key:"pk",note:"e.g. 'prompt-sessions', 'scheduler', 'project-brief'"},{name:"writer",type:"string",note:"e.g. 'epics', 'scheduler', 'project-home'"}]},{id:"mcpServerRegistry",name:"MCP server registry",aka:"mcpServers",group:"config",store:{path:"~/.claude.json -> mcpServers",format:"json",definedIn:"src/renderer/components/tabs/McpServers.tsx "},summary:"User-scope MCP server config — no single writer, since both the claude CLI and this app read/write the same file.",fields:[{name:"name",type:"string",key:"pk"},{name:"type",type:"'stdio' | 'http' | 'sse' | 'ws' | 'streamable-http'",optional:!0},{name:"command",type:"string",optional:!0},{name:"args",type:"string[]",optional:!0},{name:"url",type:"string",optional:!0},{name:"env",type:"Record<string, string>",optional:!0},{name:"headers",type:"Record<string, string>",optional:!0},{name:"alwaysLoad",type:"boolean",optional:!0},{name:"enabled",type:"boolean",optional:!0},{name:"disabledTools",type:"string[]",optional:!0}]},{id:"pluginRegistry",name:"Installed plugins manifest",aka:"installed_plugins.json",group:"config",store:{path:"~/.claude/plugins/installed_plugins.json",format:"json",definedIn:"src/renderer/components/tabs/Plugins.tsx "},summary:'Registry of installed plugin versions, keyed by "<name>@<marketplace>" — written by `claude plugin install`, read-only in the Plugins screen.',fields:[{name:"pluginKey",type:"string",key:"pk",note:"<name>@<marketplace>"},{name:"scope",type:"string"},{name:"installPath",type:"string"},{name:"version",type:"string"},{name:"installedAt",type:"string"},{name:"lastUpdated",type:"string"},{name:"gitCommitSha",type:"string",optional:!0}]},{id:"systemPrompt",name:"User CLAUDE.md",aka:"~/.claude/CLAUDE.md",group:"config",store:{path:"~/.claude/CLAUDE.md",format:"markdown",definedIn:"src/renderer/components/tabs/SystemPrompt.tsx "},summary:"The real ~/.claude/CLAUDE.md the claude CLI loads into every session it starts on this machine, in every project — edited here as plain markdown.",fields:[{name:"content",type:"string"},{name:"imports",type:"string[]",note:"@-imported files, listed in a left rail"}]},{id:"skillsAndCommands",name:"Skills & Commands",group:"config",store:{path:"~/.claude/skills/**/SKILL.md + ~/.claude/commands/*.md (and the <cwd>/.claude equivalents for project scope)",format:"directory",definedIn:"src/renderer/components/tabs/Skills.tsx "},summary:"User- and project-scope skill/command markdown files, each editable in place.",fields:[{name:"kind",type:"'skills' | 'commands'"},{name:"scope",type:"'user' | 'project'"},{name:"name",type:"string",key:"pk"},{name:"path",type:"string",note:"absolute path to the editable markdown file"},{name:"dir",type:"string | null",note:"skill directory, if applicable"},{name:"disabled",type:"boolean",note:"skills only — disable-model-invocation: true frontmatter"},{name:"description",type:"string",optional:!0}]},{id:"mcpStatusProbe",name:"MCP status probe",group:"config",store:{path:"in-memory result of `claude mcp list`, never persisted",format:"in-memory",definedIn:"src/main/mcpStatus.cjs (runProbe) "},summary:"Read-only, non-polling live connection probe — models an in-memory-only shape honestly, the same way transcriptEvent does.",fields:[{name:"ok",type:"boolean"},{name:"servers",type:"McpServerStatus[]",note:"{ name, target, transport, status }"},{name:"error",type:"string",optional:!0},{name:"checkedAt",type:"number"}]},{id:"appPrefs",name:"App preferences",aka:"app-prefs / ui-settings-prefs / ui-chrome-prefs",group:"config",store:{path:"~/.claude/session-manager/app-prefs.json + ~/.claude/session-manager/ui-settings-prefs.json + ~/.claude/session-manager/ui-chrome-prefs.json",format:"json",definedIn:"src/renderer/lib/appPrefs.ts (app-prefs.json) + src/renderer/lib/uiSettingsPrefs.ts (ui-settings-prefs.json) + src/renderer/state/uiChromePrefs.ts (ui-chrome-prefs.json) "},summary:"Three small machine-level renderer-owned pref files, read/written through window.api.config — distinct from scheduler-machine.json.",fields:[{name:"openToHomeOnLaunch",type:"boolean",optional:!0,note:"app-prefs.json — read by layout.ts at boot"},{name:"uiSettings",type:"Record<string, unknown>",optional:!0,note:"ui-settings-prefs.json — Settings page UI state"},{name:"uiChrome",type:"Record<string, unknown>",optional:!0,note:"ui-chrome-prefs.json — app chrome UI state"}]},{id:"uiPrefs",name:"UiPrefs",aka:"ui-prefs/prefs.json",group:"config",store:{path:"<cwd>/session-manager-operations/ui-prefs/prefs.json",format:"json",writer:"ui-prefs",definedIn:"src/renderer/lib/uiPrefs.ts "},summary:"Per-project UI state that used to live in scattered global/localStorage keys — one file per project keeps it scoped to the project it belongs to by construction (PRD 1398/1399).",fields:[{name:"fileTreeExpanded",type:"string[]",optional:!0,note:"FileTree.tsx — expanded folder paths in the Files sidebar"},{name:"hiddenCompletedSlugs",type:"string[]",optional:!0,note:'SchedulePanel.tsx — "Clear completed" hides, renderer-side only'},{name:"queueFilterStatus",type:"string",optional:!0,note:"SchedulePanel.tsx — the queue's status filter chip"},{name:"epicPins",type:"Record<string, boolean>",optional:!0,key:"fk",ref:"epic.id",note:"epicsPrefs.ts — pinned-to-top Epic ids, keyed by epicId (moved off the global epics-prefs.json)"},{name:"chatVerbosityPerEpic",type:"Record<string, ChatVerbosity>",optional:!0,key:"fk",ref:"epic.id",note:"chatPrefs.ts — per-Epic verbosity overrides, keyed by epicId (moved off the global chat-prefs.json)"},{name:"editorSession",type:"{ openFiles: string[]; activeFilePath: string | null; viewModeByPath: Record<string, string> }",optional:!0,note:"editor.ts — the Editor scene's structural tab strip only; buffers/baselines/dirty are never persisted (PRD 1400)"}]}];function te(t){const n=B.find(s=>s.id===t);if(!n)throw new Error(`unknown ErdEntity id: ${t}`);return n}const ve=[{from:"tab",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"epic",to:"agentPersona",cardinality:"N-1",label:"actor",optional:!0},{from:"epic",to:"epic",cardinality:"N-1",label:"resumed from",optional:!0},{from:"epic",to:"claudeTranscript",cardinality:"1-1",label:"1:1 session"},{from:"epicEvent",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicEvent",to:"epicEvent",cardinality:"N-1",label:"caused by",optional:!0},{from:"epicEvent",to:"prd",cardinality:"N-1",label:"about",optional:!0},{from:"epicTranscriptTurn",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicTranscriptTurn",to:"epicEvent",cardinality:"N-1",label:"labeled by",optional:!0},{from:"epicArchive",to:"epic",cardinality:"1-1",label:"freezes"},{from:"exchange",to:"epic",cardinality:"N-1",label:"session for",optional:!0},{from:"exchange",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"epic",cardinality:"N-1",label:"joins (directory fact)"},{from:"prd",to:"epic",cardinality:"N-1",via:"sourcePromptId",label:"authored from (frontmatter intent)",optional:!0},{from:"prd",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"scheduleJob",to:"prd",cardinality:"1-1",label:"executes"},{from:"scheduleJob",to:"prd",cardinality:"N-N",via:"dependsOn",label:"depends on",optional:!0},{from:"scheduleJob",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleJob",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleJob",to:"scheduleJob",cardinality:"N-N",via:"dependsOn",label:"depends on (self)",optional:!0},{from:"scheduleJobStatusHistory",to:"scheduleJob",cardinality:"N-1",label:"transitions of"},{from:"scheduleHistoryEntry",to:"prd",cardinality:"N-1",label:"archives"},{from:"scheduleHistoryEntry",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleHistoryEntry",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleConfig",to:"project",cardinality:"1-1",label:"configures"},{from:"agentPersona",to:"tag",cardinality:"N-N",label:"tagged with"},{from:"agentPersona",to:"project",cardinality:"N-N",label:"scoped to"},{from:"memoryEntry",to:"project",cardinality:"N-1",label:"workspace"},{from:"memoryCluster",to:"memoryEntry",cardinality:"1-N",label:"clusters"},{from:"agentMemoryEntry",to:"agentPersona",cardinality:"N-1",label:"belongs to"},{from:"transcriptEvent",to:"tab",cardinality:"N-1",label:"classified for"},{from:"transcriptEvent",to:"claudeTranscript",cardinality:"N-1",label:"classified from"},{from:"claudeTranscript",to:"project",cardinality:"N-1",label:"belongs to"},{from:"historyRollupDay",to:"project",cardinality:"N-N",label:"aggregates"},{from:"billingUsage",to:"scheduleConfig",cardinality:"1-N",label:"gates when-available firing"},{from:"projectBrief",to:"project",cardinality:"1-1",label:"describes"},{from:"projectBrief",to:"epic",cardinality:"N-1",via:"areas[].epic",label:"traces to",optional:!0},{from:"projectPages",to:"project",cardinality:"1-1",label:"generated for"},{from:"settingsScope",to:"project",cardinality:"N-1",label:"scoped to",optional:!0},{from:"layoutEnvelope",to:"tab",cardinality:"1-N",label:"panels for"},{from:"opsNamespace",to:"epic",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"prd",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"projectBrief",cardinality:"1-N",label:"governs writes"}];function we(t){return ve.filter(n=>n.from===t||n.to===t)}function Tt(t){const n=new Set;for(const s of we(t)){const r=s.from===t?s.to:s.from;r!==t&&n.add(r)}return[...n]}function It(t){switch(t){case"1-1":return"1—1";case"1-N":return"1—N";case"N-1":return"N—1";case"N-N":return"N—N"}}const ge=220,Q=7,Pt=44,Rt=16,At=10,Mt=96,Lt=28,W=24;function Dt(t){const n=Math.min(t,Q)+(t>Q?1:0);return Pt+n*Rt+At}function Ot(t){const n=t.x+t.w,s=t.y+t.h*.35,r=t.y+t.h*.65,i=n+48;return{d:`M ${n} ${s} C ${i} ${s}, ${i} ${r}, ${n} ${r}`,mx:i,my:(s+r)/2}}function $t(t=B,n=ve){const s=G.map(p=>p.id).filter(p=>t.some(f=>f.group===p)),r=[],i=new Map;s.forEach((p,f)=>{const m=W+f*(ge+Mt);let c=W;for(const g of t){if(g.group!==p)continue;const j=Dt(g.fields.length),v={id:g.id,group:p,x:m,y:c,w:ge,h:j};r.push(v),i.set(g.id,v),c+=j+Lt}});const a=new Set(t.map(p=>p.id)),d=[];for(const p of n){if(!a.has(p.from)||!a.has(p.to))continue;const f=i.get(p.from),m=i.get(p.to);if(!f||!m)continue;if(p.from===p.to){const T=Ot(f);d.push({relation:p,...T});continue}const c=f.x<m.x,g=c?f.x+f.w:f.x,j=f.y+f.h/2,v=c?m.x:m.x+m.w,N=m.y+m.h/2,S=Math.max(40,Math.abs(v-g)/2),h=g+(c?S:-S),w=v+(c?-S:S),C=`M ${g} ${j} C ${h} ${j}, ${w} ${N}, ${v} ${N}`;d.push({relation:p,d:C,mx:(g+v)/2,my:(j+N)/2})}const u=r.reduce((p,f)=>Math.max(p,f.x+f.w),0),y=r.reduce((p,f)=>Math.max(p,f.y+f.h),0);return{boxes:r,edges:d,width:u+W,height:y+W}}const _t=[{key:"diagram",label:"Diagram"},{key:"tables",label:"Tables"}];function Ht(){const[t,n]=o.useState("diagram"),[s,r]=o.useState(null),[i,a]=o.useState(()=>new Set),d=o.useMemo(()=>B.filter(m=>!i.has(m.group)),[i]),u=o.useMemo(()=>$t(d),[d]),y=m=>{a(c=>{const g=new Set(c);return g.has(m)?g.delete(m):g.add(m),g}),r(null)},p=s?te(s):null,f=m=>d.some(c=>c.id===m);return e.jsx(st,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(ye,{options:_t,active:t,onChange:n}),e.jsx(Ft,{hiddenGroups:i,onToggle:y}),e.jsxs("span",{className:"ml-auto text-fg-faint",children:[B.length," entities"]})]}),children:t==="diagram"?e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(Ut,{layout:u,selectedId:s,onSelect:m=>r(c=>c===m?null:m)})}),e.jsx("div",{className:"w-96 shrink-0 border-l border-line overflow-y-auto",children:p?e.jsx(Wt,{entity:p,onSelectRelated:m=>f(m)?r(m):void 0}):e.jsx(q,{title:"select an entity",hint:"click a box in the diagram to see its storage, fields, and relations"})})]}):e.jsx(Jt,{})})}const Bt=o.memo(Ht);function Ft({hiddenGroups:t,onToggle:n}){return e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:G.map(s=>{const r=t.has(s.id);return e.jsxs("button",{onClick:()=>n(s.id),title:`${s.blurb} (${s.realm})`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10.5px] ${r?"border-line text-fg-faint opacity-50":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${s.tone.dot}`}),s.label,e.jsx("span",{className:"text-fg-faint",children:s.realm})]},s.id)})})}function Ut({layout:t,selectedId:n,onSelect:s}){const r=o.useMemo(()=>n?new Set(Tt(n)):null,[n]),i=a=>!!n&&(a.relation.from===n||a.relation.to===n);return t.boxes.length===0?e.jsx(q,{title:"no entities in view",hint:"toggle a group in the legend to show its entities"}):e.jsxs("div",{className:"relative p-4",style:{width:t.width+32,height:t.height+32},children:[e.jsxs("svg",{width:t.width,height:t.height,className:"absolute left-4 top-4 overflow-visible",children:[t.edges.map(a=>{const d=i(a);return e.jsx("path",{"data-testid":`erd-edge-${a.relation.from}-${a.relation.to}`,d:a.d,fill:"none",className:d?"stroke-accent":"stroke-line",strokeWidth:d?2:1,opacity:n&&!d?.25:1},`${a.relation.from}-${a.relation.to}-${a.relation.label}`)}),t.edges.map(a=>i(a)?e.jsx("text",{x:a.mx,y:a.my,textAnchor:"middle",className:"fill-fg-dim text-[10px]",children:a.relation.label},`label-${a.relation.from}-${a.relation.to}-${a.relation.label}`):null)]}),t.boxes.map(a=>e.jsx(zt,{box:a,selected:a.id===n,dimmed:!!n&&a.id!==n&&!(r!=null&&r.has(a.id)),onClick:()=>s(a.id)},a.id))]})}function zt({box:t,selected:n,dimmed:s,onClick:r}){const i=te(t.id),a=je(t.group),d=i.fields.slice(0,Q),u=i.fields.length-d.length;return e.jsxs("button",{type:"button","data-testid":`erd-box-${t.id}`,onClick:r,className:`absolute text-left rounded border overflow-hidden bg-bg-hi ${n?"border-accent ring-1 ring-accent":"border-line"} ${s?"opacity-30":""}`,style:{left:t.x,top:t.y,width:t.w,height:t.h},children:[e.jsxs("div",{className:"px-2 py-1 border-b border-line flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${a.tone.dot}`}),e.jsx("span",{className:"text-[11px] font-semibold text-fg truncate",children:i.name})]}),i.aka&&e.jsx("div",{className:"px-2 pt-0.5 text-[9.5px] text-fg-faint truncate",children:i.aka}),e.jsxs("div",{className:"px-2 py-0.5",children:[d.map(y=>e.jsxs("div",{className:"text-[9.5px] font-mono text-fg-dim truncate flex items-center gap-1",children:[y.key&&e.jsx("span",{className:"text-fg-faint",children:y.key}),e.jsx("span",{className:"truncate",children:y.name})]},y.name)),u>0&&e.jsxs("div",{className:"text-[9.5px] text-fg-faint italic",children:["+",u," more"]})]})]})}function ke({fields:t}){return e.jsxs("table",{className:"w-full text-[11px] font-mono",children:[e.jsx("thead",{className:"text-fg-faint uppercase tracking-wide text-[9.5px]",children:e.jsxs("tr",{className:"border-b border-line",children:[e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"name"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"type"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"key"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"note"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{className:"border-b border-line/50",children:[e.jsxs("td",{className:"px-2 py-1 text-fg",children:[n.name,n.optional&&e.jsx("span",{className:"text-fg-faint",children:"?"})]}),e.jsx("td",{className:"px-2 py-1 text-fg-dim",children:n.type}),e.jsx("td",{className:"px-2 py-1",children:n.key&&e.jsxs(L,{tone:n.key==="pk"?"accent":"dim",children:[n.key,n.ref?` → ${n.ref}`:""]})}),e.jsx("td",{className:"px-2 py-1 text-fg-faint",children:n.note})]},n.name))})]})}function Ne({entity:t}){return e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"path"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:t.store.path})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"format"}),e.jsx("span",{className:"font-mono text-fg-dim",children:t.store.format})]}),t.store.writer&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"writer"}),e.jsxs(L,{tone:"accent",children:["single-writer: ",t.store.writer]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"definedIn"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:t.store.definedIn})]})]})}function Wt({entity:t,onSelectRelated:n}){const s=je(t.group),r=we(t.id);return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s.tone.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.name})]}),t.aka&&e.jsx("div",{className:"text-[10.5px] text-fg-faint",children:t.aka}),e.jsx(L,{tone:"dim",className:"mt-1",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.summary}),e.jsxs("div",{children:[e.jsx(J,{children:"storage"}),e.jsx(Ne,{entity:t})]}),e.jsxs("div",{children:[e.jsx(J,{children:"fields"}),e.jsx(ke,{fields:t.fields})]}),t.notes&&t.notes.length>0&&e.jsxs("div",{children:[e.jsx(J,{children:"notes"}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:t.notes.map(i=>e.jsx("li",{children:i},i))})]}),e.jsxs("div",{children:[e.jsx(J,{children:"relations"}),r.length===0?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"no relations"}):e.jsx("ul",{className:"space-y-1",children:r.map(i=>{const a=i.from===t.id?i.to:i.from,d=te(a);return e.jsxs("li",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-mono text-fg-faint w-10 shrink-0",children:It(i.cardinality)}),e.jsx("span",{className:"text-fg-dim",children:i.label}),i.via&&e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:["via ",i.via]}),e.jsx("button",{type:"button",onClick:()=>n(a),className:"ml-auto text-accent hover:underline font-mono",children:d.name})]},`${i.from}-${i.to}-${i.label}`)})})]})]})}function J({children:t}){return e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1 font-mono",children:t})}function Jt(){return e.jsx("div",{className:"p-4 space-y-6",children:G.map(t=>{const n=B.filter(s=>s.group===t.id);return n.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${t.tone.dot}`}),e.jsx("span",{className:"text-xs font-semibold text-fg",children:t.label}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:t.realm})]}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:n.map(s=>e.jsxs("div",{className:"border border-line rounded bg-bg-hi p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.name}),s.aka&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:s.aka})]}),e.jsx(L,{tone:"dim",className:"mt-1",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.summary}),e.jsx(Ne,{entity:s}),e.jsx(ke,{fields:s.fields}),s.notes&&s.notes.length>0&&e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:s.notes.map(r=>e.jsx("li",{children:r},r))})]},s.id))})]},t.id)})})}const he=[{key:"voice",label:"Voice"},{key:"appearance",label:"Appearance"},{key:"telemetry",label:"Telemetry"},{key:"remote",label:"Phone remote"},{key:"updates",label:"Updates & retention"},{key:"startup",label:"Startup"},{key:"storage",label:"Storage map"}],Vt={compact:"Compact",roomy:"Roomy"},qt=".claude/session-manager";function Gt({files:t}){const n=Xe();return e.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3","data-testid":"app-settings-chips",children:t.map(s=>{const r=s.path.startsWith("~/")?n?n+s.path.slice(1):null:s.path;return r?e.jsx(et,{path:r,keyPath:s.keyPath},s.path):null})})}function Xt(){const[t,n]=o.useState(!1),[s,r]=o.useState(!1);o.useEffect(()=>{let a=!0;return Ze().then(d=>{a&&n(d.openToHomeOnLaunch===!0)}),()=>{a=!1}},[]);const i=async a=>{n(a),r(!0);try{await Qe({openToHomeOnLaunch:a})}catch{n(!a),xe.error('Failed to save "Open to Home on launch" — try again.')}finally{r(!1)}};return e.jsx("div",{className:"p-4 max-w-3xl space-y-3 text-sm",children:e.jsx(O,{checked:t,onChange:i,disabled:s,label:"Open to Home on launch"})})}function Yt(){const{density:t,setDensity:n}=Ye();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsx(mt,{}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx(Ke,{options:["compact","roomy"],value:t,onChange:s=>n(s),labels:Vt}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]})}const D=(t,n)=>({path:`~/${qt}/${t}`,keyPath:n}),Kt={voice:[D("voice.json")],appearance:[{path:Ge,keyPath:["terminal"]},D("ui-chrome-prefs.json")],telemetry:[D("telemetry.json"),D("otel.json")],remote:[D("web-remote.json")],updates:[D("updater.json"),D("ops-retention.json")],startup:[{path:qe,keyPath:["openToHomeOnLaunch"]}],storage:[]};function rn(){const[t,n]=o.useState("voice");return Ve("app-settings",s=>{he.some(r=>r.key===s)&&n(s)}),e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"app-settings",children:[e.jsx("div",{className:"flex items-center px-4 pt-3",children:e.jsx(ye,{options:he,active:t,onChange:n})}),e.jsx(Gt,{files:Kt[t]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto","data-testid":`app-settings-${t}`,children:[t==="voice"&&e.jsx(it,{open:!0,onClose:()=>{},variant:"page"}),t==="appearance"&&e.jsx(Yt,{}),t==="telemetry"&&e.jsx(gt,{}),t==="remote"&&e.jsx(wt,{}),t==="updates"&&e.jsxs("div",{className:"p-4 max-w-3xl space-y-5",children:[e.jsx(kt,{}),e.jsx(Et,{})]}),t==="startup"&&e.jsx(Xt,{}),t==="storage"&&e.jsx(Bt,{})]})]})}export{rn as AppSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{at as o,a3 as b}from"./index-DfWJO7nP.js";function u({children:n,onClick:s,disabled:a,variant:e="default",tooltip:t,type:d="button",className:c}){const i=`px-2 py-0.5 text-xs rounded border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${e==="primary"?"text-accent border-accent/50 hover:bg-bg-hi":e==="danger"?"text-red-400 hover:text-red-300 border-line hover:border-red-400/50":"text-fg-dim border-line hover:text-fg hover:bg-bg-hi"} ${c??""}`,r=o.jsx("button",{type:d,title:t,onClick:s,disabled:a,className:i,children:n});return t?o.jsx(b,{content:t,align:"bottom-center",children:r}):r}export{u as B};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-CvPdxg56.js","./index-DfWJO7nP.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-DfWJO7nP.js";import{V as Fe}from"./ViewTabs-BYrRSHb6.js";import{S as le}from"./SourceChip-C2YMnlV8.js";import{P as ae}from"./Panel-OUbLHNsS.js";import{L as ue}from"./ListDetail-BeO3lY8t.js";import{S as Se,f as he,m as _e,e as Ie,M as Be,d as We}from"./Library-BGmD-xZN.js";import{T as Je}from"./Toggle-BnJF4V6k.js";import{P as te}from"./ProvenanceBadge-kr7arZqu.js";import{_ as He}from"./monaco-editor-BsIlgG7c.js";import"./Button-fOCJry21.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-CvPdxg56.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};
|