claude-code-session-manager 0.139.0 → 0.141.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/README.md +20 -4
- package/dist/assets/AppSettings-DExeJhqQ.js +2 -0
- package/dist/assets/History-DJMiuXyK.js +2 -0
- package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-Csyd9HbD.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/Scheduler-cyr61UAC.js +16 -0
- package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-BpGRKOcY.js → Skills-C1v91GEO.js} +26 -26
- package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/index-B2TQz3nd.js +3121 -0
- package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +423 -426
- package/package.json +5 -2
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -19
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +1 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +205 -18
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +88 -5
- package/src/main/historyDashboard.cjs +69 -4
- package/src/main/index.cjs +56 -2
- package/src/main/ipcSchemas.cjs +122 -16
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +90 -20
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +25 -5
- package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
- package/src/main/lib/epic/epicOutsideState.cjs +2 -2
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/externalContract.cjs +31 -5
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
- package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +26 -0
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +132 -13
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +377 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +121 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +10 -1
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +19 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +89 -18
- package/src/main/scheduler.cjs +1080 -89
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +14 -1
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +10 -2
- package/src/preload/api.d.ts +364 -21
- package/src/preload/apiSurface.json +89 -10
- package/src/preload/index.cjs +23 -2
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
- package/dist/assets/History-DDnqaLyw.js +0 -2
- package/dist/assets/Scheduler-NLs08fx7.js +0 -16
- package/dist/assets/index-C-d0DCre.js +0 -3124
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-
|
|
2
|
-
import{bl as oe,aR as r,bg as ae,aC as et,C as tt,aB as e,m as Y,F as nt,P as st,ai as at,a9 as Be,aZ as Ne,ag as lt,ba as H,by as ot,bn as ye,a0 as se,bd as Se,b9 as Ee,aa as it,aG as Q,bo as ue,bc as Ue,ae as me,M as He,E as Ge,A as rt,c as We,e as we,bw as ct,aH as dt,aO as ut,b7 as ft,az as Pe,H as mt,L as pt,r as gt,p as xt}from"./index-C-d0DCre.js";import{C as ht,I as bt,p as vt,L as Ve,t as jt,z as yt,A as wt,B as kt,u as Ct,y as Te,c as Ke,b as pe,g as Nt,s as St,r as Et,H as le,d as Je,f as ze,e as ke,i as Ce,F as $t,x as Lt,D as Mt,J as Pt,E as Tt,w as At,G as Dt,m as Rt,a as It,h as Ot,S as Ft,j as _t,k as Bt,l as Ut,M as Ht,P as Gt,n as Wt,o as Vt,v as Kt}from"./Skills-BpGRKOcY.js";import{s as Jt,S as zt}from"./ViewTabs-C0PRZx4_.js";import{_ as qt}from"./monaco-editor-BsIlgG7c.js";import{P as Yt}from"./Panel-Csyd9HbD.js";import"./TiptapBody-DSU3769X.js";const Xt={skills:null,mcp:null,plugins:null},Zt={fileId:"claudeJson",scope:"user"};function Qt(t){return{skillsDir:`${t}/.claude/skills`,commandsDir:`${t}/.claude/commands`,claudeJson:`${t}/.claude.json`,pluginsManifest:`${t}/.claude/plugins/installed_plugins.json`}}async function en(t,n){const[s,l]=await Promise.all([et(t),window.api.config.listDir(n,{filesOnly:!0})]),o=s.errors[0];if(o)throw new Error(`${o.path}: ${o.error}`);if(!l.ok)throw new Error(`${n}: ${l.error??"failed to list directory"}`);return s.entries.length+l.entries.filter(i=>i.name.endsWith(".md")).length}async function tn(){const{data:t}=await window.api.claudeConfig.read(Zt),n=t==null?void 0:t.mcpServers;return n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).length:0}async function nn(){return(await window.api.plugins.list()).length}function sn(){const t=oe(),[n,s]=r.useState(Xt),l=r.useRef({skills:0,mcp:0,plugins:0}),o=r.useCallback((f,x)=>{const u=l.current,y=++u[f],h=w=>{u[f]===y&&s(S=>S[f]===w?S:{...S,[f]:w})};x().then(h,()=>h(null))},[]),i=r.useMemo(()=>t?Qt(t):null,[t]),a=r.useCallback(()=>{i&&o("skills",()=>en(i.skillsDir,i.commandsDir))},[i,o]),m=r.useCallback(()=>o("mcp",tn),[o]),g=r.useCallback(()=>o("plugins",nn),[o]);return r.useEffect(()=>{const f=l.current;return a(),()=>{f.skills++}},[a]),r.useEffect(()=>{const f=l.current;return m(),g(),()=>{f.mcp++,f.plugins++}},[m,g]),ae(i?[i.skillsDir,i.commandsDir]:[],a),ae(i?[i.claudeJson]:[],m),ae(i?[i.pluginsManifest]:[],g),n}const an="User · every project on this machine",ln={title:"Nothing tells Claude how you like to work yet.",body:"Claude loads this file into every session it starts on this machine, in every project."};function on(){const t=oe(),n=r.useMemo(()=>t?tt.resolve("user",t,null):null,[t]),s=r.useMemo(()=>n?[{path:n,label:an,eyebrow:"YOUR INSTRUCTIONS FOR EVERY PROJECT"}]:[],[n]);return!t||!n?e.jsx(Y,{title:"loading…"}):e.jsx("div",{className:"flex flex-col h-full min-h-0","data-testid":"system-prompt",children:e.jsx(ht,{home:t,scope:"user",roots:s,activeRoot:n,empty:ln,testIdPrefix:"system-prompt",moreMenu:({importSelected:l})=>e.jsx(bt,{path:n,disabled:l})})})}const rn=r.memo(on);function cn({value:t,onChange:n,path:s,readOnly:l,theme:o="dark"}){const i=o==="paper";return e.jsx(nt,{path:`file://${s}`,defaultLanguage:"markdown",value:t,onChange:a=>n(a??""),beforeMount:i?at:void 0,theme:i?st:"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:l,automaticLayout:!0}})}const dn=r.lazy(()=>qt(()=>import("./SkillReferenceGraph-DcscPXAG.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function un({pluginName:t,skills:n,onBack:s,initialSelectedId:l}){var x;const[o,i]=r.useState(l??((x=n[0])==null?void 0:x.id)??null),a=o?n.find(u=>u.id===o)??null:null,m=r.useMemo(()=>vt(n),[n]),[g,f]=r.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:s,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(a==null?void 0:a.name)??(a==null?void 0:a.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 ${g==="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 ${g==="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:[a!=null&&a.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:a.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",m.length," ",m.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(Y,{title:"no skills in this plugin"}):g==="graph"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(dn,{skills:n,edges:m,selectedId:o,onSelect:i})}):e.jsx(Ve,{sidebar:e.jsx("div",{className:"py-1",children:n.map(u=>e.jsxs("button",{onClick:()=>i(u.id),className:`w-full px-3 py-1 text-xs text-left ${o===u.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:u.name??u.id}),u.description?e.jsx("div",{className:"truncate text-fg-faint",children:u.description}):null]},u.id))}),detail:a?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(cn,{path:a.path,value:a.body,onChange:()=>{},readOnly:!0})}):e.jsx(Y,{title:"select a skill"})})})]})}function fn({row:t,busy:n,onUninstall:s}){const[l,o]=r.useState(!1),[i,a]=r.useState(!1),m=r.useRef(null),g=r.useId(),f=r.useCallback(()=>{o(!1),a(!1)},[]);r.useEffect(()=>{if(!l)return;const w=P=>{var E;(E=m.current)!=null&&E.contains(P.target)||f()},S=P=>{P.key==="Escape"&&f()};return window.addEventListener("mousedown",w),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",w),window.removeEventListener("keydown",S)}},[l,f]);const x=()=>{f(),Ne(t.path)},u=async()=>{f(),await lt(t.path)||H.error(`Could not copy ${t.path} to the clipboard`)},y=()=>{f(),s(t)},h="px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev";return e.jsxs("div",{ref:m,className:"relative self-start",children:[e.jsx("button",{type:"button","data-testid":"plugin-menu","aria-label":`Actions for ${t.name}`,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?g:void 0,onClick:()=>l?f():o(!0),className:"w-[30px] h-7 inline-flex items-center justify-center bg-bg border border-line rounded-md text-fg-dim hover:border-rule",children:e.jsxs("svg",{"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}),l&&e.jsx("div",{id:g,role:"menu","aria-label":`Actions for ${t.name}`,className:`absolute ${Be.dialog} right-0 top-[34px] w-[210px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[12.5px] text-fg`,children:i?e.jsxs("div",{className:"flex flex-col gap-2 px-2.5 py-[7px]",children:[e.jsxs("span",{className:"font-medium",children:["Uninstall ",t.name,"?"]}),e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx("button",{type:"button",role:"menuitem","data-testid":"plugin-uninstall",disabled:n,onClick:y,className:"h-6 px-2.5 rounded-[5px] bg-delta-bad text-bg-hi font-medium hover:bg-delta-bad/90 disabled:opacity-40",children:"Confirm"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(!1),className:"h-6 px-2.5 rounded-[5px] border border-line text-fg-dim hover:bg-bg-elev",children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",role:"menuitem",onClick:x,className:h,children:"Reveal in File Explorer"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>void u(),className:h,children:"Copy path"}),e.jsx("div",{role:"separator",className:"h-px mx-1.5 my-1 bg-line"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!t.marketplace||n,title:t.marketplace?void 0:"No marketplace is recorded for this install",onClick:()=>a(!0),className:`${h} font-medium text-delta-bad hover:bg-delta-bad/10 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:["Uninstall ",t.name]})]})})]})}function qe({name:t,enabled:n,disabled:s,onToggle:l,testId:o="plugin-enabled-switch"}){return e.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":`${n?"Disable":"Enable"} ${t}`,"data-testid":o,disabled:s,onClick:i=>{i.stopPropagation(),l()},onKeyDown:i=>i.stopPropagation(),className:`relative shrink-0 w-[30px] h-[18px] rounded-full transition-colors align-middle disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent ${n?"bg-accent":"bg-rule"}`,children:e.jsx("span",{"aria-hidden":"true",className:`absolute top-0.5 w-3.5 h-3.5 rounded-full bg-bg-hi shadow transition-[left] ${n?"left-[14px]":"left-0.5"}`})})}const mn="Saved — matches settings.json › enabledPlugins",pn=250,gn=["hooks/hooks.json",".mcp.json","agents","skills","commands",".claude-plugin/plugin.json"],xn=(t,n,s)=>`${t} ${t===1?n:s}`;function hn(t){var s;const n=["PLUGIN"];return t.marketplace&&n.push(t.marketplace.toUpperCase()),(s=t.manifest)!=null&&s.version&&n.push(`V${t.manifest.version.toUpperCase()}`),n.push(`${(t.scope??"user").toUpperCase()} SCOPE`),n.join(" · ")}function bn(t,n){const s=i=>{const m=i.trim().replace(/^v/i,"").split(/[-+]/)[0].split(".");return m.every(g=>/^\d+$/.test(g))?m.map(Number):null},l=s(t),o=s(n);if(!l||!o)return null;for(let i=0;i<Math.max(l.length,o.length);i++){const a=(l[i]??0)-(o[i]??0);if(a!==0)return Math.sign(a)}return 0}function vn(t,n){if(!t||!n)return null;const s=bn(n,t);return s===null?n.trim()===t.trim()?"up-to-date":"update-available":s>0?"update-available":"up-to-date"}const jn=t=>t.key&&t.key.includes("@")?t.key.slice(0,t.key.lastIndexOf("@")):t.name,de=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function Ae(t,n){if(!de(t))return[];const s=de(t.hooks)?t.hooks:t,l=[];for(const[o,i]of Object.entries(s))Array.isArray(i)&&i.forEach((a,m)=>{if(!de(a)||!Array.isArray(a.hooks))return;const g=typeof a.matcher=="string"&&a.matcher?` · ${a.matcher}`:"";a.hooks.forEach((f,x)=>{const u=de(f)?typeof f.command=="string"?f.command:typeof f.prompt=="string"?f.prompt:null:null;l.push({id:`${n}:${o}:${m}:${x}`,name:`${o}${g}`,description:u})})});return l}async function yn(t,n){const s=n==null?void 0:n.hooks,l=typeof s=="string"?[s]:Array.isArray(s)?s.filter(a=>typeof a=="string"):[],o=new Set;for(const a of l)a.startsWith("/")||a.split("/").includes("..")||o.add(`${t}/${a.replace(/^\.\//,"")}`);o.add(`${t}/hooks/hooks.json`);const i=await Promise.all([...o].map(async a=>{const m=await window.api.config.readJson(a);return{p:a,data:m.exists&&!m.parseError?m.data:null}}));return[...de(s)?Ae(s,"manifest"):[],...i.flatMap(({p:a,data:m})=>Ae(m,a))]}function wn({row:t,home:n,busy:s,onToggle:l,onUninstall:o,onJump:i}){var Z,p,W;const[a,m]=r.useState([]),[g,f]=r.useState([]),[x,u]=r.useState(null),[y,h]=r.useState(!0),[w,S]=r.useState([]),P=r.useRef(0),[E,O]=r.useState(null),A=t.marketplace,j=jn(t);r.useEffect(()=>{if(O(null),!n||!A)return;let c=!0;return jt(n,{quiet:!0}).then(b=>{if(!c)return;const R=b.find(U=>U.marketplace===A&&U.name===j);O((R==null?void 0:R.version)??null)}),()=>{c=!1}},[n,A,j]);const D=r.useCallback(async()=>{const c=++P.current;try{const{manifest:b}=await yt(t.path),[R,U,ee]=await Promise.all([wt(t.path),kt(t.path,b),yn(t.path,b)]),te=R?await Ct(R):[],[B,ne]=await Promise.all([Te(U.agentFiles),Te(U.commandFiles)]),d=await Promise.all([...new Set([...gn.map(v=>`${t.path}/${v}`),...U.sourcePaths])].map(async v=>await window.api.config.exists(v)?v:null));if(c!==P.current)return;const T=(v,V)=>({kind:v,id:V.id,name:v==="command"?`/${V.name??V.id}`:V.name??V.id,description:V.description});m([...ne.map(v=>T("command",v)),...te.map(v=>({kind:"skill",id:v.id,name:v.name??v.id,description:v.description,skill:v})),...B.map(v=>T("agent",v)),...ee.map(v=>({kind:"hook",...v})),...U.mcpServers.map(v=>({kind:"mcp",id:v.id,name:v.name,description:v.description}))]),f(te);const I=d.filter(v=>v!==null);S(v=>v.join("\0")===I.join("\0")?v:I)}catch(b){if(c!==P.current)return;H.error(`Failed to load plugin contents: ${b instanceof Error?b.message:String(b)}`)}finally{c===P.current&&h(!1)}},[t.path]);r.useEffect(()=>(h(!0),D(),()=>{P.current+=1}),[D]);const L=r.useRef(null),_=r.useRef(!1),M=r.useRef(!1),N=r.useCallback(async()=>{if(_.current){M.current=!0;return}_.current=!0;try{do M.current=!1,await D();while(M.current)}finally{_.current=!1}},[D]),F=r.useCallback(()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{L.current=null,N()},pn)},[N]);if(r.useEffect(()=>()=>{L.current&&clearTimeout(L.current)},[]),ae(w,F,{depth:0}),x)return e.jsx(un,{pluginName:((Z=t.manifest)==null?void 0:Z.name)??t.name,skills:g,initialSelectedId:x.id,onBack:()=>u(null)},x.id);const q=t.enabled===!0,$=((p=t.manifest)==null?void 0:p.version)??null,G=vn($,E),J=(W=t.manifest)==null?void 0:W.description,k=c=>a.filter(b=>b.kind===c).length,X=[["command","COMMAND","COMMANDS"],["skill","SKILL","SKILLS"],["agent","AGENT","AGENTS"],["hook","HOOK","HOOKS"],["mcp","MCP SERVER","MCP SERVERS"]].filter(([c])=>k(c)>0).map(([c,b,R])=>xn(k(c),b,R)).join(" · "),z=k("skill")+k("command")>0;return e.jsxs("div",{"data-testid":"plugin-detail",className:"flex flex-col min-h-0",children:[e.jsx(Ke,{eyebrow:hn(t),title:t.name,actions:e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 text-[13.5px] text-fg-dim",children:[e.jsx(qe,{name:t.name,enabled:q,disabled:!t.key||s,onToggle:()=>l(t),testId:"plugin-detail-switch"}),"Enabled"]}),G&&e.jsx("span",{"data-testid":"plugin-update-state","data-state":G,title:`Installed v${$} · ${t.marketplace} lists v${E}`,className:`h-7 inline-flex items-center px-3 bg-bg border rounded-md text-[13px] font-semibold ${G==="update-available"?"border-accent text-accent":"border-line text-fg-dim"}`,children:G==="update-available"?"Update available":"Up to date"}),e.jsx(fn,{row:t,busy:s,onUninstall:o})]})}),e.jsxs("div",{className:"px-9 py-6 flex flex-col gap-4 max-w-[1100px]",children:[e.jsx(pe,{label:"DESCRIPTION",labelNote:"FROM THE PLUGIN'S MANIFEST",children:e.jsx("span",{"data-testid":"plugin-description",className:J?void 0:"text-fg-faint",children:J??(t.hasManifest?"The manifest has no description.":"This plugin has no manifest.")})}),e.jsx(pe,{label:"WHAT IT ADDS",labelNote:y?void 0:X||"NOTHING",action:z?e.jsx("button",{type:"button","data-testid":"plugin-open-in-skills",onClick:()=>i("skills"),className:"shrink-0 text-[13px] font-semibold text-accent hover:underline",children:"Open in Skills →"}):void 0,children:y?e.jsx(Y,{title:"scanning…"}):a.length===0?e.jsx("span",{className:"text-fg-faint",children:t.error?`Inspection failed: ${t.error}`:"No commands, skills, agents or hooks."}):e.jsx("ul",{"data-testid":"plugin-adds",className:"-mx-[18px] mt-2 border-t border-line",children:a.map(c=>{const b=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-[200px] shrink-0 truncate font-mono text-[14px] font-semibold text-fg",title:c.name,children:c.name}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-[13.5px] text-fg-dim",title:c.description??void 0,children:c.description??""})]}),R="w-full flex items-baseline gap-4 px-[18px] py-3 text-left";return e.jsx("li",{"data-testid":`plugin-adds-${c.kind}`,className:"border-b border-line last:border-b-0",children:c.skill?e.jsx("button",{type:"button",onClick:()=>u(c.skill),className:`${R} hover:bg-bg-elev`,children:b}):e.jsx("div",{className:R,children:b})},`${c.kind}:${c.id}`)})})}),e.jsx(pe,{label:"INSTALLED AT",action:e.jsx("button",{type:"button","data-testid":"plugin-reveal",onClick:()=>Ne(t.path),className:"shrink-0 text-[13px] text-fg-dim hover:text-fg",children:"Reveal"}),children:e.jsx("span",{"data-testid":"plugin-install-path",title:t.path,className:"block truncate font-mono text-[14px]",children:Jt(t.path,n)})}),e.jsx(Nt,{text:mn})]})]})}const kn="~/.claude/plugins/installed_plugins.json",Cn="On/off is saved in settings.json › enabledPlugins",Nn=t=>ye.getState().openPanel("extensions",t);function Sn(t,n){var s,l;return[t.name,(s=t.manifest)==null?void 0:s.name,t.marketplace,(l=t.manifest)==null?void 0:l.description].some(o=>typeof o=="string"&&o.toLowerCase().includes(n))}const ie=(t,n,s)=>`${t} ${t===1?n:s}`;function En(t){const n=$t(t),s=[];if(t.marketplace&&s.push(t.marketplace),t.error)s.push("inspection failed");else{const l=[n.commands>0?ie(n.commands,"command","commands"):null,n.skills>0?ie(n.skills,"skill","skills"):null,n.agents>0?ie(n.agents,"agent","agents"):null,n.hooks>0?ie(n.hooks,"hook","hooks"):null,n.mcpServers>0?ie(n.mcpServers,"MCP server","MCP servers"):null].filter(o=>o!==null);s.push(...l.length>0?l:["empty"])}return t.scope&&t.scope!=="user"&&s.push(`${t.scope} scope`),s.join(" · ")}function $n({onAdd:t,onJump:n}){const s=oe(),[l,o]=r.useState([]),[i,a]=r.useState(!0),[m,g]=r.useState(null),[f,x]=r.useState(null),[u,y]=r.useState(""),[h,w]=r.useState(null),[S,P]=r.useState(new Set),E=ot(c=>c.show),[O,A]=r.useState(null);r.useEffect(()=>{var b,R;let c=!1;return(R=(b=window.api.app).seedStatus)==null||R.call(b).then(U=>{c||w(U)}).catch(()=>{}),()=>{c=!0}},[]);const j=r.useRef(0),D=r.useRef(!1),L=r.useCallback(async()=>{var ee,te;const c=++j.current;if(!s)return;D.current||a(!0);const b=`${s}/.claude/plugins/installed_plugins.json`;let R=[],U=null;try{const B=await window.api.config.readJson(b);if(B.exists&&B.parseError)U=`could not parse installed_plugins.json${B.error?`: ${B.error}`:""}`;else if(B.exists&&B.data&&typeof B.data=="object"){const ne=B.data,d=[];for(const[I,v]of Object.entries(ne.plugins??{})){if(!Array.isArray(v))continue;const[V,fe]=I.split("@");for(const K of v)K!=null&&K.installPath&&d.push({name:V,marketplace:fe,entry:K})}let T=new Map;try{const I=await((te=(ee=window.api.plugins)==null?void 0:ee.list)==null?void 0:te.call(ee))??[];T=new Map(I.map(v=>[v.key,v.enabled]))}catch{}R=await Tn(d,Pn,async({name:I,marketplace:v,entry:V})=>{var Me;const fe={name:I,path:V.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let K;try{K=await St(fe)}catch(xe){K=Et(fe,xe instanceof Error?xe.message:String(xe))}return(Me=K.manifest)!=null&&Me.version||(K.manifest={...K.manifest??{},version:V.version}),K.marketplace=v,K.scope=V.scope,K.key=v?`${I}@${v}`:I,K.enabled=T.get(K.key)===!0,K})}}catch(B){U=`could not read installed_plugins.json: ${B instanceof Error?B.message:String(B)}`}j.current===c&&(g(U),U?H.error(`Plugins: ${U}`):(R.sort((B,ne)=>B.name.localeCompare(ne.name)),D.current=R.length>0,o(R)),a(!1))},[s]);r.useEffect(()=>{L()},[L]);const _=le(c=>c.tab),M=le(c=>c.id),N=le(c=>c.clear);r.useEffect(()=>{if(_!=="plugins"||!M||i)return;const c=M.startsWith("plugins:")?M.slice(8):null,b=c?l.find(R=>R.key===c):void 0;b&&(y(""),x(b.path)),N()},[_,M,i,l,N]),r.useEffect(()=>()=>{j.current+=1},[]),ae(s?[`${s}/.claude/plugins/installed_plugins.json`]:[],L);const F=async c=>{if(c.key){A(c.key);try{const b=await window.api.plugins.setEnabled({key:c.key,enabled:!c.enabled});b.ok||E("error",`Could not ${c.enabled?"disable":"enable"} ${c.name}: ${b.error??"unknown error"}`)}catch(b){E("error",`Could not update ${c.name}: ${b instanceof Error?b.message:String(b)}`)}finally{A(null),await L()}}},q=async c=>{if(c.marketplace){A(c.key??c.name);try{const b=await window.api.plugins.uninstall({slug:c.name,marketplaceName:c.marketplace});b.ok||E("error",`Uninstall ${c.name} failed: ${b.error??`exit ${b.exitCode}`}`)}catch(b){E("error",`Uninstall ${c.name} failed: ${b instanceof Error?b.message:String(b)}`)}finally{A(null),await L()}}},$=r.useMemo(()=>h?Object.keys(h).filter(c=>(h[c].status==="exhausted"||h[c].status==="failed")&&!S.has(c)):[],[h,S]),G=r.useMemo(()=>l.filter(c=>c.enabled===!0).length,[l]),J=u.trim().toLowerCase(),k=r.useMemo(()=>J?l.filter(c=>Sn(c,J)):l,[l,J]),C=k.find(c=>c.path===f)??k[0]??null,X=r.useCallback(()=>t==null?void 0:t(),[t]),z=n??Nn,Z=c=>O!==null&&O===(c.key??c.name),p=e.jsxs(e.Fragment,{children:[e.jsx(Je,{eyebrow:"PLUGINS",badge:`${G} on`,path:kn,note:Cn}),e.jsx(ze,{filter:u,onFilterChange:y,placeholder:"Filter",primaryLabel:"+ Add",onPrimary:X}),i&&l.length===0||m&&l.length===0?null:l.length===0?e.jsxs("div",{"data-testid":"plugins-empty",className:"flex flex-col gap-1 px-3 py-3 border border-dashed border-rule rounded-xl text-[13px] text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg",children:"No plugins installed"}),e.jsxs("span",{children:["Use + Add, or run ",e.jsx("code",{className:"font-mono text-xs",children:"claude plugin install"}),"."]})]}):k.length===0?e.jsxs("p",{className:"px-1 text-[13px] text-fg-dim",children:["No plugins match “",u.trim(),"”."]}):e.jsx("div",{role:"listbox","aria-label":"Installed plugins",className:"flex flex-col gap-1",children:k.map(c=>e.jsx(ke,{title:c.name,meta:En(c),muted:c.enabled!==!0,selected:(C==null?void 0:C.path)===c.path,onSelect:()=>x(c.path),trailing:e.jsx(qe,{name:c.name,enabled:c.enabled===!0,disabled:!c.key||Z(c),onToggle:()=>void F(c)})},c.path))})]}),W=C?e.jsx(wn,{row:C,home:s,busy:Z(C),onToggle:c=>void F(c),onUninstall:c=>void q(c),onJump:z},C.path):i?e.jsx(Y,{title:"scanning plugins…"}):m?null:l.length===0?e.jsx(Y,{title:"No plugins installed",hint:"+ Add browses the plugin catalog."}):e.jsx(Y,{title:"No plugin matches the filter"});return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[$.length>0?e.jsx(Mn,{seeders:$,seedStatus:h,onDismiss:c=>P(b=>new Set(b).add(c)),onOpenLibrary:X}):null,m?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:[m,l.length>0?" — showing the last known list":null]}):null,e.jsx(Ce,{list:p,detail:W})]})}const Ln=r.memo($n),he={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Mn({seeders:t,seedStatus:n,onDismiss:s,onOpenLibrary:l}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(o=>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:n[o].status==="failed"?`${he[o]} setup failed — it will retry on next launch. To fix it now:`:`${he[o]} setup failed after retrying — manual fix needed`}),o==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:l,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[o].fix})]}),e.jsx("button",{onClick:()=>s(o),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${he[o]} warning`,children:"✕"})]},o))})}const Pn=4;async function Tn(t,n,s){const l=new Array(t.length);let o=0;const i=Array.from({length:Math.min(n,t.length)},async()=>{for(;o<t.length;){const a=o++;l[a]=await s(t[a])}});return await Promise.all(i),l}function Ye(t,n){const s=oe();ae([s?`${s}/.claude/agents`:null,...t.map(l=>`${l}/.claude/agents`)],n)}function An({onOpenPersona:t}){const[n,s]=r.useState(se[0].tag),{personas:l,refresh:o}=Se(a=>H.error(a.message||"failed to load agent personas"));Ye([],()=>{o()});const i=se.find(a=>a.tag===n)??null;return e.jsx(Yt,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[se.length," tag",se.length===1?"":"s"]}),children:e.jsx(Ve,{sidebar:e.jsx("div",{className:"py-1",children:se.map(a=>{const m=Ee(a.tag),g=n===a.tag,f=(l==null?void 0:l.filter(x=>x.tags.includes(a.tag)).length)??0;return e.jsxs("button",{onClick:()=>{s(a.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${g?"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 ${m.bg} ${m.text} ${m.border?"border border-current/30":""}`,children:["#",a.tag]}),e.jsx("span",{className:"truncate",children:a.label}),f>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:f})]},a.tag)})}),detail:i?e.jsx(Rn,{entry:i,personas:l,onOpenPersona:t}):e.jsx(Y,{title:"select a tag"})})})}const Dn=r.memo(An);function Rn({entry:t,personas:n,onOpenPersona:s}){const l=Ee(t.tag),o=it(t.tag),i=(n==null?void 0:n.filter(a=>a.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 ${l.bg} ${l.text} ${l.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"}),n===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:[i.map(a=>e.jsx("button",{onClick:()=>s==null?void 0:s(a.name),title:`Open ${a.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:a.name},a.name)),i.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:o.initialPromptTemplate})]})]})}const In=t=>{const[n,s]=t.split(".");return Number(n)+(s?Number(s)/100:0)};function On(t){const n=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!n)return[];const s=[];for(const l of n[1].split(/,\s*|\s+and\s+/)){const o=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(l.trim());o&&s.push({family:o[1].toLowerCase(),version:In(o[2])})}return s}var Fe,_e;const Fn=On(String(((_e=(Fe=Lt.properties)==null?void 0:Fe.effortLevel)==null?void 0:_e.description)??""));function _n(t,n){const s=new RegExp(`${n}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(s)return Number(s[1])+(s[2]?Number(s[2])/100:0);const l=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${n}`,"i").exec(t);return l?Number(l[1])+(l[2]?Number(l[2])/100:0):null}function Xe(t,n=Fn){if(!t||t==="inherit"||n.length===0)return null;const s=Q(t);if(!s)return null;const l=n.filter(i=>i.family===s);if(l.length===0)return!1;const o=_n(t,s);return o===null?null:o>=Math.min(...l.map(i=>i.version))}const be=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Bn=["","red","orange","yellow","green","cyan","blue","purple","pink"],De={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function ve(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,agentCli:t.agentCli??"claude",agentCliModel:t.agentCliModel??""}}const Re={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:"",agentCli:"claude",agentCliModel:""};function $e(t){return[...t.fields.filter(n=>n!=="name"),...t.bodyOverridden?["full body"]:[]]}function Un(t){var s,l;const n=[(s=t.values)==null?void 0:s.model,(l=t.values)==null?void 0:l.effort].filter(o=>!!o);return t.bodyOverridden&&n.push("full body"),n.length?n.join(" · "):$e(t).join(", ")||"overlay"}function Hn({items:t}){const[n,s]=r.useState(!1),l=r.useRef(null),o=r.useRef(null),i=r.useId();return r.useEffect(()=>{if(!n)return;const a=g=>{var x,u;const f=g.target;(x=l.current)!=null&&x.contains(f)||(u=o.current)!=null&&u.contains(f)||s(!1)},m=g=>{g.key==="Escape"&&s(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",m)}},[n]),e.jsxs("div",{className:"relative",children:[e.jsx("button",{ref:l,type:"button","data-testid":"agent-detail-more","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?i:void 0,onClick:()=>s(a=>!a),className:"h-9 w-9 inline-flex items-center justify-center rounded-[10px] bg-bg-hi border border-line text-fg-dim hover:text-fg hover:border-rule",children:"⋯"}),n&&e.jsx("div",{ref:o,id:i,role:"menu","aria-label":"More actions","data-testid":"agent-detail-more-menu",className:`absolute ${Be.dialog} right-0 top-[42px] min-w-[200px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[13px] text-fg`,children:t.map(a=>a.info?e.jsx("div",{role:"note","data-testid":a.testId,className:"px-2.5 pb-[7px] pt-0.5 text-[11px] text-fg-faint whitespace-nowrap border-b border-line mb-1",children:a.label},a.testId):e.jsx("button",{type:"button",role:"menuitem","data-testid":a.testId,disabled:a.disabled,onClick:()=>{s(!1),a.onSelect()},className:`px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev disabled:opacity-40 ${a.danger?"text-red-400":""}`,children:a.label},a.testId))})]})}function re({children:t}){return e.jsx("span",{className:"shrink-0 w-[150px] text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint pt-1",children:t})}function Gn({obj:t,set:n,saved:s,dirty:l,isNew:o,busy:i,confirmDelete:a,setConfirmDelete:m,onDuplicate:g,onRevert:f,onSave:x,onDelete:u,onDropOverride:y,projects:h,selected:w,onSelect:S,onSaveOverride:P}){const E=oe(),{catalog:O,loading:A,degraded:j,refresh:D}=ue(null),{checking:L,recheck:_}=Ue(),[M,N]=r.useState(!1),F=!o&&s?s.path:`${E??"~"}/.claude/agents/${t.name}.md`,q=l||o,$=s&&!o?s.overrideDetails??[]:[],G=!o&&!!s&&(M||w!==null),J=t.tools.length===0,k=O?`Models live-read from claude${O.claudeVersion?` ${O.claudeVersion}`:""}${j?" (cached — CLI probe unavailable)":""}`:A?"Loading model catalog…":"Model catalog unavailable — showing the standard list",C=[{label:A||L?"Re-checking…":"Re-check models & CLIs",testId:"agent-detail-recheck",disabled:A||L,onSelect:()=>{D(),_()}},{label:k,testId:"agent-detail-catalog-info",disabled:!0,info:!0,onSelect:()=>{}},{label:"Reveal in File Explorer",testId:"agent-detail-reveal",disabled:o,onSelect:()=>Ne(F)},...o?[]:[{label:"Delete agent…",testId:"agent-detail-delete",danger:!0,disabled:i,onSelect:()=>m(!0)}]],X=p=>{if(J){n({tools:be.filter(W=>W!==p)});return}n({tools:t.tools.includes(p)?t.tools.filter(W=>W!==p):[...t.tools,p]})},z=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:g,disabled:i,className:"h-9 px-4 rounded-[10px] bg-bg-hi border border-line text-[13.5px] font-medium text-fg hover:border-rule disabled:opacity-40",children:"Duplicate"}),e.jsx(Hn,{items:C})]}),Z=$.length===0?o?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere.":$.length===1?`a local copy in ${me($[0].cwd,E)}/.claude/agents/ wins there`:"each project's local copy in its .claude/agents/ wins there";return e.jsxs("div",{"data-testid":"agent-detail",className:"flex-1 shrink-0 min-h-full flex flex-col",children:[e.jsx(Ke,{eyebrow:`AGENT · USER · ${me(F,E)}`,title:t.name,pill:o?"unsaved draft":l?"edited":void 0,actions:z}),a&&e.jsxs("div",{"data-testid":"agent-detail-delete-confirm",role:"alert",className:"shrink-0 mx-9 mt-4 px-4 py-2.5 rounded-[10px] border border-red-400/40 bg-red-400/10 flex items-center gap-3 text-[13px] text-fg",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx("button",{type:"button",onClick:u,disabled:i,className:"font-semibold text-red-400 hover:text-red-300",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>m(!1),className:"text-fg-faint hover:text-fg",children:"Keep"})]}),e.jsxs("div",{"data-testid":"agent-detail-body",className:"flex-1 shrink-0 flex flex-col gap-4 px-9 py-6",children:[e.jsx(pe,{label:"DESCRIPTION",labelNote:"CLAUDE READS THIS TO PICK THE AGENT",children:e.jsx("textarea",{"data-testid":"agent-detail-description","aria-label":"Description",rows:2,value:t.description,onKeyDown:p=>{p.key==="Enter"&&p.preventDefault()},onChange:p=>n({description:p.target.value.replace(/\r?\n/g," ")}),placeholder:"What this agent does — Claude reads it to decide when to use it",className:"w-full resize-none bg-transparent outline-none text-fg placeholder:text-fg-faint"})}),e.jsxs("section",{"data-testid":"agent-runtime-card",className:"px-[18px] py-4 rounded-[14px] bg-bg-hi border border-line flex flex-col gap-4",children:[e.jsxs("div",{"data-testid":"agent-runtime-row",className:"grid grid-cols-3 gap-4",children:[e.jsx(Vn,{value:t.model,onChange:p=>n({model:p})}),e.jsx(Kn,{value:t.effort,model:t.model,onChange:p=>n({effort:p})}),e.jsxs("div",{className:"min-w-0 flex flex-col gap-1.5",children:[e.jsx(zn,{value:t.agentCli,onChange:p=>n({agentCli:p,agentCliModel:""})}),t.agentCli!=="claude"&&e.jsx("input",{"data-testid":"agent-persona-cli-model","aria-label":"CLI model",value:t.agentCliModel,maxLength:128,placeholder:"Blank = the CLI's own default",onChange:p=>n({agentCliModel:p.target.value}),className:"w-full bg-bg border border-line rounded-md px-2 py-1 text-xs text-fg font-mono"})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"agent-tools-row",children:[e.jsx(re,{children:"tools"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:be.map(p=>{const W=J||t.tools.includes(p);return e.jsx("button",{type:"button","aria-pressed":W,"data-tool":p,onClick:()=>X(p),className:`px-2 py-0.5 rounded-md text-[12px] font-mono border ${W?"bg-honey/20 text-honey-dark border-honey/40":"bg-transparent text-fg-faint border-dashed border-rule"}`,children:p},p)})}),e.jsx("div",{"data-testid":"agent-tools-note",className:"text-[11px] text-fg-faint mt-1 leading-snug",children:J?"All tools — no tools: line, so every tool (MCP included) is granted. Click one to restrict.":e.jsxs(e.Fragment,{children:[t.tools.length," of ",be.length," granted. Anything not filled is refused at call time."," ",e.jsx("button",{type:"button","data-testid":"agent-tools-all",onClick:()=>n({tools:[]}),className:"underline text-fg-dim hover:text-fg",children:"Grant all tools"})]})})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"agent-overrides-row",children:[e.jsx(re,{children:"project overrides"}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2 pt-0.5",children:[$.map(p=>e.jsxs("span",{"data-testid":"agent-override-chip",title:`${me(p.cwd,E)}/.claude/agents/${s.name}.md`,className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded-md px-2 py-0.5 text-[12px] font-mono text-fg-dim",children:[e.jsx("strong",{className:"font-sans font-semibold text-fg",children:p.project}),Un(p),e.jsx("button",{onClick:()=>y(p.cwd,p.project),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},p.cwd)),e.jsx("span",{className:`text-[12px] text-fg-faint ${$.length===0?"italic":""}`,children:Z}),!o&&s&&!G&&e.jsx("button",{type:"button","data-testid":"agent-override-add",onClick:()=>N(!0),className:"text-[12px] font-medium text-accent hover:underline",children:"+ Add override"})]})]}),G&&s&&e.jsx(Xn,{saved:s,projects:h,selected:w,onSelect:S,busy:i,onSave:P,onClose:()=>{N(!1),S(null)}}),e.jsxs("details",{"data-testid":"agent-details",open:o||void 0,className:"group border-t border-line pt-3",children:[e.jsxs("summary",{className:"cursor-pointer select-none flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint",children:[e.jsx("span",{children:"details"}),e.jsxs("span",{className:"normal-case tracking-normal font-normal font-mono text-fg-dim flex items-center gap-1.5",children:[t.color&&e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{background:De[t.color]}}),t.color||"no colour"," · ",t.tags.length?t.tags.map(p=>`#${p}`).join(" "):"no tags"]})]}),e.jsxs("div",{className:"flex flex-col gap-3 pt-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"name"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("input",{"data-testid":"agent-detail-name","aria-label":"Name",value:t.name,onChange:p=>n({name:p.target.value.toLowerCase()}),className:"w-full max-w-sm bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:"Filename on disk — lowercase, hyphenated."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"color"}),e.jsx("div",{className:"flex gap-1.5 pt-0.5",children:Bn.map(p=>e.jsx("button",{type:"button",title:p||"none",onClick:()=>n({color:p}),className:"w-5 h-5 rounded",style:{background:p?De[p]:"transparent",border:t.color===p?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},p||"none"))})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"tags"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:se.map(p=>{const W=t.tags.includes(p.tag),c=Ee(p.tag);return e.jsxs("button",{type:"button",onClick:()=>n({tags:W?t.tags.filter(b=>b!==p.tag):[...t.tags,p.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${W?`${c.bg} ${c.text} ${c.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",p.tag]},p.tag)})}),e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab."})]})]})]})]})]}),e.jsx("div",{"data-testid":"agent-detail-editor","data-busy":i?"true":void 0,className:"flex-1 shrink-0 min-h-[320px] grid rounded-[14px] border border-line bg-bg-hi overflow-hidden",children:e.jsx(Mt,{path:F,value:t.body,defaultMode:"document",dirty:q,isNew:o,onChange:p=>n({body:p}),onSave:()=>{i||x()},onRevert:f})})]})]})}const Wn="w-full h-9 appearance-none pl-3 pr-8 rounded border border-line bg-bg-hi font-mono text-[13px] text-fg focus:outline-none focus:border-fg-faint disabled:opacity-60";function Le({label:t,hint:n,testId:s,value:l,onChange:o,children:i}){return e.jsxs("label",{className:"min-w-0 flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint",children:t}),e.jsxs("span",{className:"relative block",children:[e.jsx("select",{"data-testid":s,"aria-label":t,title:n,value:l,onChange:a=>o(a.target.value),className:Wn,children:i}),e.jsx("svg",{"aria-hidden":!0,"data-testid":`${s}-chevron`,viewBox:"0 0 16 16",className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-faint",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]})]})}const Ie=t=>{var n;return((n=/\[[^\]]*\]$/.exec(t))==null?void 0:n[0])??""};function Vn({value:t,onChange:n}){const{catalog:s}=ue(null),l=s?["inherit",...s.aliases]:[...He],o=(s==null?void 0:s.availableModels)??null,i=[];if(s){const u=new Set,y=h=>{!u.has(h)&&!l.includes(h)&&(u.add(h),i.push(h))};for(const h of s.models)y(h);for(const h of s.aliases){const w=Q(h),S=Ie(h);if(w&&S)for(const P of s.models)Q(P)===w&&y(P+S)}}const a=u=>!!o&&u!=="inherit"&&!o.includes(u),m=u=>{const y=Q(u);return!!o&&!o.includes(u)&&!(y&&o.includes(y+Ie(u)))&&!(y&&o.includes(y))},g=t||"inherit",f=l.includes(g)||i.includes(g);return e.jsxs(Le,{label:"model",hint:"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. Pinned versions fix a concrete id; an alias floats to the latest.",testId:"model-select",value:g,onChange:n,children:[!f&&e.jsxs("option",{value:g,children:[g," (current)"]}),e.jsx("optgroup",{label:"Aliases",children:l.map(u=>e.jsx("option",{value:u,disabled:!!s&&a(u),title:a(u)?ge:void 0,children:u},u))}),i.length>0&&e.jsx("optgroup",{label:"Pinned versions",children:i.map(u=>e.jsx("option",{value:u,disabled:m(u),title:m(u)?ge:void 0,children:u},u))})]})}function Kn({value:t,model:n,onChange:s}){const{catalog:l}=ue(null),o=l&&l.effortLevels.length?["inherit",...l.effortLevels]:[...Ge],i=(l==null?void 0:l.settingsEffortLevels)??[],a=l?o.filter(x=>x!=="inherit"&&!i.includes(x)):[],m=t||"inherit",g=m!=="inherit"&&Xe(n)===!1,f=l?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${a.length?`${a.join(", ")} ${a.length>1?"are":"is"} session-only — settings.json accepts ${i.join(", ")}. `:""}'inherit' writes no effort: line.`:"Catalog unavailable — showing the standard list. 'inherit' writes no effort: line.";return e.jsxs("div",{className:"min-w-0 flex flex-col gap-1",children:[e.jsxs(Le,{label:"effort",hint:f,testId:"effort-select",value:m,onChange:s,children:[!o.includes(m)&&e.jsxs("option",{value:m,children:[m," (current)"]}),o.map(x=>e.jsx("option",{value:x,children:a.includes(x)?`${x} (session-only)`:x},x))]}),g&&e.jsx("div",{className:"text-[11px] text-amber-400 leading-snug","data-testid":"effort-unsupported-note",children:"This model ignores effort."})]})}const Jn=["codex","gemini","antigravity","cursor","opencode"];function zn({value:t,onChange:n}){const{rows:s}=Ue(),l=new Map((s??[]).map(i=>[i.id,i]));return e.jsxs(Le,{label:"runs on",hint:"Which coding-agent CLI New Session starts this persona on — override per session in New Session → advanced. On a non-Claude CLI the session has no develop loop, no Restore, and this persona's model/effort are not used. Macros, phone launches and scheduled PRDs always run Claude Code.",testId:"agent-persona-cli-select",value:t,onChange:i=>n(i),children:[e.jsx("option",{value:"claude",children:"Claude Code"}),Jn.map(i=>{const a=l.get(i),m=(a==null?void 0:a.label)||rt[i],g=!!(a!=null&&a.installed),f=a?g?"":" (not installed)":s===null?" (checking…)":" (not detected)",x=a?g?[a.version,a.path].filter(Boolean).join(" · ")||void 0:a.install??"Not installed":void 0;return e.jsxs("option",{value:i,disabled:!g&&t!==i,title:x,children:[m,f]},i)})]})}function Ze({label:t,hint:n,children:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint mb-1.5",children:t}),s,n&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:n})]})}const je="latest",ge="Blocked by the availableModels allowlist in your Claude settings";function qn({value:t,onChange:n,label:s="model",hint:l,testIdPrefix:o="",inheritLabel:i}){var F,q;const{catalog:a,loading:m,degraded:g,refresh:f}=ue(null),x=a?["inherit",...a.aliases]:[...He],u=(a==null?void 0:a.availableModels)??null,y=$=>!!u&&$!=="inherit"&&!u.includes($),h=($,G)=>!!u&&!u.includes($)&&!(G&&u.includes(G)),w=t||"inherit",S=((F=/\[[^\]]*\]$/.exec(w))==null?void 0:F[0])??"",P=x.includes(w),E=!P&&a&&Q(w)&&x.includes(Q(w)+S)?Q(w)+S:null,O=P?w:E??w,A=Q(O),j=((q=/\[[^\]]*\]$/.exec(O))==null?void 0:q[0])??"",D=!!a&&w!=="inherit"&&!!A&&x.includes(O),L=D?a.models.filter($=>Q($)===A).map($=>$+j):[],_=P?je:w,M={};if(a)for(const $ of x)y($)&&(M[$]=ge);const N={};for(const $ of L)h($,A)&&(N[$]=ge);return e.jsxs(Ze,{label:s,hint:l??"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":`${o}model-row`,children:e.jsx(we,{options:x,value:O,onChange:n,mono:!0,blocked:M,labels:i?{inherit:i}:void 0})}),D&&e.jsxs("div",{className:"mt-2","data-testid":`${o}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(we,{options:[je,...L],value:_,onChange:$=>n($===je?O:$),mono:!0,blocked:N})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:a?`Models are live-read from the installed claude CLI${g?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:m?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${o}model-catalog-refresh`,onClick:()=>{f()},disabled:m,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function Yn({value:t,model:n,onChange:s,label:l="effort",testIdPrefix:o="",inheritLabel:i}){const{catalog:a}=ue(null),m=a&&a.effortLevels.length?["inherit",...a.effortLevels]:[...Ge],g=(a==null?void 0:a.settingsEffortLevels)??[],f=a?m.filter(y=>y!=="inherit"&&!g.includes(y)):[],x=t||"inherit",u=x!=="inherit"&&Xe(n)===!1;return e.jsxs(Ze,{label:l,hint:a?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${f.length?`${f.join(", ")} ${f.length>1?"are":"is"} session-only — settings.json accepts ${g.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${o}effort-row`,children:e.jsx(we,{options:m,value:x,onChange:s,mono:!0,labels:i?{inherit:i}:void 0})}),f.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${o}effort-session-only`,children:f.map(y=>`${y} (session-only)`).join(" · ")}),u&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${o}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Xn({saved:t,projects:n,selected:s,onSelect:l,busy:o,onSave:i,onClose:a}){var E,O,A;const m=oe(),g=r.useId(),f=new Map;for(const j of n)f.set(j.name,(f.get(j.name)??0)+1);const x=j=>{var M;const D=(f.get(j.name)??0)>1?me(j.cwd,m):j.name,L=(M=t.overrideDetails)==null?void 0:M.find(N=>N.cwd===j.cwd);if(!L)return D;const _=$e(L);return`${D} — ${_.length?`overrides ${_.join(", ")}`:"overlay"}`},u=s?(E=t.overrideDetails)==null?void 0:E.find(j=>j.cwd===s.cwd):void 0,y=!!(u!=null&&u.bodyOverridden),h=((O=u==null?void 0:u.values)==null?void 0:O.model)??"inherit",w=((A=u==null?void 0:u.values)==null?void 0:A.effort)??"inherit",S=t.model??"inherit",P=t.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override-block",className:s?"border border-accent/40 rounded p-3 space-y-3 bg-accent/5":"border border-dashed border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:g,className:`flex-1 text-[10.5px] font-semibold uppercase tracking-wide font-mono ${s?"text-accent":"text-fg-faint"}`,children:"project override"}),e.jsx("button",{type:"button","data-testid":"override-close",onClick:a,className:"text-[11px] text-fg-faint hover:text-fg",children:"Done"})]}),e.jsx("div",{className:"flex flex-col gap-1",children:e.jsxs("select",{id:g,"data-testid":"override-project-select",value:(s==null?void 0:s.cwd)??"",onChange:j=>l(j.target.value||null),disabled:o||n.length===0,className:"rounded-md border border-line bg-bg px-2 py-1.5 font-mono text-[12.5px] text-fg disabled:opacity-60",children:[e.jsx("option",{value:"",children:"Choose a project…"}),n.map(j=>e.jsx("option",{value:j.cwd,children:x(j)},j.cwd))]})}),n.length===0?e.jsx("div",{"data-testid":"project-override-none",className:"text-[11px] text-fg-faint leading-snug",children:"No open project tabs — open a project tab to override this persona's model or effort for it."}):s?e.jsxs("div",{"data-testid":"project-override",className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(We,{tone:"accent",children:[s.name," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(zt,{path:`${s.cwd}/.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.name})," 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."]}),y&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s.name,' 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 its × in the "project overrides" row above.']}),e.jsxs("fieldset",{disabled:o||y,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(qn,{value:h,onChange:j=>{y||i({model:j,effort:w})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(Yn,{value:w,model:h!=="inherit"?h:S,onChange:j=>{y||i({model:h,effort:j})},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",S,h],["effort",P,w]].map(([j,D,L])=>e.jsxs("div",{"data-testid":`override-provenance-${j}`,children:[j,": ",L!=="inherit"?e.jsxs(e.Fragment,{children:[D," ",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:[D," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},j))})]}):e.jsx("div",{"data-testid":"project-override-unselected",className:"text-[11px] text-fg-faint leading-snug",children:"Pick an open project to see or set this persona's model and effort for that project only. A project that already overrides this persona says what it overrides."})]})}const Zn=new Set(se.map(t=>t.tag));function Qe(t){return t.filter(n=>Zn.has(n))}function Qn(t,n={}){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:Qe(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...t.agentCli?{agentCli:t.agentCli}:{},...t.agentCliModel?{agentCliModel:t.agentCliModel}:{},...n}}function es(t){const n=new Map;for(const s of t){const l=typeof s.cwd=="string"?dt(s.cwd):"";l&&!n.has(l)&&n.set(l,{cwd:l,name:ut(l)})}return[...n.values()].sort((s,l)=>s.name.localeCompare(l.name)||s.cwd.localeCompare(l.cwd))}function ts(t){return(t.overrideDetails??[]).map(n=>`${n.project}: ${$e(n).join(", ")||"overlay"}`).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-Ba4TkX2C.js","./index-B2TQz3nd.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-DKXdXfka.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bl as oe,aR as r,bg as ae,aC as et,C as tt,aB as e,m as Y,F as nt,P as st,ai as at,a9 as Be,aZ as Ne,ag as lt,ba as H,by as ot,bn as ye,a0 as se,bd as Se,b9 as Ee,aa as it,aG as Q,bo as ue,bc as Ue,ae as me,M as He,E as Ge,A as rt,c as We,e as we,bw as ct,aH as dt,aO as ut,b7 as ft,az as Pe,H as mt,L as pt,r as gt,p as xt}from"./index-B2TQz3nd.js";import{C as ht,I as bt,p as vt,L as Ve,t as jt,z as yt,A as wt,B as kt,u as Ct,y as Te,c as Ke,b as pe,g as Nt,s as St,r as Et,H as le,d as Je,f as ze,e as ke,i as Ce,F as $t,x as Lt,D as Mt,J as Pt,E as Tt,w as At,G as Dt,m as Rt,a as It,h as Ot,S as Ft,j as _t,k as Bt,l as Ut,M as Ht,P as Gt,n as Wt,o as Vt,v as Kt}from"./Skills-C1v91GEO.js";import{s as Jt,S as zt}from"./ViewTabs-DXhOWFG0.js";import{_ as qt}from"./monaco-editor-BsIlgG7c.js";import{P as Yt}from"./Panel-Bf1Cf8UL.js";import"./TiptapBody-BrcWVpiW.js";const Xt={skills:null,mcp:null,plugins:null},Zt={fileId:"claudeJson",scope:"user"};function Qt(t){return{skillsDir:`${t}/.claude/skills`,commandsDir:`${t}/.claude/commands`,claudeJson:`${t}/.claude.json`,pluginsManifest:`${t}/.claude/plugins/installed_plugins.json`}}async function en(t,n){const[s,l]=await Promise.all([et(t),window.api.config.listDir(n,{filesOnly:!0})]),o=s.errors[0];if(o)throw new Error(`${o.path}: ${o.error}`);if(!l.ok)throw new Error(`${n}: ${l.error??"failed to list directory"}`);return s.entries.length+l.entries.filter(i=>i.name.endsWith(".md")).length}async function tn(){const{data:t}=await window.api.claudeConfig.read(Zt),n=t==null?void 0:t.mcpServers;return n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).length:0}async function nn(){return(await window.api.plugins.list()).length}function sn(){const t=oe(),[n,s]=r.useState(Xt),l=r.useRef({skills:0,mcp:0,plugins:0}),o=r.useCallback((f,x)=>{const u=l.current,y=++u[f],h=w=>{u[f]===y&&s(S=>S[f]===w?S:{...S,[f]:w})};x().then(h,()=>h(null))},[]),i=r.useMemo(()=>t?Qt(t):null,[t]),a=r.useCallback(()=>{i&&o("skills",()=>en(i.skillsDir,i.commandsDir))},[i,o]),m=r.useCallback(()=>o("mcp",tn),[o]),g=r.useCallback(()=>o("plugins",nn),[o]);return r.useEffect(()=>{const f=l.current;return a(),()=>{f.skills++}},[a]),r.useEffect(()=>{const f=l.current;return m(),g(),()=>{f.mcp++,f.plugins++}},[m,g]),ae(i?[i.skillsDir,i.commandsDir]:[],a),ae(i?[i.claudeJson]:[],m),ae(i?[i.pluginsManifest]:[],g),n}const an="User · every project on this machine",ln={title:"Nothing tells Claude how you like to work yet.",body:"Claude loads this file into every session it starts on this machine, in every project."};function on(){const t=oe(),n=r.useMemo(()=>t?tt.resolve("user",t,null):null,[t]),s=r.useMemo(()=>n?[{path:n,label:an,eyebrow:"YOUR INSTRUCTIONS FOR EVERY PROJECT"}]:[],[n]);return!t||!n?e.jsx(Y,{title:"loading…"}):e.jsx("div",{className:"flex flex-col h-full min-h-0","data-testid":"system-prompt",children:e.jsx(ht,{home:t,scope:"user",roots:s,activeRoot:n,empty:ln,testIdPrefix:"system-prompt",moreMenu:({importSelected:l})=>e.jsx(bt,{path:n,disabled:l})})})}const rn=r.memo(on);function cn({value:t,onChange:n,path:s,readOnly:l,theme:o="dark"}){const i=o==="paper";return e.jsx(nt,{path:`file://${s}`,defaultLanguage:"markdown",value:t,onChange:a=>n(a??""),beforeMount:i?at:void 0,theme:i?st:"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:l,automaticLayout:!0}})}const dn=r.lazy(()=>qt(()=>import("./SkillReferenceGraph-Ba4TkX2C.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function un({pluginName:t,skills:n,onBack:s,initialSelectedId:l}){var x;const[o,i]=r.useState(l??((x=n[0])==null?void 0:x.id)??null),a=o?n.find(u=>u.id===o)??null:null,m=r.useMemo(()=>vt(n),[n]),[g,f]=r.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:s,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(a==null?void 0:a.name)??(a==null?void 0:a.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 ${g==="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 ${g==="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:[a!=null&&a.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:a.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",m.length," ",m.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(Y,{title:"no skills in this plugin"}):g==="graph"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(dn,{skills:n,edges:m,selectedId:o,onSelect:i})}):e.jsx(Ve,{sidebar:e.jsx("div",{className:"py-1",children:n.map(u=>e.jsxs("button",{onClick:()=>i(u.id),className:`w-full px-3 py-1 text-xs text-left ${o===u.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:u.name??u.id}),u.description?e.jsx("div",{className:"truncate text-fg-faint",children:u.description}):null]},u.id))}),detail:a?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(cn,{path:a.path,value:a.body,onChange:()=>{},readOnly:!0})}):e.jsx(Y,{title:"select a skill"})})})]})}function fn({row:t,busy:n,onUninstall:s}){const[l,o]=r.useState(!1),[i,a]=r.useState(!1),m=r.useRef(null),g=r.useId(),f=r.useCallback(()=>{o(!1),a(!1)},[]);r.useEffect(()=>{if(!l)return;const w=P=>{var E;(E=m.current)!=null&&E.contains(P.target)||f()},S=P=>{P.key==="Escape"&&f()};return window.addEventListener("mousedown",w),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",w),window.removeEventListener("keydown",S)}},[l,f]);const x=()=>{f(),Ne(t.path)},u=async()=>{f(),await lt(t.path)||H.error(`Could not copy ${t.path} to the clipboard`)},y=()=>{f(),s(t)},h="px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev";return e.jsxs("div",{ref:m,className:"relative self-start",children:[e.jsx("button",{type:"button","data-testid":"plugin-menu","aria-label":`Actions for ${t.name}`,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?g:void 0,onClick:()=>l?f():o(!0),className:"w-[30px] h-7 inline-flex items-center justify-center bg-bg border border-line rounded-md text-fg-dim hover:border-rule",children:e.jsxs("svg",{"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}),l&&e.jsx("div",{id:g,role:"menu","aria-label":`Actions for ${t.name}`,className:`absolute ${Be.dialog} right-0 top-[34px] w-[210px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[12.5px] text-fg`,children:i?e.jsxs("div",{className:"flex flex-col gap-2 px-2.5 py-[7px]",children:[e.jsxs("span",{className:"font-medium",children:["Uninstall ",t.name,"?"]}),e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx("button",{type:"button",role:"menuitem","data-testid":"plugin-uninstall",disabled:n,onClick:y,className:"h-6 px-2.5 rounded-[5px] bg-delta-bad text-bg-hi font-medium hover:bg-delta-bad/90 disabled:opacity-40",children:"Confirm"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(!1),className:"h-6 px-2.5 rounded-[5px] border border-line text-fg-dim hover:bg-bg-elev",children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",role:"menuitem",onClick:x,className:h,children:"Reveal in File Explorer"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>void u(),className:h,children:"Copy path"}),e.jsx("div",{role:"separator",className:"h-px mx-1.5 my-1 bg-line"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!t.marketplace||n,title:t.marketplace?void 0:"No marketplace is recorded for this install",onClick:()=>a(!0),className:`${h} font-medium text-delta-bad hover:bg-delta-bad/10 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:["Uninstall ",t.name]})]})})]})}function qe({name:t,enabled:n,disabled:s,onToggle:l,testId:o="plugin-enabled-switch"}){return e.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":`${n?"Disable":"Enable"} ${t}`,"data-testid":o,disabled:s,onClick:i=>{i.stopPropagation(),l()},onKeyDown:i=>i.stopPropagation(),className:`relative shrink-0 w-[30px] h-[18px] rounded-full transition-colors align-middle disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent ${n?"bg-accent":"bg-rule"}`,children:e.jsx("span",{"aria-hidden":"true",className:`absolute top-0.5 w-3.5 h-3.5 rounded-full bg-bg-hi shadow transition-[left] ${n?"left-[14px]":"left-0.5"}`})})}const mn="Saved — matches settings.json › enabledPlugins",pn=250,gn=["hooks/hooks.json",".mcp.json","agents","skills","commands",".claude-plugin/plugin.json"],xn=(t,n,s)=>`${t} ${t===1?n:s}`;function hn(t){var s;const n=["PLUGIN"];return t.marketplace&&n.push(t.marketplace.toUpperCase()),(s=t.manifest)!=null&&s.version&&n.push(`V${t.manifest.version.toUpperCase()}`),n.push(`${(t.scope??"user").toUpperCase()} SCOPE`),n.join(" · ")}function bn(t,n){const s=i=>{const m=i.trim().replace(/^v/i,"").split(/[-+]/)[0].split(".");return m.every(g=>/^\d+$/.test(g))?m.map(Number):null},l=s(t),o=s(n);if(!l||!o)return null;for(let i=0;i<Math.max(l.length,o.length);i++){const a=(l[i]??0)-(o[i]??0);if(a!==0)return Math.sign(a)}return 0}function vn(t,n){if(!t||!n)return null;const s=bn(n,t);return s===null?n.trim()===t.trim()?"up-to-date":"update-available":s>0?"update-available":"up-to-date"}const jn=t=>t.key&&t.key.includes("@")?t.key.slice(0,t.key.lastIndexOf("@")):t.name,de=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function Ae(t,n){if(!de(t))return[];const s=de(t.hooks)?t.hooks:t,l=[];for(const[o,i]of Object.entries(s))Array.isArray(i)&&i.forEach((a,m)=>{if(!de(a)||!Array.isArray(a.hooks))return;const g=typeof a.matcher=="string"&&a.matcher?` · ${a.matcher}`:"";a.hooks.forEach((f,x)=>{const u=de(f)?typeof f.command=="string"?f.command:typeof f.prompt=="string"?f.prompt:null:null;l.push({id:`${n}:${o}:${m}:${x}`,name:`${o}${g}`,description:u})})});return l}async function yn(t,n){const s=n==null?void 0:n.hooks,l=typeof s=="string"?[s]:Array.isArray(s)?s.filter(a=>typeof a=="string"):[],o=new Set;for(const a of l)a.startsWith("/")||a.split("/").includes("..")||o.add(`${t}/${a.replace(/^\.\//,"")}`);o.add(`${t}/hooks/hooks.json`);const i=await Promise.all([...o].map(async a=>{const m=await window.api.config.readJson(a);return{p:a,data:m.exists&&!m.parseError?m.data:null}}));return[...de(s)?Ae(s,"manifest"):[],...i.flatMap(({p:a,data:m})=>Ae(m,a))]}function wn({row:t,home:n,busy:s,onToggle:l,onUninstall:o,onJump:i}){var Z,p,W;const[a,m]=r.useState([]),[g,f]=r.useState([]),[x,u]=r.useState(null),[y,h]=r.useState(!0),[w,S]=r.useState([]),P=r.useRef(0),[E,O]=r.useState(null),A=t.marketplace,j=jn(t);r.useEffect(()=>{if(O(null),!n||!A)return;let c=!0;return jt(n,{quiet:!0}).then(b=>{if(!c)return;const R=b.find(U=>U.marketplace===A&&U.name===j);O((R==null?void 0:R.version)??null)}),()=>{c=!1}},[n,A,j]);const D=r.useCallback(async()=>{const c=++P.current;try{const{manifest:b}=await yt(t.path),[R,U,ee]=await Promise.all([wt(t.path),kt(t.path,b),yn(t.path,b)]),te=R?await Ct(R):[],[B,ne]=await Promise.all([Te(U.agentFiles),Te(U.commandFiles)]),d=await Promise.all([...new Set([...gn.map(v=>`${t.path}/${v}`),...U.sourcePaths])].map(async v=>await window.api.config.exists(v)?v:null));if(c!==P.current)return;const T=(v,V)=>({kind:v,id:V.id,name:v==="command"?`/${V.name??V.id}`:V.name??V.id,description:V.description});m([...ne.map(v=>T("command",v)),...te.map(v=>({kind:"skill",id:v.id,name:v.name??v.id,description:v.description,skill:v})),...B.map(v=>T("agent",v)),...ee.map(v=>({kind:"hook",...v})),...U.mcpServers.map(v=>({kind:"mcp",id:v.id,name:v.name,description:v.description}))]),f(te);const I=d.filter(v=>v!==null);S(v=>v.join("\0")===I.join("\0")?v:I)}catch(b){if(c!==P.current)return;H.error(`Failed to load plugin contents: ${b instanceof Error?b.message:String(b)}`)}finally{c===P.current&&h(!1)}},[t.path]);r.useEffect(()=>(h(!0),D(),()=>{P.current+=1}),[D]);const L=r.useRef(null),_=r.useRef(!1),M=r.useRef(!1),N=r.useCallback(async()=>{if(_.current){M.current=!0;return}_.current=!0;try{do M.current=!1,await D();while(M.current)}finally{_.current=!1}},[D]),F=r.useCallback(()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{L.current=null,N()},pn)},[N]);if(r.useEffect(()=>()=>{L.current&&clearTimeout(L.current)},[]),ae(w,F,{depth:0}),x)return e.jsx(un,{pluginName:((Z=t.manifest)==null?void 0:Z.name)??t.name,skills:g,initialSelectedId:x.id,onBack:()=>u(null)},x.id);const q=t.enabled===!0,$=((p=t.manifest)==null?void 0:p.version)??null,G=vn($,E),J=(W=t.manifest)==null?void 0:W.description,k=c=>a.filter(b=>b.kind===c).length,X=[["command","COMMAND","COMMANDS"],["skill","SKILL","SKILLS"],["agent","AGENT","AGENTS"],["hook","HOOK","HOOKS"],["mcp","MCP SERVER","MCP SERVERS"]].filter(([c])=>k(c)>0).map(([c,b,R])=>xn(k(c),b,R)).join(" · "),z=k("skill")+k("command")>0;return e.jsxs("div",{"data-testid":"plugin-detail",className:"flex flex-col min-h-0",children:[e.jsx(Ke,{eyebrow:hn(t),title:t.name,actions:e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 text-[13.5px] text-fg-dim",children:[e.jsx(qe,{name:t.name,enabled:q,disabled:!t.key||s,onToggle:()=>l(t),testId:"plugin-detail-switch"}),"Enabled"]}),G&&e.jsx("span",{"data-testid":"plugin-update-state","data-state":G,title:`Installed v${$} · ${t.marketplace} lists v${E}`,className:`h-7 inline-flex items-center px-3 bg-bg border rounded-md text-[13px] font-semibold ${G==="update-available"?"border-accent text-accent":"border-line text-fg-dim"}`,children:G==="update-available"?"Update available":"Up to date"}),e.jsx(fn,{row:t,busy:s,onUninstall:o})]})}),e.jsxs("div",{className:"px-9 py-6 flex flex-col gap-4 max-w-[1100px]",children:[e.jsx(pe,{label:"DESCRIPTION",labelNote:"FROM THE PLUGIN'S MANIFEST",children:e.jsx("span",{"data-testid":"plugin-description",className:J?void 0:"text-fg-faint",children:J??(t.hasManifest?"The manifest has no description.":"This plugin has no manifest.")})}),e.jsx(pe,{label:"WHAT IT ADDS",labelNote:y?void 0:X||"NOTHING",action:z?e.jsx("button",{type:"button","data-testid":"plugin-open-in-skills",onClick:()=>i("skills"),className:"shrink-0 text-[13px] font-semibold text-accent hover:underline",children:"Open in Skills →"}):void 0,children:y?e.jsx(Y,{title:"scanning…"}):a.length===0?e.jsx("span",{className:"text-fg-faint",children:t.error?`Inspection failed: ${t.error}`:"No commands, skills, agents or hooks."}):e.jsx("ul",{"data-testid":"plugin-adds",className:"-mx-[18px] mt-2 border-t border-line",children:a.map(c=>{const b=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-[200px] shrink-0 truncate font-mono text-[14px] font-semibold text-fg",title:c.name,children:c.name}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-[13.5px] text-fg-dim",title:c.description??void 0,children:c.description??""})]}),R="w-full flex items-baseline gap-4 px-[18px] py-3 text-left";return e.jsx("li",{"data-testid":`plugin-adds-${c.kind}`,className:"border-b border-line last:border-b-0",children:c.skill?e.jsx("button",{type:"button",onClick:()=>u(c.skill),className:`${R} hover:bg-bg-elev`,children:b}):e.jsx("div",{className:R,children:b})},`${c.kind}:${c.id}`)})})}),e.jsx(pe,{label:"INSTALLED AT",action:e.jsx("button",{type:"button","data-testid":"plugin-reveal",onClick:()=>Ne(t.path),className:"shrink-0 text-[13px] text-fg-dim hover:text-fg",children:"Reveal"}),children:e.jsx("span",{"data-testid":"plugin-install-path",title:t.path,className:"block truncate font-mono text-[14px]",children:Jt(t.path,n)})}),e.jsx(Nt,{text:mn})]})]})}const kn="~/.claude/plugins/installed_plugins.json",Cn="On/off is saved in settings.json › enabledPlugins",Nn=t=>ye.getState().openPanel("extensions",t);function Sn(t,n){var s,l;return[t.name,(s=t.manifest)==null?void 0:s.name,t.marketplace,(l=t.manifest)==null?void 0:l.description].some(o=>typeof o=="string"&&o.toLowerCase().includes(n))}const ie=(t,n,s)=>`${t} ${t===1?n:s}`;function En(t){const n=$t(t),s=[];if(t.marketplace&&s.push(t.marketplace),t.error)s.push("inspection failed");else{const l=[n.commands>0?ie(n.commands,"command","commands"):null,n.skills>0?ie(n.skills,"skill","skills"):null,n.agents>0?ie(n.agents,"agent","agents"):null,n.hooks>0?ie(n.hooks,"hook","hooks"):null,n.mcpServers>0?ie(n.mcpServers,"MCP server","MCP servers"):null].filter(o=>o!==null);s.push(...l.length>0?l:["empty"])}return t.scope&&t.scope!=="user"&&s.push(`${t.scope} scope`),s.join(" · ")}function $n({onAdd:t,onJump:n}){const s=oe(),[l,o]=r.useState([]),[i,a]=r.useState(!0),[m,g]=r.useState(null),[f,x]=r.useState(null),[u,y]=r.useState(""),[h,w]=r.useState(null),[S,P]=r.useState(new Set),E=ot(c=>c.show),[O,A]=r.useState(null);r.useEffect(()=>{var b,R;let c=!1;return(R=(b=window.api.app).seedStatus)==null||R.call(b).then(U=>{c||w(U)}).catch(()=>{}),()=>{c=!0}},[]);const j=r.useRef(0),D=r.useRef(!1),L=r.useCallback(async()=>{var ee,te;const c=++j.current;if(!s)return;D.current||a(!0);const b=`${s}/.claude/plugins/installed_plugins.json`;let R=[],U=null;try{const B=await window.api.config.readJson(b);if(B.exists&&B.parseError)U=`could not parse installed_plugins.json${B.error?`: ${B.error}`:""}`;else if(B.exists&&B.data&&typeof B.data=="object"){const ne=B.data,d=[];for(const[I,v]of Object.entries(ne.plugins??{})){if(!Array.isArray(v))continue;const[V,fe]=I.split("@");for(const K of v)K!=null&&K.installPath&&d.push({name:V,marketplace:fe,entry:K})}let T=new Map;try{const I=await((te=(ee=window.api.plugins)==null?void 0:ee.list)==null?void 0:te.call(ee))??[];T=new Map(I.map(v=>[v.key,v.enabled]))}catch{}R=await Tn(d,Pn,async({name:I,marketplace:v,entry:V})=>{var Me;const fe={name:I,path:V.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let K;try{K=await St(fe)}catch(xe){K=Et(fe,xe instanceof Error?xe.message:String(xe))}return(Me=K.manifest)!=null&&Me.version||(K.manifest={...K.manifest??{},version:V.version}),K.marketplace=v,K.scope=V.scope,K.key=v?`${I}@${v}`:I,K.enabled=T.get(K.key)===!0,K})}}catch(B){U=`could not read installed_plugins.json: ${B instanceof Error?B.message:String(B)}`}j.current===c&&(g(U),U?H.error(`Plugins: ${U}`):(R.sort((B,ne)=>B.name.localeCompare(ne.name)),D.current=R.length>0,o(R)),a(!1))},[s]);r.useEffect(()=>{L()},[L]);const _=le(c=>c.tab),M=le(c=>c.id),N=le(c=>c.clear);r.useEffect(()=>{if(_!=="plugins"||!M||i)return;const c=M.startsWith("plugins:")?M.slice(8):null,b=c?l.find(R=>R.key===c):void 0;b&&(y(""),x(b.path)),N()},[_,M,i,l,N]),r.useEffect(()=>()=>{j.current+=1},[]),ae(s?[`${s}/.claude/plugins/installed_plugins.json`]:[],L);const F=async c=>{if(c.key){A(c.key);try{const b=await window.api.plugins.setEnabled({key:c.key,enabled:!c.enabled});b.ok||E("error",`Could not ${c.enabled?"disable":"enable"} ${c.name}: ${b.error??"unknown error"}`)}catch(b){E("error",`Could not update ${c.name}: ${b instanceof Error?b.message:String(b)}`)}finally{A(null),await L()}}},q=async c=>{if(c.marketplace){A(c.key??c.name);try{const b=await window.api.plugins.uninstall({slug:c.name,marketplaceName:c.marketplace});b.ok||E("error",`Uninstall ${c.name} failed: ${b.error??`exit ${b.exitCode}`}`)}catch(b){E("error",`Uninstall ${c.name} failed: ${b instanceof Error?b.message:String(b)}`)}finally{A(null),await L()}}},$=r.useMemo(()=>h?Object.keys(h).filter(c=>(h[c].status==="exhausted"||h[c].status==="failed")&&!S.has(c)):[],[h,S]),G=r.useMemo(()=>l.filter(c=>c.enabled===!0).length,[l]),J=u.trim().toLowerCase(),k=r.useMemo(()=>J?l.filter(c=>Sn(c,J)):l,[l,J]),C=k.find(c=>c.path===f)??k[0]??null,X=r.useCallback(()=>t==null?void 0:t(),[t]),z=n??Nn,Z=c=>O!==null&&O===(c.key??c.name),p=e.jsxs(e.Fragment,{children:[e.jsx(Je,{eyebrow:"PLUGINS",badge:`${G} on`,path:kn,note:Cn}),e.jsx(ze,{filter:u,onFilterChange:y,placeholder:"Filter",primaryLabel:"+ Add",onPrimary:X}),i&&l.length===0||m&&l.length===0?null:l.length===0?e.jsxs("div",{"data-testid":"plugins-empty",className:"flex flex-col gap-1 px-3 py-3 border border-dashed border-rule rounded-xl text-[13px] text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg",children:"No plugins installed"}),e.jsxs("span",{children:["Use + Add, or run ",e.jsx("code",{className:"font-mono text-xs",children:"claude plugin install"}),"."]})]}):k.length===0?e.jsxs("p",{className:"px-1 text-[13px] text-fg-dim",children:["No plugins match “",u.trim(),"”."]}):e.jsx("div",{role:"listbox","aria-label":"Installed plugins",className:"flex flex-col gap-1",children:k.map(c=>e.jsx(ke,{title:c.name,meta:En(c),muted:c.enabled!==!0,selected:(C==null?void 0:C.path)===c.path,onSelect:()=>x(c.path),trailing:e.jsx(qe,{name:c.name,enabled:c.enabled===!0,disabled:!c.key||Z(c),onToggle:()=>void F(c)})},c.path))})]}),W=C?e.jsx(wn,{row:C,home:s,busy:Z(C),onToggle:c=>void F(c),onUninstall:c=>void q(c),onJump:z},C.path):i?e.jsx(Y,{title:"scanning plugins…"}):m?null:l.length===0?e.jsx(Y,{title:"No plugins installed",hint:"+ Add browses the plugin catalog."}):e.jsx(Y,{title:"No plugin matches the filter"});return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[$.length>0?e.jsx(Mn,{seeders:$,seedStatus:h,onDismiss:c=>P(b=>new Set(b).add(c)),onOpenLibrary:X}):null,m?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:[m,l.length>0?" — showing the last known list":null]}):null,e.jsx(Ce,{list:p,detail:W})]})}const Ln=r.memo($n),he={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Mn({seeders:t,seedStatus:n,onDismiss:s,onOpenLibrary:l}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(o=>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:n[o].status==="failed"?`${he[o]} setup failed — it will retry on next launch. To fix it now:`:`${he[o]} setup failed after retrying — manual fix needed`}),o==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:l,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[o].fix})]}),e.jsx("button",{onClick:()=>s(o),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${he[o]} warning`,children:"✕"})]},o))})}const Pn=4;async function Tn(t,n,s){const l=new Array(t.length);let o=0;const i=Array.from({length:Math.min(n,t.length)},async()=>{for(;o<t.length;){const a=o++;l[a]=await s(t[a])}});return await Promise.all(i),l}function Ye(t,n){const s=oe();ae([s?`${s}/.claude/agents`:null,...t.map(l=>`${l}/.claude/agents`)],n)}function An({onOpenPersona:t}){const[n,s]=r.useState(se[0].tag),{personas:l,refresh:o}=Se(a=>H.error(a.message||"failed to load agent personas"));Ye([],()=>{o()});const i=se.find(a=>a.tag===n)??null;return e.jsx(Yt,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[se.length," tag",se.length===1?"":"s"]}),children:e.jsx(Ve,{sidebar:e.jsx("div",{className:"py-1",children:se.map(a=>{const m=Ee(a.tag),g=n===a.tag,f=(l==null?void 0:l.filter(x=>x.tags.includes(a.tag)).length)??0;return e.jsxs("button",{onClick:()=>{s(a.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${g?"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 ${m.bg} ${m.text} ${m.border?"border border-current/30":""}`,children:["#",a.tag]}),e.jsx("span",{className:"truncate",children:a.label}),f>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:f})]},a.tag)})}),detail:i?e.jsx(Rn,{entry:i,personas:l,onOpenPersona:t}):e.jsx(Y,{title:"select a tag"})})})}const Dn=r.memo(An);function Rn({entry:t,personas:n,onOpenPersona:s}){const l=Ee(t.tag),o=it(t.tag),i=(n==null?void 0:n.filter(a=>a.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 ${l.bg} ${l.text} ${l.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"}),n===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:[i.map(a=>e.jsx("button",{onClick:()=>s==null?void 0:s(a.name),title:`Open ${a.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:a.name},a.name)),i.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:o.initialPromptTemplate})]})]})}const In=t=>{const[n,s]=t.split(".");return Number(n)+(s?Number(s)/100:0)};function On(t){const n=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!n)return[];const s=[];for(const l of n[1].split(/,\s*|\s+and\s+/)){const o=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(l.trim());o&&s.push({family:o[1].toLowerCase(),version:In(o[2])})}return s}var Fe,_e;const Fn=On(String(((_e=(Fe=Lt.properties)==null?void 0:Fe.effortLevel)==null?void 0:_e.description)??""));function _n(t,n){const s=new RegExp(`${n}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(s)return Number(s[1])+(s[2]?Number(s[2])/100:0);const l=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${n}`,"i").exec(t);return l?Number(l[1])+(l[2]?Number(l[2])/100:0):null}function Xe(t,n=Fn){if(!t||t==="inherit"||n.length===0)return null;const s=Q(t);if(!s)return null;const l=n.filter(i=>i.family===s);if(l.length===0)return!1;const o=_n(t,s);return o===null?null:o>=Math.min(...l.map(i=>i.version))}const be=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Bn=["","red","orange","yellow","green","cyan","blue","purple","pink"],De={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function ve(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,agentCli:t.agentCli??"claude",agentCliModel:t.agentCliModel??""}}const Re={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:"",agentCli:"claude",agentCliModel:""};function $e(t){return[...t.fields.filter(n=>n!=="name"),...t.bodyOverridden?["full body"]:[]]}function Un(t){var s,l;const n=[(s=t.values)==null?void 0:s.model,(l=t.values)==null?void 0:l.effort].filter(o=>!!o);return t.bodyOverridden&&n.push("full body"),n.length?n.join(" · "):$e(t).join(", ")||"overlay"}function Hn({items:t}){const[n,s]=r.useState(!1),l=r.useRef(null),o=r.useRef(null),i=r.useId();return r.useEffect(()=>{if(!n)return;const a=g=>{var x,u;const f=g.target;(x=l.current)!=null&&x.contains(f)||(u=o.current)!=null&&u.contains(f)||s(!1)},m=g=>{g.key==="Escape"&&s(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",m)}},[n]),e.jsxs("div",{className:"relative",children:[e.jsx("button",{ref:l,type:"button","data-testid":"agent-detail-more","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?i:void 0,onClick:()=>s(a=>!a),className:"h-9 w-9 inline-flex items-center justify-center rounded-[10px] bg-bg-hi border border-line text-fg-dim hover:text-fg hover:border-rule",children:"⋯"}),n&&e.jsx("div",{ref:o,id:i,role:"menu","aria-label":"More actions","data-testid":"agent-detail-more-menu",className:`absolute ${Be.dialog} right-0 top-[42px] min-w-[200px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[13px] text-fg`,children:t.map(a=>a.info?e.jsx("div",{role:"note","data-testid":a.testId,className:"px-2.5 pb-[7px] pt-0.5 text-[11px] text-fg-faint whitespace-nowrap border-b border-line mb-1",children:a.label},a.testId):e.jsx("button",{type:"button",role:"menuitem","data-testid":a.testId,disabled:a.disabled,onClick:()=>{s(!1),a.onSelect()},className:`px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev disabled:opacity-40 ${a.danger?"text-red-400":""}`,children:a.label},a.testId))})]})}function re({children:t}){return e.jsx("span",{className:"shrink-0 w-[150px] text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint pt-1",children:t})}function Gn({obj:t,set:n,saved:s,dirty:l,isNew:o,busy:i,confirmDelete:a,setConfirmDelete:m,onDuplicate:g,onRevert:f,onSave:x,onDelete:u,onDropOverride:y,projects:h,selected:w,onSelect:S,onSaveOverride:P}){const E=oe(),{catalog:O,loading:A,degraded:j,refresh:D}=ue(null),{checking:L,recheck:_}=Ue(),[M,N]=r.useState(!1),F=!o&&s?s.path:`${E??"~"}/.claude/agents/${t.name}.md`,q=l||o,$=s&&!o?s.overrideDetails??[]:[],G=!o&&!!s&&(M||w!==null),J=t.tools.length===0,k=O?`Models live-read from claude${O.claudeVersion?` ${O.claudeVersion}`:""}${j?" (cached — CLI probe unavailable)":""}`:A?"Loading model catalog…":"Model catalog unavailable — showing the standard list",C=[{label:A||L?"Re-checking…":"Re-check models & CLIs",testId:"agent-detail-recheck",disabled:A||L,onSelect:()=>{D(),_()}},{label:k,testId:"agent-detail-catalog-info",disabled:!0,info:!0,onSelect:()=>{}},{label:"Reveal in File Explorer",testId:"agent-detail-reveal",disabled:o,onSelect:()=>Ne(F)},...o?[]:[{label:"Delete agent…",testId:"agent-detail-delete",danger:!0,disabled:i,onSelect:()=>m(!0)}]],X=p=>{if(J){n({tools:be.filter(W=>W!==p)});return}n({tools:t.tools.includes(p)?t.tools.filter(W=>W!==p):[...t.tools,p]})},z=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:g,disabled:i,className:"h-9 px-4 rounded-[10px] bg-bg-hi border border-line text-[13.5px] font-medium text-fg hover:border-rule disabled:opacity-40",children:"Duplicate"}),e.jsx(Hn,{items:C})]}),Z=$.length===0?o?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere.":$.length===1?`a local copy in ${me($[0].cwd,E)}/.claude/agents/ wins there`:"each project's local copy in its .claude/agents/ wins there";return e.jsxs("div",{"data-testid":"agent-detail",className:"flex-1 shrink-0 min-h-full flex flex-col",children:[e.jsx(Ke,{eyebrow:`AGENT · USER · ${me(F,E)}`,title:t.name,pill:o?"unsaved draft":l?"edited":void 0,actions:z}),a&&e.jsxs("div",{"data-testid":"agent-detail-delete-confirm",role:"alert",className:"shrink-0 mx-9 mt-4 px-4 py-2.5 rounded-[10px] border border-red-400/40 bg-red-400/10 flex items-center gap-3 text-[13px] text-fg",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx("button",{type:"button",onClick:u,disabled:i,className:"font-semibold text-red-400 hover:text-red-300",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>m(!1),className:"text-fg-faint hover:text-fg",children:"Keep"})]}),e.jsxs("div",{"data-testid":"agent-detail-body",className:"flex-1 shrink-0 flex flex-col gap-4 px-9 py-6",children:[e.jsx(pe,{label:"DESCRIPTION",labelNote:"CLAUDE READS THIS TO PICK THE AGENT",children:e.jsx("textarea",{"data-testid":"agent-detail-description","aria-label":"Description",rows:2,value:t.description,onKeyDown:p=>{p.key==="Enter"&&p.preventDefault()},onChange:p=>n({description:p.target.value.replace(/\r?\n/g," ")}),placeholder:"What this agent does — Claude reads it to decide when to use it",className:"w-full resize-none bg-transparent outline-none text-fg placeholder:text-fg-faint"})}),e.jsxs("section",{"data-testid":"agent-runtime-card",className:"px-[18px] py-4 rounded-[14px] bg-bg-hi border border-line flex flex-col gap-4",children:[e.jsxs("div",{"data-testid":"agent-runtime-row",className:"grid grid-cols-3 gap-4",children:[e.jsx(Vn,{value:t.model,onChange:p=>n({model:p})}),e.jsx(Kn,{value:t.effort,model:t.model,onChange:p=>n({effort:p})}),e.jsxs("div",{className:"min-w-0 flex flex-col gap-1.5",children:[e.jsx(zn,{value:t.agentCli,onChange:p=>n({agentCli:p,agentCliModel:""})}),t.agentCli!=="claude"&&e.jsx("input",{"data-testid":"agent-persona-cli-model","aria-label":"CLI model",value:t.agentCliModel,maxLength:128,placeholder:"Blank = the CLI's own default",onChange:p=>n({agentCliModel:p.target.value}),className:"w-full bg-bg border border-line rounded-md px-2 py-1 text-xs text-fg font-mono"})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"agent-tools-row",children:[e.jsx(re,{children:"tools"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:be.map(p=>{const W=J||t.tools.includes(p);return e.jsx("button",{type:"button","aria-pressed":W,"data-tool":p,onClick:()=>X(p),className:`px-2 py-0.5 rounded-md text-[12px] font-mono border ${W?"bg-honey/20 text-honey-dark border-honey/40":"bg-transparent text-fg-faint border-dashed border-rule"}`,children:p},p)})}),e.jsx("div",{"data-testid":"agent-tools-note",className:"text-[11px] text-fg-faint mt-1 leading-snug",children:J?"All tools — no tools: line, so every tool (MCP included) is granted. Click one to restrict.":e.jsxs(e.Fragment,{children:[t.tools.length," of ",be.length," granted. Anything not filled is refused at call time."," ",e.jsx("button",{type:"button","data-testid":"agent-tools-all",onClick:()=>n({tools:[]}),className:"underline text-fg-dim hover:text-fg",children:"Grant all tools"})]})})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"agent-overrides-row",children:[e.jsx(re,{children:"project overrides"}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2 pt-0.5",children:[$.map(p=>e.jsxs("span",{"data-testid":"agent-override-chip",title:`${me(p.cwd,E)}/.claude/agents/${s.name}.md`,className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded-md px-2 py-0.5 text-[12px] font-mono text-fg-dim",children:[e.jsx("strong",{className:"font-sans font-semibold text-fg",children:p.project}),Un(p),e.jsx("button",{onClick:()=>y(p.cwd,p.project),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},p.cwd)),e.jsx("span",{className:`text-[12px] text-fg-faint ${$.length===0?"italic":""}`,children:Z}),!o&&s&&!G&&e.jsx("button",{type:"button","data-testid":"agent-override-add",onClick:()=>N(!0),className:"text-[12px] font-medium text-accent hover:underline",children:"+ Add override"})]})]}),G&&s&&e.jsx(Xn,{saved:s,projects:h,selected:w,onSelect:S,busy:i,onSave:P,onClose:()=>{N(!1),S(null)}}),e.jsxs("details",{"data-testid":"agent-details",open:o||void 0,className:"group border-t border-line pt-3",children:[e.jsxs("summary",{className:"cursor-pointer select-none flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint",children:[e.jsx("span",{children:"details"}),e.jsxs("span",{className:"normal-case tracking-normal font-normal font-mono text-fg-dim flex items-center gap-1.5",children:[t.color&&e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{background:De[t.color]}}),t.color||"no colour"," · ",t.tags.length?t.tags.map(p=>`#${p}`).join(" "):"no tags"]})]}),e.jsxs("div",{className:"flex flex-col gap-3 pt-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"name"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("input",{"data-testid":"agent-detail-name","aria-label":"Name",value:t.name,onChange:p=>n({name:p.target.value.toLowerCase()}),className:"w-full max-w-sm bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:"Filename on disk — lowercase, hyphenated."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"color"}),e.jsx("div",{className:"flex gap-1.5 pt-0.5",children:Bn.map(p=>e.jsx("button",{type:"button",title:p||"none",onClick:()=>n({color:p}),className:"w-5 h-5 rounded",style:{background:p?De[p]:"transparent",border:t.color===p?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},p||"none"))})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"tags"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:se.map(p=>{const W=t.tags.includes(p.tag),c=Ee(p.tag);return e.jsxs("button",{type:"button",onClick:()=>n({tags:W?t.tags.filter(b=>b!==p.tag):[...t.tags,p.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${W?`${c.bg} ${c.text} ${c.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",p.tag]},p.tag)})}),e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab."})]})]})]})]})]}),e.jsx("div",{"data-testid":"agent-detail-editor","data-busy":i?"true":void 0,className:"flex-1 shrink-0 min-h-[320px] grid rounded-[14px] border border-line bg-bg-hi overflow-hidden",children:e.jsx(Mt,{path:F,value:t.body,defaultMode:"document",dirty:q,isNew:o,onChange:p=>n({body:p}),onSave:()=>{i||x()},onRevert:f})})]})]})}const Wn="w-full h-9 appearance-none pl-3 pr-8 rounded border border-line bg-bg-hi font-mono text-[13px] text-fg focus:outline-none focus:border-fg-faint disabled:opacity-60";function Le({label:t,hint:n,testId:s,value:l,onChange:o,children:i}){return e.jsxs("label",{className:"min-w-0 flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint",children:t}),e.jsxs("span",{className:"relative block",children:[e.jsx("select",{"data-testid":s,"aria-label":t,title:n,value:l,onChange:a=>o(a.target.value),className:Wn,children:i}),e.jsx("svg",{"aria-hidden":!0,"data-testid":`${s}-chevron`,viewBox:"0 0 16 16",className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-faint",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]})]})}const Ie=t=>{var n;return((n=/\[[^\]]*\]$/.exec(t))==null?void 0:n[0])??""};function Vn({value:t,onChange:n}){const{catalog:s}=ue(null),l=s?["inherit",...s.aliases]:[...He],o=(s==null?void 0:s.availableModels)??null,i=[];if(s){const u=new Set,y=h=>{!u.has(h)&&!l.includes(h)&&(u.add(h),i.push(h))};for(const h of s.models)y(h);for(const h of s.aliases){const w=Q(h),S=Ie(h);if(w&&S)for(const P of s.models)Q(P)===w&&y(P+S)}}const a=u=>!!o&&u!=="inherit"&&!o.includes(u),m=u=>{const y=Q(u);return!!o&&!o.includes(u)&&!(y&&o.includes(y+Ie(u)))&&!(y&&o.includes(y))},g=t||"inherit",f=l.includes(g)||i.includes(g);return e.jsxs(Le,{label:"model",hint:"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. Pinned versions fix a concrete id; an alias floats to the latest.",testId:"model-select",value:g,onChange:n,children:[!f&&e.jsxs("option",{value:g,children:[g," (current)"]}),e.jsx("optgroup",{label:"Aliases",children:l.map(u=>e.jsx("option",{value:u,disabled:!!s&&a(u),title:a(u)?ge:void 0,children:u},u))}),i.length>0&&e.jsx("optgroup",{label:"Pinned versions",children:i.map(u=>e.jsx("option",{value:u,disabled:m(u),title:m(u)?ge:void 0,children:u},u))})]})}function Kn({value:t,model:n,onChange:s}){const{catalog:l}=ue(null),o=l&&l.effortLevels.length?["inherit",...l.effortLevels]:[...Ge],i=(l==null?void 0:l.settingsEffortLevels)??[],a=l?o.filter(x=>x!=="inherit"&&!i.includes(x)):[],m=t||"inherit",g=m!=="inherit"&&Xe(n)===!1,f=l?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${a.length?`${a.join(", ")} ${a.length>1?"are":"is"} session-only — settings.json accepts ${i.join(", ")}. `:""}'inherit' writes no effort: line.`:"Catalog unavailable — showing the standard list. 'inherit' writes no effort: line.";return e.jsxs("div",{className:"min-w-0 flex flex-col gap-1",children:[e.jsxs(Le,{label:"effort",hint:f,testId:"effort-select",value:m,onChange:s,children:[!o.includes(m)&&e.jsxs("option",{value:m,children:[m," (current)"]}),o.map(x=>e.jsx("option",{value:x,children:a.includes(x)?`${x} (session-only)`:x},x))]}),g&&e.jsx("div",{className:"text-[11px] text-amber-400 leading-snug","data-testid":"effort-unsupported-note",children:"This model ignores effort."})]})}const Jn=["codex","gemini","antigravity","cursor","opencode"];function zn({value:t,onChange:n}){const{rows:s}=Ue(),l=new Map((s??[]).map(i=>[i.id,i]));return e.jsxs(Le,{label:"runs on",hint:"Which coding-agent CLI New Session starts this persona on — override per session in New Session → advanced. On a non-Claude CLI the session has no develop loop, no Restore, and this persona's model/effort are not used. Macros, phone launches and scheduled PRDs always run Claude Code.",testId:"agent-persona-cli-select",value:t,onChange:i=>n(i),children:[e.jsx("option",{value:"claude",children:"Claude Code"}),Jn.map(i=>{const a=l.get(i),m=(a==null?void 0:a.label)||rt[i],g=!!(a!=null&&a.installed),f=a?g?"":" (not installed)":s===null?" (checking…)":" (not detected)",x=a?g?[a.version,a.path].filter(Boolean).join(" · ")||void 0:a.install??"Not installed":void 0;return e.jsxs("option",{value:i,disabled:!g&&t!==i,title:x,children:[m,f]},i)})]})}function Ze({label:t,hint:n,children:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint mb-1.5",children:t}),s,n&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:n})]})}const je="latest",ge="Blocked by the availableModels allowlist in your Claude settings";function qn({value:t,onChange:n,label:s="model",hint:l,testIdPrefix:o="",inheritLabel:i}){var F,q;const{catalog:a,loading:m,degraded:g,refresh:f}=ue(null),x=a?["inherit",...a.aliases]:[...He],u=(a==null?void 0:a.availableModels)??null,y=$=>!!u&&$!=="inherit"&&!u.includes($),h=($,G)=>!!u&&!u.includes($)&&!(G&&u.includes(G)),w=t||"inherit",S=((F=/\[[^\]]*\]$/.exec(w))==null?void 0:F[0])??"",P=x.includes(w),E=!P&&a&&Q(w)&&x.includes(Q(w)+S)?Q(w)+S:null,O=P?w:E??w,A=Q(O),j=((q=/\[[^\]]*\]$/.exec(O))==null?void 0:q[0])??"",D=!!a&&w!=="inherit"&&!!A&&x.includes(O),L=D?a.models.filter($=>Q($)===A).map($=>$+j):[],_=P?je:w,M={};if(a)for(const $ of x)y($)&&(M[$]=ge);const N={};for(const $ of L)h($,A)&&(N[$]=ge);return e.jsxs(Ze,{label:s,hint:l??"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":`${o}model-row`,children:e.jsx(we,{options:x,value:O,onChange:n,mono:!0,blocked:M,labels:i?{inherit:i}:void 0})}),D&&e.jsxs("div",{className:"mt-2","data-testid":`${o}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(we,{options:[je,...L],value:_,onChange:$=>n($===je?O:$),mono:!0,blocked:N})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:a?`Models are live-read from the installed claude CLI${g?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:m?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${o}model-catalog-refresh`,onClick:()=>{f()},disabled:m,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function Yn({value:t,model:n,onChange:s,label:l="effort",testIdPrefix:o="",inheritLabel:i}){const{catalog:a}=ue(null),m=a&&a.effortLevels.length?["inherit",...a.effortLevels]:[...Ge],g=(a==null?void 0:a.settingsEffortLevels)??[],f=a?m.filter(y=>y!=="inherit"&&!g.includes(y)):[],x=t||"inherit",u=x!=="inherit"&&Xe(n)===!1;return e.jsxs(Ze,{label:l,hint:a?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${f.length?`${f.join(", ")} ${f.length>1?"are":"is"} session-only — settings.json accepts ${g.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${o}effort-row`,children:e.jsx(we,{options:m,value:x,onChange:s,mono:!0,labels:i?{inherit:i}:void 0})}),f.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${o}effort-session-only`,children:f.map(y=>`${y} (session-only)`).join(" · ")}),u&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${o}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Xn({saved:t,projects:n,selected:s,onSelect:l,busy:o,onSave:i,onClose:a}){var E,O,A;const m=oe(),g=r.useId(),f=new Map;for(const j of n)f.set(j.name,(f.get(j.name)??0)+1);const x=j=>{var M;const D=(f.get(j.name)??0)>1?me(j.cwd,m):j.name,L=(M=t.overrideDetails)==null?void 0:M.find(N=>N.cwd===j.cwd);if(!L)return D;const _=$e(L);return`${D} — ${_.length?`overrides ${_.join(", ")}`:"overlay"}`},u=s?(E=t.overrideDetails)==null?void 0:E.find(j=>j.cwd===s.cwd):void 0,y=!!(u!=null&&u.bodyOverridden),h=((O=u==null?void 0:u.values)==null?void 0:O.model)??"inherit",w=((A=u==null?void 0:u.values)==null?void 0:A.effort)??"inherit",S=t.model??"inherit",P=t.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override-block",className:s?"border border-accent/40 rounded p-3 space-y-3 bg-accent/5":"border border-dashed border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:g,className:`flex-1 text-[10.5px] font-semibold uppercase tracking-wide font-mono ${s?"text-accent":"text-fg-faint"}`,children:"project override"}),e.jsx("button",{type:"button","data-testid":"override-close",onClick:a,className:"text-[11px] text-fg-faint hover:text-fg",children:"Done"})]}),e.jsx("div",{className:"flex flex-col gap-1",children:e.jsxs("select",{id:g,"data-testid":"override-project-select",value:(s==null?void 0:s.cwd)??"",onChange:j=>l(j.target.value||null),disabled:o||n.length===0,className:"rounded-md border border-line bg-bg px-2 py-1.5 font-mono text-[12.5px] text-fg disabled:opacity-60",children:[e.jsx("option",{value:"",children:"Choose a project…"}),n.map(j=>e.jsx("option",{value:j.cwd,children:x(j)},j.cwd))]})}),n.length===0?e.jsx("div",{"data-testid":"project-override-none",className:"text-[11px] text-fg-faint leading-snug",children:"No open project tabs — open a project tab to override this persona's model or effort for it."}):s?e.jsxs("div",{"data-testid":"project-override",className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(We,{tone:"accent",children:[s.name," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(zt,{path:`${s.cwd}/.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.name})," 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."]}),y&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s.name,' 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 its × in the "project overrides" row above.']}),e.jsxs("fieldset",{disabled:o||y,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(qn,{value:h,onChange:j=>{y||i({model:j,effort:w})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(Yn,{value:w,model:h!=="inherit"?h:S,onChange:j=>{y||i({model:h,effort:j})},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",S,h],["effort",P,w]].map(([j,D,L])=>e.jsxs("div",{"data-testid":`override-provenance-${j}`,children:[j,": ",L!=="inherit"?e.jsxs(e.Fragment,{children:[D," ",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:[D," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},j))})]}):e.jsx("div",{"data-testid":"project-override-unselected",className:"text-[11px] text-fg-faint leading-snug",children:"Pick an open project to see or set this persona's model and effort for that project only. A project that already overrides this persona says what it overrides."})]})}const Zn=new Set(se.map(t=>t.tag));function Qe(t){return t.filter(n=>Zn.has(n))}function Qn(t,n={}){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:Qe(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...t.agentCli?{agentCli:t.agentCli}:{},...t.agentCliModel?{agentCliModel:t.agentCliModel}:{},...n}}function es(t){const n=new Map;for(const s of t){const l=typeof s.cwd=="string"?dt(s.cwd):"";l&&!n.has(l)&&n.set(l,{cwd:l,name:ut(l)})}return[...n.values()].sort((s,l)=>s.name.localeCompare(l.name)||s.cwd.localeCompare(l.cwd))}function ts(t){return(t.overrideDetails??[]).map(n=>`${n.project}: ${$e(n).join(", ")||"overlay"}`).join(`
|
|
3
3
|
`)}const ns=[{key:"personas",label:"Personas"},{key:"tags",label:"Tags"}];function ss(){const[t,n]=r.useState("personas"),{personas:s,refresh:l}=Se(d=>H.error(d.message||"failed to load agent personas")),[o,i]=r.useState(null),[a,m]=r.useState(""),[g,f]=r.useState(null),[x,u]=r.useState(!1),[y,h]=r.useState(!1),[w,S]=r.useState(null),[P,E]=r.useState(!1),O=r.useRef(!0);r.useEffect(()=>()=>{O.current=!1},[]);const A=ct(d=>d.tabs),j=r.useMemo(()=>es(A),[A]),[D,L]=r.useState(null),_=j.find(d=>d.cwd===D)??null,M=async d=>{await l()&&d&&i(d)};Ye(j.map(d=>d.cwd),()=>M()),r.useEffect(()=>{const d=ft();d&&i(d);const T=I=>i(I.detail);return window.addEventListener("sm:select-persona",T),()=>window.removeEventListener("sm:select-persona",T)},[]);const N=le(d=>d.tab),F=le(d=>d.id),q=le(d=>d.clear);r.useEffect(()=>{if(N!=="agents"||!F||s===null)return;const d=F.startsWith("agents:")?F.slice(7):null;d&&s.some(T=>T.name===d)&&(n("personas"),m(""),f(null),u(!1),h(!1),S(null),i(d)),q()},[N,F,s,q]);const $=e.jsx(Je,{eyebrow:"AGENTS FOLDER",badge:s==null?void 0:s.length,path:"~/.claude/agents/",note:"The actor a session opens with — “you are acting as …”",children:e.jsx("div",{role:"group","aria-label":"Agents view","data-testid":"agent-view-switch",className:"mt-1 self-start inline-flex items-center p-0.5 rounded bg-bg-hi border border-line",children:ns.map(d=>e.jsx("button",{type:"button",onClick:()=>n(d.key),"aria-pressed":t===d.key,className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${t===d.key?"bg-bg text-fg font-medium shadow-sm":"text-fg-dim hover:text-fg"}`,children:d.label},d.key))})});if(t==="tags")return e.jsx("div",{className:"flex flex-col h-full min-h-0",children:e.jsx(Ce,{list:$,detail:e.jsx(Dn,{onOpenPersona:d=>{i(d),f(null),u(!1),n("personas")}})})});if(s===null)return e.jsx(Y,{title:"loading…"});const G=a.toLowerCase(),J=s.filter(d=>!G||d.name.toLowerCase().includes(G)||(d.description??"").toLowerCase().includes(G)),k=s.find(d=>d.name===o)??s[0]??null,C=g??(k?ve(k):null),X=!!g&&!!k&&JSON.stringify(g)!==JSON.stringify(ve(k)),z=x,Z=d=>{f(null),u(!1),h(!1),S(null),i(d)},p=d=>f(T=>({...T??(k?ve(k):Re),...d})),W=()=>{f({...Re}),u(!0),h(!1)},c=()=>{C&&(f({...C,name:C.name+"-copy"}),u(!0))},b=()=>{f(null),u(!1)},R=async()=>{if(C){if(!/^[a-z][a-z0-9-]*$/.test(C.name)){H.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}E(!0);try{const d=z?null:k,T={name:C.name,originalName:d==null?void 0:d.name,description:C.description,tools:C.tools,model:C.model,effort:C.effort,color:C.color,tags:Qe(C.tags),body:C.body,agentCli:C.agentCli,...C.agentCli!=="claude"&&C.agentCliModel.trim()?{agentCliModel:C.agentCliModel.trim()}:{}},I=d?Qn(d,T):T;"agentCliModel"in T||delete I.agentCliModel,await window.api.agents.savePersona(I),H.info(z?`created ${C.name}`:`saved ${C.name}`),f(null),u(!1),await M(C.name)}catch(d){H.error(d.message||"failed to save agent persona")}finally{E(!1)}}},U=async()=>{if(k){E(!0);try{await window.api.agents.deletePersona({name:k.name}),H.info(`deleted ${k.name}`),h(!1),f(null),u(!1),await M()}catch(d){H.error(d.message||"failed to delete agent persona")}finally{E(!1)}}},ee=async d=>{E(!0);try{await window.api.agents.deletePersona({name:d}),H.info(`deleted ${d}`),S(null),o===d&&(f(null),u(!1)),await M()}catch(T){H.error(T.message||"failed to delete agent persona")}finally{E(!1)}},te=async(d,T)=>{if(k)try{await window.api.agents.removeOverride({name:k.name,projectCwd:d}),H.info(`removed ${T}'s override of ${k.name}`),await M(k.name)}catch(I){H.error(I.message||"failed to remove override")}},B=async d=>{if(!k||!_)return;const{cwd:T,name:I}=_;E(!0);try{d.model==="inherit"&&d.effort==="inherit"?(await window.api.agents.removeOverride({name:k.name,projectCwd:T}),H.info(`cleared ${I}'s override of ${k.name}`)):(await window.api.agents.savePersona({name:k.name,projectCwd:T,description:"",tools:[],color:"",tags:[],body:"",model:d.model,effort:d.effort}),H.info(`saved ${I}'s override of ${k.name}`)),await M(k.name)}catch(v){H.error(v.message||"failed to save project override")}finally{E(!1)}},ne=e.jsxs(e.Fragment,{children:[$,e.jsx(ze,{filter:a,onFilterChange:m,placeholder:"Filter",primaryLabel:"+ New",onPrimary:W}),e.jsxs("div",{role:"listbox","aria-label":"Agents",className:"flex flex-col gap-0.5",children:[z&&C&&e.jsx("div",{"data-agent-row-new":"",children:e.jsx(ke,{title:C.name,trailing:e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"new"}),meta:C.description||void 0,selected:!0,onSelect:()=>{}})}),J.length===0&&!z?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):J.map(d=>{const T=!z&&d.name===(k==null?void 0:k.name),I=T&&X,v=w===d.name;return e.jsx("div",{"data-agent-row":d.name,className:"group",children:e.jsx(ke,{title:d.name,selected:T,onSelect:()=>Z(d.name),meta:d.description||void 0,trailing:e.jsxs("span",{className:"flex items-center gap-1.5",children:[I&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!I&&d.overridingProjects.length>0&&e.jsx("span",{title:ts(d),children:e.jsxs(We,{tone:"dim",children:[d.overridingProjects.length," override",d.overridingProjects.length>1?"s":""]})}),e.jsx("span",{"data-testid":"agent-row-model",className:"font-mono",children:d.model??"inherit"}),v?e.jsxs("span",{className:"flex items-center gap-1",onClick:V=>V.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:()=>ee(d.name),disabled:P,title:`Delete ${d.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{type:"button",onClick:()=>S(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),S(d.name)},title:`Delete ${d.name}`,"aria-label":`Delete ${d.name}`,className:"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})})},d.name)})]})]});return e.jsx("div",{className:"flex flex-col h-full min-h-0",children:e.jsx(Ce,{list:ne,detail:C?e.jsx(Gn,{obj:C,set:p,saved:k,dirty:X,isNew:z,busy:P,confirmDelete:y,setConfirmDelete:h,onDuplicate:c,onRevert:b,onSave:R,onDelete:U,onDropOverride:te,projects:j,selected:_,onSelect:L,onSaveOverride:B}):e.jsx(Y,{title:"select an agent"})})})}const as=r.memo(ss),ls={"claude-md":"system-prompt",settings:"settings",mcp:"extensions",skills:"extensions",plugins:"extensions",agents:"agent-library"},os={skills:"Add skill",mcp:"Add MCP server",plugins:"Add plugin"},ce=t=>t??void 0;async function Oe(t){try{return await t()}catch{return null}}function is(){const t=oe(),[n,s]=r.useState({claudeMd:null,settings:null}),l=r.useRef(0),o=t?`${t}/.claude/CLAUDE.md`:null,i=t?`${t}/.claude/settings.json`:null,a=r.useCallback(()=>{if(!o||!i)return;const m=++l.current;Promise.all([Oe(()=>Wt(o)),Oe(()=>Vt(i))]).then(([g,f])=>{m===l.current&&s({claudeMd:g,settings:f})})},[o,i]);return r.useEffect(()=>(a(),()=>{l.current++}),[a]),ae([o,i],a),n}const rs=()=>Kt({scope:"home",cwd:null,api:window.api});function cs({initialTab:t="claude-md"}){const[n,s]=r.useState(t),[l,o]=r.useState(!1),[i,a]=r.useState(!1),[m,g]=r.useState({scope:"user",cwd:null}),f=sn(),{personas:x}=Se(),u=is(),y=Pt(Tt),h=r.useMemo(()=>At(y),[y]),w=ye(N=>N.panelTabHint);r.useEffect(()=>{if(!w||w.id!=="claude-config")return;const[N,F]=w.tab.split(":");Pe(N)&&(s(N),o(!1)),ye.setState({panelTabHint:N==="settings"&&F?{id:"settings",tab:F}:null})},[w]);const S=r.useCallback(N=>{s(N),o(!1)},[]),P=r.useCallback(()=>o(!1),[]),E=r.useCallback(()=>o(!0),[]),O=r.useCallback(N=>{g(N),o(!0)},[]),A=r.useCallback(()=>a(N=>!N),[]),j=r.useCallback(N=>{Pe(N.tab)&&(S(N.tab),le.getState().set(N.tab,N.id))},[S]),D=Dt({load:rs,loadKey:"home",onChoose:j}),L=r.useMemo(()=>{const N={"claude-md":Rt(u.claudeMd),settings:{count:ce(u.settings)},mcp:{count:ce(f.mcp),attention:h},skills:{count:ce(f.skills)},plugins:{count:ce(f.plugins)},agents:{count:ce(x==null?void 0:x.length)}};return mt.map(F=>({...F,...N[F.key]}))},[u.claudeMd,u.settings,f.mcp,f.skills,f.plugins,x,h]),_=pt[ls[n]],M=n==="skills"||n==="mcp"||n==="plugins"?n:null;return e.jsxs("div",{className:"h-full w-full flex flex-col bg-bg text-fg","data-testid":"home-claude-config",children:[e.jsx(It,{eyebrow:"CLAUDE CODE · GLOBAL",title:"Claude config",scopePath:"~/.claude",tabs:L,activeKey:n,onSelect:S,onLearn:A,...D.bandProps,searchPanel:e.jsx(Ot,{...D.panelProps,tabs:L})}),i&&_&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-7 py-4 max-h-[40vh] overflow-y-auto","data-testid":"home-claude-config-learn",children:e.jsx(gt,{content:_})}),e.jsxs("div",{className:"flex-1 min-h-0 px-8 py-6","data-testid":`home-claude-config-panel-${n}`,children:[n==="claude-md"&&e.jsx(rn,{}),n==="settings"&&e.jsx(Ft,{scope:"user"}),n==="mcp"&&e.jsx(_t,{onAdd:O,scope:"user"}),n==="skills"&&e.jsx(Bt,{onAdd:E,scope:"user"}),n==="plugins"&&e.jsx(Ln,{onAdd:E,onJump:S}),n==="agents"&&e.jsx(as,{})]}),M&&e.jsxs(xt,{open:l,onClose:P,title:os[M],keyVals:[],children:[M==="skills"&&e.jsx(Ut,{}),M==="mcp"&&e.jsx(Ht,{scope:m.scope,cwd:m.cwd}),M==="plugins"&&e.jsx(Gt,{})]})]})}const xs=r.memo(cs);export{xs as HomeClaudeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aB as e}from"./index-
|
|
1
|
+
import{aB as e}from"./index-B2TQz3nd.js";function n({toolbar:s,footer:l,children:r}){return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:s}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:r}),l&&e.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:l})]})}export{n as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aR as o,ba as A,aB as e,ao as _t,aV as Bt,a9 as he,an as Ut,bl as at,bb as rt,m as Ne,bq as Kt,L as Wt,r as Ht,p as Vt,bg as Gt,C as Ke,ac as We,aC as Yt}from"./index-
|
|
1
|
+
import{aR as o,ba as A,aB as e,ao as _t,aV as Bt,a9 as he,an as Ut,bl as at,bb as rt,m as Ne,bq as Kt,L as Wt,r as Ht,p as Vt,bg as Gt,C as Ke,ac as We,aC as Yt}from"./index-B2TQz3nd.js";import{q as ot,d as qt,D as zt,H as fe,J as Xt,E as Jt,w as Qt,v as Zt,G as es,m as ts,a as ss,h as ns,j as as,k as rs,M as os,C as ls,I as is,S as ds,n as cs,o as He}from"./Skills-C1v91GEO.js";import{s as ms}from"./ViewTabs-DXhOWFG0.js";import{V as us}from"./VoiceButton-qivnDV6K.js";import"./monaco-editor-BsIlgG7c.js";import"./Panel-Bf1Cf8UL.js";import"./TiptapBody-BrcWVpiW.js";const Ve=["bg-accent","bg-sage-dark","bg-honey","bg-fg-dim","bg-fg-faint","bg-hive-teal","bg-butter","bg-delta-bad"],lt=864e5,xs="MEMORY.md",Ge=2e3,Me=s=>s.replace(/\.md$/,"");function it(s,t,n,d){var y,x,m;const i=new Map(((t==null?void 0:t.entries)??[]).map(c=>[c.name,c])),a=new Set(((y=t==null?void 0:t.index)==null?void 0:y.orphans)??[]),u=new Map;for(const c of(n==null?void 0:n.clusters)??[])for(const h of c.memberSlugs)u.has(h)||u.set(h,c.id);const g=s.filter(c=>c.name!==xs),p=new Map;for(const c of g){const h=Me(c.name),k=((x=i.get(c.name))==null?void 0:x.outLinks)??((m=i.get(h))==null?void 0:m.outLinks)??[];for(const v of k){const S=Me(v),b=p.get(S)??[];b.includes(h)||b.push(h),p.set(S,b)}}return g.map(c=>{const h=Me(c.name),k=i.get(c.name)??i.get(h),v=(k==null?void 0:k.deadRefs)??[],S=(k==null?void 0:k.danglingLinks)??[],b=(k==null?void 0:k.stale)??!1;return{name:c.name,slug:h,path:c.path,description:(k==null?void 0:k.description)??"",bytes:c.bytes,mtimeMs:c.mtimeMs,ageDays:Math.floor((d-c.mtimeMs)/lt),stale:b,staleReasons:(k==null?void 0:k.reasons)??[],ageOnlyStale:b&&v.length===0,deadRefs:v,movedRefs:(k==null?void 0:k.movedRefs)??[],broken:v.length>0||S.length>0,danglingLinks:S,outLinks:(k==null?void 0:k.outLinks)??[],inLinks:p.get(h)??[],notIndexed:a.has(c.name)||a.has(h),clusterId:u.get(h)??null,type:(k==null?void 0:k.type)??null,originSessionId:(k==null?void 0:k.originSessionId)??null}})}function ps(s,t){const n=new Set(t.filter(d=>d.stale).map(d=>d.slug));return((s==null?void 0:s.clusters)??[]).map((d,i)=>({id:d.id,name:d.name,summary:d.summary,memberSlugs:d.memberSlugs,linkCount:d.links.length,retireCount:d.links.filter(a=>/retire/i.test(a.label??"")).length,staleCount:d.memberSlugs.filter(a=>n.has(a)).length,dotClass:Ve[i%Ve.length]}))}function fs(s,t,n){const d=t.trim().toLowerCase(),i=d?s.filter(a=>a.slug.toLowerCase().includes(d)||a.description.toLowerCase().includes(d)):s;return n===void 0?i:i.slice(0,n)}function pe(s,t,n){let d;return t==="ask"||t==="clusters"||t==="archived"?[]:(t==="all"?d=s:t==="stale"?d=s.filter(i=>i.stale):t==="broken"?d=s.filter(i=>i.broken):t==="recent"?d=s.filter(i=>Date.now()-i.mtimeMs<=7*lt):t==="unindexed"?d=s.filter(i=>i.notIndexed):t==="cluster:unclustered"?d=s.filter(i=>i.clusterId===null):t.startsWith("cluster:")?d=s.filter(i=>i.clusterId===t.slice(8)):d=s,fs(d,n))}function hs(s,t){const n=[...s];return t==="recent"?n.sort((d,i)=>i.mtimeMs-d.mtimeMs):t==="name"?n.sort((d,i)=>d.slug<i.slug?-1:d.slug>i.slug?1:0):n.sort((d,i)=>i.bytes-d.bytes),n}function gs(s){return{all:s.length,stale:pe(s,"stale","").length,broken:pe(s,"broken","").length,recent:pe(s,"recent","").length,unindexed:pe(s,"unindexed","").length}}function dt(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"untitled_memory"}function bs(s,t){const n=s===""?[]:s.split(`
|
|
2
2
|
`),d=t===""?[]:t.split(`
|
|
3
3
|
`);if(n.length>Ge||d.length>Ge)return[...n.map(x=>({sign:"−",text:x})),...d.map(x=>({sign:"+",text:x}))];const i=n.length,a=d.length,u=Array.from({length:i+1},()=>new Array(a+1).fill(0));for(let x=i-1;x>=0;x--)for(let m=a-1;m>=0;m--)u[x][m]=n[x]===d[m]?u[x+1][m+1]+1:Math.max(u[x+1][m],u[x][m+1]);const g=[];let p=0,y=0;for(;p<i&&y<a;)n[p]===d[y]?(p++,y++):u[p+1][y]>=u[p][y+1]?g.push({sign:"−",text:n[p++]}):g.push({sign:"+",text:d[y++]});for(;p<i;)g.push({sign:"−",text:n[p++]});for(;y<a;)g.push({sign:"+",text:d[y++]});return g}const K=s=>s instanceof Error?s.message:String(s);function Ye(s){const t=/^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/.exec(s);return t?{front:t[0],body:s.slice(t[0].length)}:{front:"",body:s}}function ys(s){return s.split(`
|
|
4
4
|
`).map(t=>t.trim()).find(t=>t.length>0)??""}function ks(s,t){const n=s.kind==="agent"?s.agent:null,d=n?`${n.name}|${n.memoryScope??""}`:"",i=n!==null&&n.memoryScope===null,a=o.useMemo(()=>i?null:n&&n.memoryScope?{agent:{name:n.name,scope:n.memoryScope},...t?{cwd:t}:{}}:{workspace:ot(t),...t?{cwd:t}:{}},[d,i,t]),u=n===null,[g,p]=o.useState(!0),[y,x]=o.useState([]),[m,c]=o.useState(null),[h,k]=o.useState(null),[v,S]=o.useState(!1),[b,$]=o.useState(""),[W,z]=o.useState(!0),[ae,I]=o.useState([]),[D,R]=o.useState([]),[E,re]=o.useState({}),[X,V]=o.useState(()=>Date.now()),oe=o.useRef(a);oe.current=a;const O=o.useCallback(async()=>{if(!a){x([]),c(null),k(null),I([]),$(""),p(!1);return}try{const l=await window.api.memory.list(a);if(oe.current!==a)return;x(l.entries??[]),$(l.dir??""),z(l.autoMemoryEnabled!==!1),l.error&&A.error(`Memory list failed: ${l.error}`);const[j,w]=await Promise.all([window.api.memory.stale(a).catch(C=>(A.error(`Memory staleness check failed: ${K(C)}`),null)),window.api.memory.listArchived(a).catch(()=>({names:[],error:null}))]);if(oe.current!==a)return;c(j),I(w.names??[]),V(Date.now())}catch(l){A.error(`Memory list failed: ${K(l)}`)}finally{p(!1)}},[a]);o.useEffect(()=>{p(!0),k(null),O(),a&&u&&a.workspace&&window.api.memory.aggregate(a.workspace,!1,t??void 0).then(l=>{oe.current===a&&k(l)}).catch(l=>A.error(`Memory clusters failed: ${K(l)}`))},[O]),o.useEffect(()=>{let l=!1;return(async()=>{try{const{agents:j}=await window.api.memory.agents(t??void 0);if(l)return;R(j);const w={};await Promise.all(j.filter(C=>C.memoryScope).map(async C=>{const F=await window.api.memory.list({agent:{name:C.name,scope:C.memoryScope},...t?{cwd:t}:{}});w[C.name]=(F.entries??[]).filter(L=>L.name!=="MEMORY.md").length})),l||re(w)}catch(j){l||A.error(`Memory agents failed: ${K(j)}`)}})(),()=>{l=!0}},[t]),o.useEffect(()=>{if(!b)return;const l=b;window.api.config.watch([l]);const j=window.api.config.onChanged(({path:w})=>{(w===l||w.startsWith(l+"/"))&&O()});return()=>{j(),window.api.config.unwatch([l])}},[b,O]);const _=o.useMemo(()=>it(y,m,h,X),[y,m,h,X]),me=o.useMemo(()=>ps(h,_),[h,_]),Ce=o.useMemo(()=>({generatedAt:(h==null?void 0:h.generatedAt)??null,running:v}),[h,v]),B=o.useCallback(async l=>{if(!a)return null;try{const j=await window.api.memory.read(l,a);return j.error?(A.error(`Memory read failed: ${j.error}`),null):j.content}catch(j){return A.error(`Memory read failed: ${K(j)}`),null}},[a]),M=o.useCallback(async(l,j)=>{try{const w=await j();return w.ok?(await O(),!0):(A.error(`${l} failed: ${w.error??"unknown error"}`),!1)}catch(w){return A.error(`${l} failed: ${K(w)}`),!1}},[O]),J=o.useCallback(async(l,j)=>{if(!a)return!1;const w=await B(l);if(w===null)return!1;const{front:C}=Ye(w);return M("Memory save",()=>window.api.memory.write(l,C+j,a))},[a,B,M]),G=o.useCallback(async(l,j)=>a?M("Memory save",()=>window.api.memory.write(l,j,a)):!1,[a,M]),H=o.useCallback(async(l,j)=>{if(!a)return null;const w=dt(l),C=ys(j);if(!await M("Memory create",()=>window.api.memory.create(w,C,a)))return null;const L=`---
|