claude-code-session-manager 0.96.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/assets/{DataModel-T0D00BpK.js → DataModel-DCEgMTjH.js} +1 -1
  2. package/dist/assets/{History-DuAovTr7.js → History-Bfdoywlh.js} +1 -1
  3. package/dist/assets/{Hooks-CgP9jsAN.js → Hooks-CKDJjTJV.js} +1 -1
  4. package/dist/assets/{HostBilko-DHfz3Mxa.js → HostBilko-CDVHE0hT.js} +1 -1
  5. package/dist/assets/{Library--poVP-d1.js → Library-7akfgy67.js} +1 -1
  6. package/dist/assets/{MarkdownEditor-C56-Pc4c.js → MarkdownEditor-DDesiqet.js} +1 -1
  7. package/dist/assets/{McpServers-D-ykP4Vi.js → McpServers-D4lZtXof.js} +1 -1
  8. package/dist/assets/{Memory-BrkJjRL8.js → Memory-CeI8G1w5.js} +1 -1
  9. package/dist/assets/{Permissions-BMpAaxJu.js → Permissions-BGleLja4.js} +1 -1
  10. package/dist/assets/{Plugins-OuEe5S_T.js → Plugins-P4eCXy_S.js} +2 -2
  11. package/dist/assets/{ProvenanceBadge-4eNbDYe8.js → ProvenanceBadge-BFczzI1B.js} +1 -1
  12. package/dist/assets/{SaveBar-BQ8y9Lkv.js → SaveBar-l9jnEMES.js} +1 -1
  13. package/dist/assets/{Scheduler-DcMT5sT_.js → Scheduler-C_phpeUS.js} +1 -1
  14. package/dist/assets/{ScopeSwitcher-XdxtVKP-.js → ScopeSwitcher-CjJi8ST5.js} +1 -1
  15. package/dist/assets/{Settings-FdaPUq2t.js → Settings-BIwZ3FGQ.js} +1 -1
  16. package/dist/assets/{SkillReferenceGraph-CJzvvc0_.js → SkillReferenceGraph-CjbO01Sg.js} +1 -1
  17. package/dist/assets/{Skills-Wvm9OE1e.js → Skills-BxZ9_fCR.js} +1 -1
  18. package/dist/assets/{SystemPrompt--LYw_69j.js → SystemPrompt-D8vfFb8b.js} +1 -1
  19. package/dist/assets/{TagLibrary-Be6HbMMx.js → TagLibrary-2vzUo7YL.js} +1 -1
  20. package/dist/assets/{TiptapBody-DzFlWMgO.js → TiptapBody-B8ZfbK90.js} +1 -1
  21. package/dist/assets/{Toggle-BxtAFE1i.js → Toggle-BbW4nGGf.js} +1 -1
  22. package/dist/assets/{index-XkrLB67D.js → index-Cd98Q1lD.js} +3 -3
  23. package/dist/assets/{settingsSchema-BIvDZ1Cj.js → settingsSchema-IhUfucCF.js} +1 -1
  24. package/dist/index.html +1 -1
  25. package/package.json +2 -1
  26. package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +2 -0
  27. package/plugins/session-manager-dev/skills/develop/SKILL.md +12 -5
  28. package/src/main/__tests__/ipcSchemas-dependsOn.test.cjs +39 -0
  29. package/src/main/__tests__/planValidator.test.cjs +54 -0
  30. package/src/main/__tests__/prdCreateAdoption.test.cjs +205 -0
  31. package/src/main/__tests__/queueOpsAutoArchive.test.cjs +63 -6
  32. package/src/main/__tests__/scheduler-mutate-reentrancy.test.cjs +117 -0
  33. package/src/main/build-info.json +4 -4
  34. package/src/main/ipcSchemas.cjs +10 -6
  35. package/src/main/lib/__tests__/watchdog-helpers.test.cjs +66 -0
  36. package/src/main/lib/planValidator.cjs +59 -7
  37. package/src/main/lib/prdCreate.cjs +32 -7
  38. package/src/main/lib/watchdogHelpers.cjs +21 -5
  39. package/src/main/queueOps.cjs +17 -6
  40. package/src/main/scheduler.cjs +65 -5
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-CJzvvc0_.js","./index-XkrLB67D.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./index-CKH5Uxik.css"])))=>i.map(i=>d[i]);
2
- import{ak as e,az as m,m as k,r as U,aX as Y,aS as Z,v as V,aN as W,a as ee}from"./index-XkrLB67D.js";import{P as q}from"./ProvenanceBadge-4eNbDYe8.js";import{e as te}from"./Library--poVP-d1.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as ne}from"./monaco-editor-BW5C4Iv1.js";import{M as se}from"./MarkdownEditor-C56-Pc4c.js";function ie({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:h}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:h??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(p=>e.jsx("td",{className:`px-3 py-1 ${p.className??""}`,children:p.render(l)},p.key))},r)})})]})}async function ae(t,n,o){var p,g;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const h=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!h)return null;const l=(g=(p=i.plugins[h])==null?void 0:p[0])==null?void 0:g.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function le(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,h=await window.api.config.readText(i);if(!h.exists)continue;const l=G(h.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function re(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const h=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${h}\\b`,`\`${h}\``];if(i.id.length>=4&&l.push(`\\b${h}\\b`),!l.some(p=>new RegExp(p,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const oe=m.lazy(()=>ne(()=>import("./SkillReferenceGraph-CJzvvc0_.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function ce({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var g;const[i,h]=m.useState(a??((g=n[0])==null?void 0:g.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=m.useMemo(()=>re(n),[n]),[d,p]=m.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>p("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>p("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(k,{title:"no skills in this plugin"}):d==="graph"?e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(oe,{skills:n,edges:r,selectedId:i,onSelect:h})}):e.jsx(U,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>h(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(se,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(k,{title:"select a skill"})})})]})}const X=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function de(){const t=Y(),[n,o]=m.useState([]),[a,i]=m.useState(!0),[h,l]=m.useState(null),[r,d]=m.useState("installed"),[p,g]=m.useState(null),[c,L]=m.useState(new Set);m.useEffect(()=>{var x,v;let s=!1;return(v=(x=window.api.app).seedStatus)==null||v.call(x).then(j=>{s||g(j)}).catch(()=>{}),()=>{s=!0}},[]);const w=m.useRef(0),$=m.useCallback(async()=>{var v;const s=++w.current;if(!t)return;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const M=j.data;for(const[O,u]of Object.entries(M.plugins??{})){if(!Array.isArray(u))continue;const y=O.split("@")[0],I=O.split("@")[1];for(const b of u){if(!(b!=null&&b.installPath))continue;const R={name:y,path:b.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},P=await pe(R);(v=P.manifest)!=null&&v.version||(P.manifest={...P.manifest??{},version:b.version}),P.marketplace=I,x.push(P)}}}}catch{}w.current===s&&(x.sort((j,M)=>j.name.localeCompare(M.name)),o(x),i(!1))},[t]);m.useEffect(()=>{$()},[$]),m.useEffect(()=>()=>{w.current+=1},[]),Z(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],$);const D=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(q,{interactive:!1,input:X(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],f=m.useMemo(()=>p?Object.keys(p).filter(s=>p[s].status==="exhausted"&&!c.has(s)):[],[p,c]),C=f.length>0?e.jsx(he,{seeders:f,seedStatus:p,onDismiss:s=>L(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(V,{toolbar:e.jsx(z,{active:r,onChange:d}),children:[C,e.jsx(te,{})]});const S=h?n.find(s=>s.path===h)??null:null;return e.jsxs(V,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(z,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[C,a?e.jsx(k,{title:"scanning plugins…"}):S?e.jsx(me,{row:S,home:t,onBack:()=>l(null)},S.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ie,{columns:D,rows:n,getKey:s=>s.path,activeKey:h,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const ye=m.memo(de),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function he({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[K[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${K[i]} warning`,children:"✕"})]},i))})}function z({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function me({row:t,home:n,onBack:o}){var x,v,j,M,O;const[a,i]=m.useState([]),[h,l]=m.useState([]),[r,d]=m.useState([]),[p,g]=m.useState([]),[c,L]=m.useState("skills"),[w,$]=m.useState(null),[D,f]=m.useState(!0);m.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{f(!0);try{const[y,I,b,R]=await Promise.all([ae(t.name,t.path,n),F(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),F(`${t.path}/bin`,{filesOnly:!0})]),P=y?await le(y):[],T=I.filter(N=>N.endsWith(".md")),Q=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),H=[];T.forEach((N,B)=>{const A=Q[B];if(!A.exists)return;const _=G(A.text);H.push({id:N,name:_.name??N.replace(/\.md$/,""),description:_.description})});const J=[];if(b&&b.exists&&!b.parseError&&b.data&&typeof b.data=="object"){const N=b.data.mcpServers;if(N&&typeof N=="object")for(const[B,A]of Object.entries(N)){const _=A&&typeof A=="object"?A.command:void 0;J.push({id:B,name:B,description:typeof _=="string"?_:null})}}if(u)return;i(P),l(H),d(J),g(R),L(P.length>0?"skills":H.length>0?"agents":J.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(y){if(u)return;W.error(`Failed to load plugin contents: ${y instanceof Error?y.message:String(y)}`),i([]),l([]),d([]),g([])}finally{u||f(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const C=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:h.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],S=(x=t.manifest)!=null&&x.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,s=async u=>{const y=await window.api.shell.open({as:"external",url:u});y.ok||W.error(y.error??`Failed to open ${u}`)};return w?e.jsx(ce,{pluginName:((v=t.manifest)==null?void 0:v.name)??t.name,skills:a,initialSelectedId:w.id,onBack:()=>$(null)},w.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((j=t.manifest)==null?void 0:j.name)??t.name}),(M=t.manifest)!=null&&M.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(O=t.manifest)!=null&&O.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(q,{input:X(t)}),t.hasMcp?e.jsx(ee,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[S?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),S]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>s(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:C.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>L(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:D?e.jsx(k,{title:"scanning…"}):e.jsx(fe,{active:c,row:t,skills:a,agents:h,mcpServers:r,files:p,onOpenSkill:$})})]})]})}function fe({active:t,row:n,skills:o,agents:a,mcpServers:i,files:h,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(E,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(E,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(E,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(E,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(E,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(E,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(k,{title:"no components"}):h.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:h.map((r,d)=>e.jsx(E,{n:d+1,name:r,description:null},r))})}function E({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function pe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const f=await window.api.config.readJson(n);f.exists&&!f.parseError&&f.data&&typeof f.data=="object"&&(a=f.data)}const[i,h,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const f=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(f.data)?d=f.data.length:f.data&&typeof f.data=="object"&&Array.isArray(f.data.monitors)&&(d=f.data.monitors.length)}let p=0;if(r){const f=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(f.data&&typeof f.data=="object"){const C=f.data;p=Object.values(C).reduce((S,s)=>Array.isArray(s)?S+s.reduce((x,v)=>x+(Array.isArray(v.hooks)?v.hooks.length:0),0):S,0)}}const[g,c,L]=await Promise.all([F(`${t.path}/agents`,{filesOnly:!0}),F(`${t.path}/bin`,{filesOnly:!0}),F(`${t.path}/skills`,{dirsOnly:!0})]),w=g.filter(f=>f.endsWith(".md")).length,$=c.length,D=L.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:p,agents:w,skills:D,binCount:$,hasMcp:h}}async function F(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{ye as Plugins};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-CjbO01Sg.js","./index-Cd98Q1lD.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./index-CKH5Uxik.css"])))=>i.map(i=>d[i]);
2
+ import{ak as e,az as m,m as k,r as U,aX as Y,aS as Z,v as V,aN as W,a as ee}from"./index-Cd98Q1lD.js";import{P as q}from"./ProvenanceBadge-BFczzI1B.js";import{e as te}from"./Library-7akfgy67.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as ne}from"./monaco-editor-BW5C4Iv1.js";import{M as se}from"./MarkdownEditor-DDesiqet.js";function ie({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:h}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:h??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(p=>e.jsx("td",{className:`px-3 py-1 ${p.className??""}`,children:p.render(l)},p.key))},r)})})]})}async function ae(t,n,o){var p,g;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const h=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!h)return null;const l=(g=(p=i.plugins[h])==null?void 0:p[0])==null?void 0:g.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function le(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,h=await window.api.config.readText(i);if(!h.exists)continue;const l=G(h.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function re(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const h=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${h}\\b`,`\`${h}\``];if(i.id.length>=4&&l.push(`\\b${h}\\b`),!l.some(p=>new RegExp(p,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const oe=m.lazy(()=>ne(()=>import("./SkillReferenceGraph-CjbO01Sg.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function ce({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var g;const[i,h]=m.useState(a??((g=n[0])==null?void 0:g.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=m.useMemo(()=>re(n),[n]),[d,p]=m.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>p("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>p("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(k,{title:"no skills in this plugin"}):d==="graph"?e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(oe,{skills:n,edges:r,selectedId:i,onSelect:h})}):e.jsx(U,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>h(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(se,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(k,{title:"select a skill"})})})]})}const X=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function de(){const t=Y(),[n,o]=m.useState([]),[a,i]=m.useState(!0),[h,l]=m.useState(null),[r,d]=m.useState("installed"),[p,g]=m.useState(null),[c,L]=m.useState(new Set);m.useEffect(()=>{var x,v;let s=!1;return(v=(x=window.api.app).seedStatus)==null||v.call(x).then(j=>{s||g(j)}).catch(()=>{}),()=>{s=!0}},[]);const w=m.useRef(0),$=m.useCallback(async()=>{var v;const s=++w.current;if(!t)return;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const M=j.data;for(const[O,u]of Object.entries(M.plugins??{})){if(!Array.isArray(u))continue;const y=O.split("@")[0],I=O.split("@")[1];for(const b of u){if(!(b!=null&&b.installPath))continue;const R={name:y,path:b.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},P=await pe(R);(v=P.manifest)!=null&&v.version||(P.manifest={...P.manifest??{},version:b.version}),P.marketplace=I,x.push(P)}}}}catch{}w.current===s&&(x.sort((j,M)=>j.name.localeCompare(M.name)),o(x),i(!1))},[t]);m.useEffect(()=>{$()},[$]),m.useEffect(()=>()=>{w.current+=1},[]),Z(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],$);const D=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(q,{interactive:!1,input:X(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],f=m.useMemo(()=>p?Object.keys(p).filter(s=>p[s].status==="exhausted"&&!c.has(s)):[],[p,c]),C=f.length>0?e.jsx(he,{seeders:f,seedStatus:p,onDismiss:s=>L(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(V,{toolbar:e.jsx(z,{active:r,onChange:d}),children:[C,e.jsx(te,{})]});const S=h?n.find(s=>s.path===h)??null:null;return e.jsxs(V,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(z,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[C,a?e.jsx(k,{title:"scanning plugins…"}):S?e.jsx(me,{row:S,home:t,onBack:()=>l(null)},S.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ie,{columns:D,rows:n,getKey:s=>s.path,activeKey:h,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const ye=m.memo(de),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function he({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[K[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${K[i]} warning`,children:"✕"})]},i))})}function z({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function me({row:t,home:n,onBack:o}){var x,v,j,M,O;const[a,i]=m.useState([]),[h,l]=m.useState([]),[r,d]=m.useState([]),[p,g]=m.useState([]),[c,L]=m.useState("skills"),[w,$]=m.useState(null),[D,f]=m.useState(!0);m.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{f(!0);try{const[y,I,b,R]=await Promise.all([ae(t.name,t.path,n),F(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),F(`${t.path}/bin`,{filesOnly:!0})]),P=y?await le(y):[],T=I.filter(N=>N.endsWith(".md")),Q=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),H=[];T.forEach((N,B)=>{const A=Q[B];if(!A.exists)return;const _=G(A.text);H.push({id:N,name:_.name??N.replace(/\.md$/,""),description:_.description})});const J=[];if(b&&b.exists&&!b.parseError&&b.data&&typeof b.data=="object"){const N=b.data.mcpServers;if(N&&typeof N=="object")for(const[B,A]of Object.entries(N)){const _=A&&typeof A=="object"?A.command:void 0;J.push({id:B,name:B,description:typeof _=="string"?_:null})}}if(u)return;i(P),l(H),d(J),g(R),L(P.length>0?"skills":H.length>0?"agents":J.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(y){if(u)return;W.error(`Failed to load plugin contents: ${y instanceof Error?y.message:String(y)}`),i([]),l([]),d([]),g([])}finally{u||f(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const C=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:h.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],S=(x=t.manifest)!=null&&x.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,s=async u=>{const y=await window.api.shell.open({as:"external",url:u});y.ok||W.error(y.error??`Failed to open ${u}`)};return w?e.jsx(ce,{pluginName:((v=t.manifest)==null?void 0:v.name)??t.name,skills:a,initialSelectedId:w.id,onBack:()=>$(null)},w.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((j=t.manifest)==null?void 0:j.name)??t.name}),(M=t.manifest)!=null&&M.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(O=t.manifest)!=null&&O.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(q,{input:X(t)}),t.hasMcp?e.jsx(ee,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[S?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),S]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>s(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:C.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>L(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:D?e.jsx(k,{title:"scanning…"}):e.jsx(fe,{active:c,row:t,skills:a,agents:h,mcpServers:r,files:p,onOpenSkill:$})})]})]})}function fe({active:t,row:n,skills:o,agents:a,mcpServers:i,files:h,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(E,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(E,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(E,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(E,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(E,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(E,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(k,{title:"no components"}):h.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:h.map((r,d)=>e.jsx(E,{n:d+1,name:r,description:null},r))})}function E({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function pe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const f=await window.api.config.readJson(n);f.exists&&!f.parseError&&f.data&&typeof f.data=="object"&&(a=f.data)}const[i,h,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const f=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(f.data)?d=f.data.length:f.data&&typeof f.data=="object"&&Array.isArray(f.data.monitors)&&(d=f.data.monitors.length)}let p=0;if(r){const f=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(f.data&&typeof f.data=="object"){const C=f.data;p=Object.values(C).reduce((S,s)=>Array.isArray(s)?S+s.reduce((x,v)=>x+(Array.isArray(v.hooks)?v.hooks.length:0),0):S,0)}}const[g,c,L]=await Promise.all([F(`${t.path}/agents`,{filesOnly:!0}),F(`${t.path}/bin`,{filesOnly:!0}),F(`${t.path}/skills`,{dirsOnly:!0})]),w=g.filter(f=>f.endsWith(".md")).length,$=c.length,D=L.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:p,agents:w,skills:D,binCount:$,hasMcp:h}}async function F(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{ye as Plugins};
@@ -1 +1 @@
1
- import{a1 as P,aX as G,az as x,ak as i,Z as R,B as T,a as _}from"./index-XkrLB67D.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library--poVP-d1.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(S.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(S.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),X=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.map(e=>e.command.trim())),q=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),F=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,Q=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function W(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),y=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):z.has(t)?y("third-party skill (catalog)"):null;case"plugin":return J.has(t)?l("official Anthropic plugin (catalog)"):U.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return V.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return X.has(t)||n&&Z.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":Q.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=W(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&q.has(t))return l("built-in Claude Code command");if(F.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?y(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[v,m]=x.useState(!1),w=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!v)return;const s=C=>{w.current&&!w.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[v]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(_,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:w,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),v&&i.jsxs("span",{className:`absolute ${R.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(b,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${T[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(b,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
1
+ import{a1 as P,aX as G,az as x,ak as i,Z as R,B as T,a as _}from"./index-Cd98Q1lD.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-7akfgy67.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(S.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(S.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),X=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.map(e=>e.command.trim())),q=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),F=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,Q=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function W(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),y=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):z.has(t)?y("third-party skill (catalog)"):null;case"plugin":return J.has(t)?l("official Anthropic plugin (catalog)"):U.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return V.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return X.has(t)||n&&Z.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":Q.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=W(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&q.has(t))return l("built-in Claude Code command");if(F.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?y(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[v,m]=x.useState(!1),w=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!v)return;const s=C=>{w.current&&!w.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[v]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(_,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:w,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),v&&i.jsxs("span",{className:`absolute ${R.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(b,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${T[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(b,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
@@ -1 +1 @@
1
- import{ak as e,ae as x}from"./index-XkrLB67D.js";function m({dirty:a,busy:n,parseError:t,lastSavedAt:c,onSave:i,onRevert:l,leading:d}){const s=a&&!n&&!t;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:d}),t&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:t,children:t}),!a&&!t&&c&&e.jsx("span",{className:"text-fg-faint",children:x(c)}),a&&!t&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:l,disabled:!a||n,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:i,disabled:!s,className:`px-2.5 py-0.5 rounded border ${s?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:n?"Saving…":"Save"})]})}export{m as S};
1
+ import{ak as e,ae as x}from"./index-Cd98Q1lD.js";function m({dirty:a,busy:n,parseError:t,lastSavedAt:c,onSave:i,onRevert:l,leading:d}){const s=a&&!n&&!t;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:d}),t&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:t,children:t}),!a&&!t&&c&&e.jsx("span",{className:"text-fg-faint",children:x(c)}),a&&!t&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:l,disabled:!a||n,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:i,disabled:!s,className:`px-2.5 py-0.5 rounded border ${s?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:n?"Saving…":"Save"})]})}export{m as S};
@@ -1,4 +1,4 @@
1
- import{aF as Ce,ar as re,aJ as fs,af as Se,a9 as ie,ad as ee,aN as H,b2 as Oe,b0 as ue,az as f,b9 as hs,a7 as xe,b8 as xs,ak as t,b as Ge,I as ge,L as ft,p as gs,K as he,t as ms,Q as bs,e as ws,U as vs,a$ as Ye,aU as js,a3 as ht,ap as Mt,b7 as $e,G as Le,av as Te,A as Xe,aI as Ze,aa as xt,N as Rt,w as It,o as Et,q as ys,n as et,y as tt,O as Ns,D as ae,g as B,ab as Tt,b3 as ks,ay as Ss,aB as _t,bb as Ot,V as $s,as as gt,aV as mt,m as Ne,x as bt,l as Cs,aL as Ps,W as Ds,u as Lt,aX as As,aR as je,H as Ms,C as Rs,b4 as Is,aA as Es,T as Ts,ba as _s,b5 as wt,aH as Os}from"./index-XkrLB67D.js";import{l as Ls}from"./listSkills-QORduPIk.js";import{T as Fs}from"./Toggle-BxtAFE1i.js";import"./monaco-editor-BW5C4Iv1.js";function qs(e){const s=new Map(e.map(r=>[r.slug,r])),n=new Map,a=new Set,u=[];function o(r){n.set(r,1),u.push(r);const i=s.get(r);for(const d of(i==null?void 0:i.dependsOn)??[]){if(!s.has(d))continue;const l=n.get(d);if(l===1){const c=u.indexOf(d);for(let p=c;p<u.length;p++)a.add(u[p])}else l===void 0&&o(d)}u.pop(),n.set(r,2)}for(const r of e)n.has(r.slug)||o(r.slug);return a}function Bs(e,s){return(e.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function Hs(e,s,n){const a=new Set(e.map(l=>l.slug)),u=new Set;for(const l of e)for(const c of l.dependsOn??[])a.has(c)&&u.add(c);const o=new Map,r=[];for(const l of e){const c=n.has(l.slug)?void 0:(l.dependsOn??[]).find(p=>a.has(p)&&!n.has(p));c?(o.has(c)||o.set(c,[]),o.get(c).push(l)):r.push(l)}const i=(l,c)=>l.slug.localeCompare(c.slug);r.sort(i);for(const l of o.values())l.sort(i);function d(l,c,p){const h=Bs(l,s),w=n.has(l.slug);p.add(l.slug);const x=w?[]:(o.get(l.slug)??[]).filter(m=>!p.has(m.slug)).map(m=>d(m,c+1,p));return p.delete(l.slug),{row:l,depth:c,children:x,blockers:h,blocked:h.some(m=>!m.missing&&m.status!=="completed"),hasNeedsReviewBlocker:h.some(m=>m.needsReview),hasMissingDep:h.some(m=>m.missing),cycle:w,parallelEligible:(l.dependsOn??[]).length===0&&!u.has(l.slug)}}return r.map(l=>d(l,0,new Set))}function Ft(e,s,n){const a=new Map((n??e).map(l=>[l.slug,l])),u=qs(e),o=[],r=new Map,i=new Map;for(const l of e){const c=Ce(l,s),p=c.epicId??"__none__";r.has(p)||(o.push(p),r.set(p,[]),i.set(p,{epicId:c.epicId,label:c.known&&c.label?c.label:c.epicId?`Epic ${c.epicId.slice(0,12)}…`:"No Epic",known:c.known})),r.get(p).push(l)}const d=o.map(l=>{const c=i.get(l),p=r.get(l),h=Hs(p,a,u),w={};for(const x of p){const m=x.status??"unknown";w[m]=(w[m]??0)+1}return{epicId:c.epicId,label:c.label,known:c.known,nodes:h,counts:w,total:p.length}});return d.sort((l,c)=>l.epicId===null?1:c.epicId===null?-1:l.known!==c.known?l.known?-1:1:l.label.localeCompare(c.label)),d}function Fe(e){const s=[],n=a=>{s.push(a);for(const u of a.children)n(u)};for(const a of e)n(a);return s}const Gs=15e4,ze=e=>e==="completed"||e==="skipped",ke=e=>e==="running"||e==="investigating",qt=e=>e==="failed"||e==="needs_review"||e==="quarantined",Us=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Bt(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),u=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(u).padStart(2,"0")}s`:`${u}s`}function Ht(e){if(e<=5e3)return"~now";if(e<6e4)return`~${Math.round(e/1e3)}s`;const s=Math.round(e/6e4);return s<60?`~${s}m`:`~${Math.floor(s/60)}h${String(s%60).padStart(2,"0")}m`}function Gt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Bt(s)}function Vs(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const u=Date.parse(a.finishedAt)-Date.parse(a.startedAt);u>0&&(s+=u,n++)}return n===0?Gs:s/n}function _e(e){const s=re(e);return s===null?1/0:Number(s)}function vt(e,s){const n=_e(e.slug)-_e(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ws(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Qs(e){return e.some(n=>ke(n.status))?"active":e.every(n=>ze(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function zs(e,s,n,a){switch(e){case"done":return`${s.doneCount}/${s.rows.length} done`;case"running":return`${s.runningCount} running · ${n}`;case"held":return`${s.heldCount} held`;case"blocked":return`${s.blockedCount+a} blocked`;default:return`${n} ready`}}function Js(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function Ks(e,s){const n=new Map(e.map(o=>[o.row.slug,o.row.slug])),a=o=>{for(;n.get(o)!==o;)n.set(o,n.get(n.get(o))),o=n.get(o);return o};for(const o of e)for(const r of o.row.dependsOn??[])s.has(r)&&n.set(a(o.row.slug),a(r));const u=new Map;for(const o of e){const r=a(o.row.slug),i=u.get(r);i?i.push(o):u.set(r,[o])}return[...u.values()]}function Ys(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const u=n.get(a.row.planId);u?u.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return Ks(e,s)}function st(e,s){if(e.length===0)return[];const n=s.now??Date.now(),a=s.avgDurationMs??Vs(e),u=Math.max(1,s.concurrency??1),o=new Map(e.map(c=>[c.slug,c])),r=c=>c.status==="pending"&&(c.dependsOn??[]).every(p=>o.get(p)===void 0||o.get(p).status==="completed"),i=new Map;e.filter(r).sort(vt).forEach((c,p)=>i.set(c.slug,p));const d=Ft(e,s.sessions,e),l=[];for(const c of d){const p=Fe(c.nodes),h=new Set(p.map(m=>m.row.slug)),w=new Map(p.map(m=>[m.row.slug,m])),x=[];for(const m of Ys(p,h)){const j=new Set(m.map($=>$.row.slug)),_=new Map,N=new Set,I=$=>{const S=w.get($);return(S.row.dependsOn??[]).filter(q=>j.has(q)&&!(S.cycle&&w.get(q).cycle))},g=$=>{const S=_.get($);if(S!==void 0)return S;if(N.has($))return 0;N.add($);let q=0;for(const L of I($))q=Math.max(q,g(L));return N.delete($),_.set($,q+1),q+1};for(const $ of m)g($.row.slug);const A=m.map($=>{const S=$.row,q=(S.dependsOn??[]).filter(L=>h.has(L));return{slug:S.slug,title:S.title,status:S.status,stage:_.get(S.slug),prdNumber:re(S.slug),rowKind:"dep",rowTrailing:"",cycle:$.cycle,estimateMinutes:S.estimateMinutes??null,deps:q,crossEpicDeps:(S.dependsOn??[]).filter(L=>!h.has(L)),blockers:$.blockers,job:S}});A.sort(vt);const k=A.reduce(($,S)=>Math.max($,S.stage),0),P=new Map;for(const $ of A){const S=$.job,q=w.get($.slug),L=S.status;let D;if(ze(L)){const E=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;D={kind:"done",trailing:E>0?Bt(E):"",held:!1,blocked:!1}}else if(ke(L)){const E=S.startedAt?Math.max(0,n-Date.parse(S.startedAt)):null;D={kind:"running",trailing:E===null?"":Gt(S,E),held:!1,blocked:!1}}else if(L==="failed")D={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(L==="needs_review")D={kind:"review",trailing:"review",held:!1,blocked:!1};else if(L==="quarantined")D={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const E=q.blockers.filter(T=>!T.missing&&T.status!=="completed");if(E.length>0){const T=E.some(Y=>Us(Y.status)),V=E[0].slug;D={kind:"dep",trailing:`←${re(V)??V}`,held:!T,blocked:T}}else if(S.heldReason)D={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const T=Ws(S),V=i.get(S.slug)??0;D=T>0?{kind:"retry",trailing:`${T} ${T===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:Ht(V*a/u),held:!1,blocked:!1}}}P.set($.slug,D)}const G=[];for(let $=1;$<=k;$++){const S=A.filter(b=>b.stage===$),q=S.find(b=>{const y=P.get(b.slug).kind;return b.status==="pending"&&(y==="eta"||y==="retry")});if(q){const b=P.get(q.slug);b.kind="next",b.trailing="next"}let L=0,D=0,E=0,T=0,V=0,Y=0;for(const b of S){const y=P.get(b.slug);b.rowKind=y.kind,b.rowTrailing=y.trailing,ze(b.status)?L++:ke(b.status)?D++:b.status==="pending"?(V++,y.held&&E++,y.blocked&&T++):qt(b.status)&&Y++}const J=L===S.length?"done":D>0?"running":T+Y>0?"blocked":E>0?"held":"pending",ne={n:$,rows:S,doneCount:L,runningCount:D,heldCount:E,blockedCount:T};G.push({...ne,state:J,summary:zs(J,ne,V,Y)})}let z=0;for(const $ of A){const S=$.estimateMinutes?$.estimateMinutes*6e4:a;if($.status==="pending")z+=S;else if(ke($.status)){const q=$.job.startedAt?Math.max(0,n-Date.parse($.job.startedAt)):0;z+=Math.max(0,S-q)}}const Q=A.reduce(($,S)=>Math.min($,_e(S.slug)),1/0),Z=A.reduce(($,S)=>Math.max($,_e(S.slug)),-1/0);x.push({epicId:c.epicId,waveIndex:0,index:0,label:c.known?fs(c.label).title:c.label,status:Qs(A),prdCount:A.length,stageCount:k,doneCount:G.reduce(($,S)=>$+S.doneCount,0),runningCount:G.reduce(($,S)=>$+S.runningCount,0),heldCount:G.reduce(($,S)=>$+S.heldCount,0),blockedCount:G.reduce(($,S)=>$+S.blockedCount,0),etaMs:z/u,stages:G,_firstNum:Q,_lastNum:Z,_firstSlug:A[0].slug})}x.sort(Js),x.forEach((m,j)=>{m.waveIndex=j+1,x.length>1&&(m.label=`${m.label} · plan ${j+1}/${x.length}`),l.push(m)})}return l.sort((c,p)=>{if(c._lastNum!==p._lastNum)return c._lastNum>p._lastNum?-1:1;const h=(c.epicId??"").localeCompare(p.epicId??"");return h!==0?h:c.waveIndex-p.waveIndex}),l.map(({_firstNum:c,_lastNum:p,_firstSlug:h,...w},x)=>({...w,index:x+1}))}function Xs(e,s=Date.now()){const n=new Map(e.map(h=>[h.slug,h])),a=new Date(s).toDateString();let u=0,o=0,r=0,i=0,d=0,l=0,c=0;for(const h of e)h.status==="pending"?(o++,(h.dependsOn??[]).every(x=>n.get(x)===void 0||n.get(x).status==="completed")&&u++):ke(h.status)?c++:h.status==="failed"?r++:h.status==="needs_review"?i++:h.status==="quarantined"?d++:h.status==="completed"&&h.finishedAt&&new Date(Date.parse(h.finishedAt)).toDateString()===a&&l++;let p=null;if(r+i+d>0){for(const h of st(e,{sessions:{},now:s}))for(const w of h.stages)if(w.rows.some(x=>qt(x.status))){(p===null||w.n<p)&&(p=w.n);break}}return{readyNow:u,totalQueued:o,heldByDeps:o-u,needsYou:r+i+d,needsYouStage:p,failedCount:r,needsReviewCount:i,doneToday:l,inFlight:c}}function Zs(e){const s=new Map;for(const d of e.stages)for(const l of d.rows)s.set(l.slug,l);const n=d=>{var l;return((l=s.get(d))==null?void 0:l.cycle)===!0},a=new Map,u=new Set,o=(d,l)=>d.chain.length!==l.chain.length?d.chain.length>l.chain.length:d.est!==l.est?d.est>l.est:d.chain.join("\0")<l.chain.join("\0"),r=d=>{const l=a.get(d);if(l)return l;const c=s.get(d),p=c.estimateMinutes??0;if(u.has(d))return{chain:[d],est:p};u.add(d);let h=null;for(const x of c.deps){if(!s.has(x)||c.cycle&&n(x))continue;const m=r(x);(!h||o(m,h))&&(h=m)}u.delete(d);const w=h?{chain:[...h.chain,d],est:h.est+p}:{chain:[d],est:p};return a.set(d,w),w};let i=null;for(const d of s.keys()){const l=r(d);(!i||o(l,i))&&(i=l)}return i?i.chain:[]}const en=300*6e4,tn={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function sn(e){return tn[e]??e.replace(/_/g," ")}function Ut({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:u,jobs:o,paused:r,nextReset:i,utilization:d,utilizationWindow:l,effectiveConcurrency:c}=e;let p=0,h=0;for(const N of o)N.status==="pending"?p++:N.status==="completed"&&h++;const w=a.length,x=p+w,m=(c==null?void 0:c.cap)??5;if(w>0){const N=a.reduce((P,G)=>(P.startedAt??"")<(G.startedAt??"")?P:G),I=N.startedAt?s-Date.parse(N.startedAt):0,g=h+w,A=h+x,k=w>1?` · ${w}/${m} parallel`:"";return{kind:"running",line1:`Running ${g}/${A}${k} · ${Se(I)}`,line2:w===1?N.title:a.map(P=>P.title).join(", "),tooltip:a.map(P=>`${P.slug} (g${P.parallelGroup})`).join("; ")}}if(r){const N=r.resumeAt?Date.parse(r.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[r.reason]??`Paused — ${r.reason}`,line2:r.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":N!==null&&N>0?`auto-resume ${ie(Date.parse(r.resumeAt))} (in ${ee(N)})`:r.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:r.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};const j=u.firePolicy??"when-available";if(j==="manual")return{kind:"manual",line1:`Manual · ${p} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(H.fromOutcome).catch(()=>H.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(j==="on-reset"){if(!i)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const N=Date.parse(i)+u.offsetMinutes*6e4,I=N-s;return{kind:"on-reset",line1:`On-reset · ${p} pending`,line2:I>0?`fires ${ie(N)} (in ${ee(I)})`:"firing now…"}}const _=u.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${p} pending`,line2:"checking token availability…"};if(d>=_){const N=i?Date.parse(i)-s:null,I=l?sn(l):null,g=N===null||Number.isNaN(N)||N>en,A=N&&N>0?`resets ${ie(Date.parse(i))} (in ${ee(N)})`:null;let k;return g?k=`${I??"binding"} window — long hold${A?`, ${A}`:", reset time unknown"}`:k=A?`${I?`${I} window `:""}next ${A}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${_}%)`,line2:k}}return{kind:"auto-soon",line1:`Auto · ${p} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const nn=15e3,an=new Set(["failed","needs_review","quarantined"]);function jt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>an.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function rn(e,s){var n;switch(e.kind){case"paused":return`paused: scheduler is paused (${e.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${e.agentType} jobs can't launch${(n=e.block)!=null&&n.kind?` (${e.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${ee(s)}`:"";return`saturated: ${e.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=e.blockedChains.length;return`blocked: ${e.pending} pending, ${e.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${e.idleMs!=null?ee(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function ln(e){const[s,n]=f.useState(null),a=Ye(),u=js(),o=a&&u;return f.useEffect(()=>{if(!o)return;let r=!0,i=!1,d=!1;const l=()=>{i||(i=!0,window.api.schedule.queueHealth(e).then(p=>{i=!1,d=!1,r&&n(p)},p=>{i=!1,!d&&(d=!0,H.error(`Queue health refresh failed: ${p instanceof Error?p.message:String(p)}`))}))};l();const c=setInterval(l,nn);return()=>{r=!1,clearInterval(c)}},[e,o]),s}const on={running:{dot:"bg-sage",text:"text-sage-dark"},paused:{dot:"bg-amber-500",text:"text-amber-600"},idle:{dot:"bg-fg-faint",text:"text-fg-faint"}};function dn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function cn(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}const Ue="px-2.5 py-1.5 rounded border border-line text-[12.5px] font-medium text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap";function un(e,s,n){if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const a=new Date(s).getTime()-n;return a>0?`Paused for rate limit — resumes in ${ee(a)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return e==="network"?"Paused: billing endpoint unreachable for 30+ min.":e==="manual"?"Scheduler paused manually — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${e})`}function pn({now:e}){const s=Oe(c=>c.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),u=Object.entries(s.launchMitigations??{}),o=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",r="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",i="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",l="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${r} ${o?i:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:un(n.reason,n.resumeAt,e)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:l,children:"Resume"})]}),a.map(([c,p])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${r} ${i}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:c})," jobs are failing before any work starts",p.httpStatus?` (HTTP ${p.httpStatus}, ${p.kind})`:` (${p.kind})`,p.exhausted?" — held until the Claude CLI version changes or you press Retry now.":p.until?` — next automatic probe ${new Date(p.until).getTime()>e?`in ${ee(new Date(p.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:p.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:p.message,children:[p.attempts," failed probe",p.attempts===1?"":"s",p.claudeVersion?` · CLI ${p.claudeVersion}`:"",p.lastSlug?` · last: ${p.lastSlug}`:""," · ",p.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:l,children:"Retry now"})]},`launch-block-${c}`)),u.map(([c,p])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${r} ${d}`,children:t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[t.jsx("span",{className:"font-mono",children:c})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(p.env).map(([h,w])=>`${h}=${w}`).join(" ")}),")",p.claudeVersion?` since CLI ${p.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:p.hint})]})},`launch-mitigation-${c}`))]})}function fn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:u,planMode:o,onPlanMode:r,planToolsRef:i}){const d=Oe(C=>C.snapshot),l=ue(C=>C.sessions),c=ln(e),[p,h]=f.useState(()=>Date.now()),[w,x]=f.useState("—");f.useEffect(()=>{const C=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(C)},[]),f.useEffect(()=>{let C=!0;return hs(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(O=>{if(!C)return;const F=O.totals,K=F.inputTokens+F.outputTokens+F.cacheReadTokens+F.cacheCreationTokens;x(`$${F.estimatedCostUsd.toFixed(2)} · ${cn(K)} tok`)}).catch(()=>{}),()=>{C=!1}},[]);const m=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(C=>!e||C.cwd===e),[d,e]),j=f.useMemo(()=>Xs(m,p),[m,p]),_=f.useMemo(()=>{const C=st(m,{sessions:l,now:p}),O=F=>C.filter(K=>K.status===F).length;return{active:O("active"),queued:O("queued"),draft:O("draft")}},[m,l,p]),N=f.useMemo(()=>{const C=new Date(p).toDateString(),O=[];for(const F of m)if(F.status==="completed"&&F.startedAt&&F.finishedAt&&new Date(Date.parse(F.finishedAt)).toDateString()===C){const K=Date.parse(F.finishedAt)-Date.parse(F.startedAt);K>0&&O.push(K)}return O.length?Math.round(O.reduce((F,K)=>F+K,0)/O.length/6e4):null},[m,p]);if(!d)return null;const I=c&&!c.unknown?c.verdict??null:null,g=c&&!c.unknown?c.slots??null:null,A=d.paused,k=dn((I==null?void 0:I.kind)??null,!!A,j.inFlight),P=on[k],G=m.filter(C=>C.status==="pending").length,z=m.filter(C=>C.status==="running").length,Q=Ut({snap:{...d,jobs:m},now:p,avgDurationMs:0,runningJobs:m.filter(C=>C.status==="running")}),Z=c!=null&&c.unknown?`Queue health: unknown — ${c.reason??"state unavailable"}`:I?rn(I,(c==null?void 0:c.oldestRunningAgeMs)??null):"queue health loading…",$=xe(d.lastRunAt?Date.parse(d.lastRunAt):null,p),S=c!=null&&c.lastDispatchAttemptAt?xe(Date.parse(c.lastDispatchAttemptAt),p):"never",q=[Z,Q.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(c==null?void 0:c.oldestRunningAgeMs)!=null?`oldest running ${ee(c.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${$} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${S} (advances on every driver evaluation)`].filter(Boolean).join(`
1
+ import{aF as Ce,ar as re,aJ as fs,af as Se,a9 as ie,ad as ee,aN as H,b2 as Oe,b0 as ue,az as f,b9 as hs,a7 as xe,b8 as xs,ak as t,b as Ge,I as ge,L as ft,p as gs,K as he,t as ms,Q as bs,e as ws,U as vs,a$ as Ye,aU as js,a3 as ht,ap as Mt,b7 as $e,G as Le,av as Te,A as Xe,aI as Ze,aa as xt,N as Rt,w as It,o as Et,q as ys,n as et,y as tt,O as Ns,D as ae,g as B,ab as Tt,b3 as ks,ay as Ss,aB as _t,bb as Ot,V as $s,as as gt,aV as mt,m as Ne,x as bt,l as Cs,aL as Ps,W as Ds,u as Lt,aX as As,aR as je,H as Ms,C as Rs,b4 as Is,aA as Es,T as Ts,ba as _s,b5 as wt,aH as Os}from"./index-Cd98Q1lD.js";import{l as Ls}from"./listSkills-QORduPIk.js";import{T as Fs}from"./Toggle-BbW4nGGf.js";import"./monaco-editor-BW5C4Iv1.js";function qs(e){const s=new Map(e.map(r=>[r.slug,r])),n=new Map,a=new Set,u=[];function o(r){n.set(r,1),u.push(r);const i=s.get(r);for(const d of(i==null?void 0:i.dependsOn)??[]){if(!s.has(d))continue;const l=n.get(d);if(l===1){const c=u.indexOf(d);for(let p=c;p<u.length;p++)a.add(u[p])}else l===void 0&&o(d)}u.pop(),n.set(r,2)}for(const r of e)n.has(r.slug)||o(r.slug);return a}function Bs(e,s){return(e.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function Hs(e,s,n){const a=new Set(e.map(l=>l.slug)),u=new Set;for(const l of e)for(const c of l.dependsOn??[])a.has(c)&&u.add(c);const o=new Map,r=[];for(const l of e){const c=n.has(l.slug)?void 0:(l.dependsOn??[]).find(p=>a.has(p)&&!n.has(p));c?(o.has(c)||o.set(c,[]),o.get(c).push(l)):r.push(l)}const i=(l,c)=>l.slug.localeCompare(c.slug);r.sort(i);for(const l of o.values())l.sort(i);function d(l,c,p){const h=Bs(l,s),w=n.has(l.slug);p.add(l.slug);const x=w?[]:(o.get(l.slug)??[]).filter(m=>!p.has(m.slug)).map(m=>d(m,c+1,p));return p.delete(l.slug),{row:l,depth:c,children:x,blockers:h,blocked:h.some(m=>!m.missing&&m.status!=="completed"),hasNeedsReviewBlocker:h.some(m=>m.needsReview),hasMissingDep:h.some(m=>m.missing),cycle:w,parallelEligible:(l.dependsOn??[]).length===0&&!u.has(l.slug)}}return r.map(l=>d(l,0,new Set))}function Ft(e,s,n){const a=new Map((n??e).map(l=>[l.slug,l])),u=qs(e),o=[],r=new Map,i=new Map;for(const l of e){const c=Ce(l,s),p=c.epicId??"__none__";r.has(p)||(o.push(p),r.set(p,[]),i.set(p,{epicId:c.epicId,label:c.known&&c.label?c.label:c.epicId?`Epic ${c.epicId.slice(0,12)}…`:"No Epic",known:c.known})),r.get(p).push(l)}const d=o.map(l=>{const c=i.get(l),p=r.get(l),h=Hs(p,a,u),w={};for(const x of p){const m=x.status??"unknown";w[m]=(w[m]??0)+1}return{epicId:c.epicId,label:c.label,known:c.known,nodes:h,counts:w,total:p.length}});return d.sort((l,c)=>l.epicId===null?1:c.epicId===null?-1:l.known!==c.known?l.known?-1:1:l.label.localeCompare(c.label)),d}function Fe(e){const s=[],n=a=>{s.push(a);for(const u of a.children)n(u)};for(const a of e)n(a);return s}const Gs=15e4,ze=e=>e==="completed"||e==="skipped",ke=e=>e==="running"||e==="investigating",qt=e=>e==="failed"||e==="needs_review"||e==="quarantined",Us=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Bt(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),u=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(u).padStart(2,"0")}s`:`${u}s`}function Ht(e){if(e<=5e3)return"~now";if(e<6e4)return`~${Math.round(e/1e3)}s`;const s=Math.round(e/6e4);return s<60?`~${s}m`:`~${Math.floor(s/60)}h${String(s%60).padStart(2,"0")}m`}function Gt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Bt(s)}function Vs(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const u=Date.parse(a.finishedAt)-Date.parse(a.startedAt);u>0&&(s+=u,n++)}return n===0?Gs:s/n}function _e(e){const s=re(e);return s===null?1/0:Number(s)}function vt(e,s){const n=_e(e.slug)-_e(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ws(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Qs(e){return e.some(n=>ke(n.status))?"active":e.every(n=>ze(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function zs(e,s,n,a){switch(e){case"done":return`${s.doneCount}/${s.rows.length} done`;case"running":return`${s.runningCount} running · ${n}`;case"held":return`${s.heldCount} held`;case"blocked":return`${s.blockedCount+a} blocked`;default:return`${n} ready`}}function Js(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function Ks(e,s){const n=new Map(e.map(o=>[o.row.slug,o.row.slug])),a=o=>{for(;n.get(o)!==o;)n.set(o,n.get(n.get(o))),o=n.get(o);return o};for(const o of e)for(const r of o.row.dependsOn??[])s.has(r)&&n.set(a(o.row.slug),a(r));const u=new Map;for(const o of e){const r=a(o.row.slug),i=u.get(r);i?i.push(o):u.set(r,[o])}return[...u.values()]}function Ys(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const u=n.get(a.row.planId);u?u.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return Ks(e,s)}function st(e,s){if(e.length===0)return[];const n=s.now??Date.now(),a=s.avgDurationMs??Vs(e),u=Math.max(1,s.concurrency??1),o=new Map(e.map(c=>[c.slug,c])),r=c=>c.status==="pending"&&(c.dependsOn??[]).every(p=>o.get(p)===void 0||o.get(p).status==="completed"),i=new Map;e.filter(r).sort(vt).forEach((c,p)=>i.set(c.slug,p));const d=Ft(e,s.sessions,e),l=[];for(const c of d){const p=Fe(c.nodes),h=new Set(p.map(m=>m.row.slug)),w=new Map(p.map(m=>[m.row.slug,m])),x=[];for(const m of Ys(p,h)){const j=new Set(m.map($=>$.row.slug)),_=new Map,N=new Set,I=$=>{const S=w.get($);return(S.row.dependsOn??[]).filter(q=>j.has(q)&&!(S.cycle&&w.get(q).cycle))},g=$=>{const S=_.get($);if(S!==void 0)return S;if(N.has($))return 0;N.add($);let q=0;for(const L of I($))q=Math.max(q,g(L));return N.delete($),_.set($,q+1),q+1};for(const $ of m)g($.row.slug);const A=m.map($=>{const S=$.row,q=(S.dependsOn??[]).filter(L=>h.has(L));return{slug:S.slug,title:S.title,status:S.status,stage:_.get(S.slug),prdNumber:re(S.slug),rowKind:"dep",rowTrailing:"",cycle:$.cycle,estimateMinutes:S.estimateMinutes??null,deps:q,crossEpicDeps:(S.dependsOn??[]).filter(L=>!h.has(L)),blockers:$.blockers,job:S}});A.sort(vt);const k=A.reduce(($,S)=>Math.max($,S.stage),0),P=new Map;for(const $ of A){const S=$.job,q=w.get($.slug),L=S.status;let D;if(ze(L)){const E=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;D={kind:"done",trailing:E>0?Bt(E):"",held:!1,blocked:!1}}else if(ke(L)){const E=S.startedAt?Math.max(0,n-Date.parse(S.startedAt)):null;D={kind:"running",trailing:E===null?"":Gt(S,E),held:!1,blocked:!1}}else if(L==="failed")D={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(L==="needs_review")D={kind:"review",trailing:"review",held:!1,blocked:!1};else if(L==="quarantined")D={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const E=q.blockers.filter(T=>!T.missing&&T.status!=="completed");if(E.length>0){const T=E.some(Y=>Us(Y.status)),V=E[0].slug;D={kind:"dep",trailing:`←${re(V)??V}`,held:!T,blocked:T}}else if(S.heldReason)D={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const T=Ws(S),V=i.get(S.slug)??0;D=T>0?{kind:"retry",trailing:`${T} ${T===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:Ht(V*a/u),held:!1,blocked:!1}}}P.set($.slug,D)}const G=[];for(let $=1;$<=k;$++){const S=A.filter(b=>b.stage===$),q=S.find(b=>{const y=P.get(b.slug).kind;return b.status==="pending"&&(y==="eta"||y==="retry")});if(q){const b=P.get(q.slug);b.kind="next",b.trailing="next"}let L=0,D=0,E=0,T=0,V=0,Y=0;for(const b of S){const y=P.get(b.slug);b.rowKind=y.kind,b.rowTrailing=y.trailing,ze(b.status)?L++:ke(b.status)?D++:b.status==="pending"?(V++,y.held&&E++,y.blocked&&T++):qt(b.status)&&Y++}const J=L===S.length?"done":D>0?"running":T+Y>0?"blocked":E>0?"held":"pending",ne={n:$,rows:S,doneCount:L,runningCount:D,heldCount:E,blockedCount:T};G.push({...ne,state:J,summary:zs(J,ne,V,Y)})}let z=0;for(const $ of A){const S=$.estimateMinutes?$.estimateMinutes*6e4:a;if($.status==="pending")z+=S;else if(ke($.status)){const q=$.job.startedAt?Math.max(0,n-Date.parse($.job.startedAt)):0;z+=Math.max(0,S-q)}}const Q=A.reduce(($,S)=>Math.min($,_e(S.slug)),1/0),Z=A.reduce(($,S)=>Math.max($,_e(S.slug)),-1/0);x.push({epicId:c.epicId,waveIndex:0,index:0,label:c.known?fs(c.label).title:c.label,status:Qs(A),prdCount:A.length,stageCount:k,doneCount:G.reduce(($,S)=>$+S.doneCount,0),runningCount:G.reduce(($,S)=>$+S.runningCount,0),heldCount:G.reduce(($,S)=>$+S.heldCount,0),blockedCount:G.reduce(($,S)=>$+S.blockedCount,0),etaMs:z/u,stages:G,_firstNum:Q,_lastNum:Z,_firstSlug:A[0].slug})}x.sort(Js),x.forEach((m,j)=>{m.waveIndex=j+1,x.length>1&&(m.label=`${m.label} · plan ${j+1}/${x.length}`),l.push(m)})}return l.sort((c,p)=>{if(c._lastNum!==p._lastNum)return c._lastNum>p._lastNum?-1:1;const h=(c.epicId??"").localeCompare(p.epicId??"");return h!==0?h:c.waveIndex-p.waveIndex}),l.map(({_firstNum:c,_lastNum:p,_firstSlug:h,...w},x)=>({...w,index:x+1}))}function Xs(e,s=Date.now()){const n=new Map(e.map(h=>[h.slug,h])),a=new Date(s).toDateString();let u=0,o=0,r=0,i=0,d=0,l=0,c=0;for(const h of e)h.status==="pending"?(o++,(h.dependsOn??[]).every(x=>n.get(x)===void 0||n.get(x).status==="completed")&&u++):ke(h.status)?c++:h.status==="failed"?r++:h.status==="needs_review"?i++:h.status==="quarantined"?d++:h.status==="completed"&&h.finishedAt&&new Date(Date.parse(h.finishedAt)).toDateString()===a&&l++;let p=null;if(r+i+d>0){for(const h of st(e,{sessions:{},now:s}))for(const w of h.stages)if(w.rows.some(x=>qt(x.status))){(p===null||w.n<p)&&(p=w.n);break}}return{readyNow:u,totalQueued:o,heldByDeps:o-u,needsYou:r+i+d,needsYouStage:p,failedCount:r,needsReviewCount:i,doneToday:l,inFlight:c}}function Zs(e){const s=new Map;for(const d of e.stages)for(const l of d.rows)s.set(l.slug,l);const n=d=>{var l;return((l=s.get(d))==null?void 0:l.cycle)===!0},a=new Map,u=new Set,o=(d,l)=>d.chain.length!==l.chain.length?d.chain.length>l.chain.length:d.est!==l.est?d.est>l.est:d.chain.join("\0")<l.chain.join("\0"),r=d=>{const l=a.get(d);if(l)return l;const c=s.get(d),p=c.estimateMinutes??0;if(u.has(d))return{chain:[d],est:p};u.add(d);let h=null;for(const x of c.deps){if(!s.has(x)||c.cycle&&n(x))continue;const m=r(x);(!h||o(m,h))&&(h=m)}u.delete(d);const w=h?{chain:[...h.chain,d],est:h.est+p}:{chain:[d],est:p};return a.set(d,w),w};let i=null;for(const d of s.keys()){const l=r(d);(!i||o(l,i))&&(i=l)}return i?i.chain:[]}const en=300*6e4,tn={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function sn(e){return tn[e]??e.replace(/_/g," ")}function Ut({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:u,jobs:o,paused:r,nextReset:i,utilization:d,utilizationWindow:l,effectiveConcurrency:c}=e;let p=0,h=0;for(const N of o)N.status==="pending"?p++:N.status==="completed"&&h++;const w=a.length,x=p+w,m=(c==null?void 0:c.cap)??5;if(w>0){const N=a.reduce((P,G)=>(P.startedAt??"")<(G.startedAt??"")?P:G),I=N.startedAt?s-Date.parse(N.startedAt):0,g=h+w,A=h+x,k=w>1?` · ${w}/${m} parallel`:"";return{kind:"running",line1:`Running ${g}/${A}${k} · ${Se(I)}`,line2:w===1?N.title:a.map(P=>P.title).join(", "),tooltip:a.map(P=>`${P.slug} (g${P.parallelGroup})`).join("; ")}}if(r){const N=r.resumeAt?Date.parse(r.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[r.reason]??`Paused — ${r.reason}`,line2:r.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":N!==null&&N>0?`auto-resume ${ie(Date.parse(r.resumeAt))} (in ${ee(N)})`:r.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:r.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};const j=u.firePolicy??"when-available";if(j==="manual")return{kind:"manual",line1:`Manual · ${p} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(H.fromOutcome).catch(()=>H.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(j==="on-reset"){if(!i)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const N=Date.parse(i)+u.offsetMinutes*6e4,I=N-s;return{kind:"on-reset",line1:`On-reset · ${p} pending`,line2:I>0?`fires ${ie(N)} (in ${ee(I)})`:"firing now…"}}const _=u.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${p} pending`,line2:"checking token availability…"};if(d>=_){const N=i?Date.parse(i)-s:null,I=l?sn(l):null,g=N===null||Number.isNaN(N)||N>en,A=N&&N>0?`resets ${ie(Date.parse(i))} (in ${ee(N)})`:null;let k;return g?k=`${I??"binding"} window — long hold${A?`, ${A}`:", reset time unknown"}`:k=A?`${I?`${I} window `:""}next ${A}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${_}%)`,line2:k}}return{kind:"auto-soon",line1:`Auto · ${p} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const nn=15e3,an=new Set(["failed","needs_review","quarantined"]);function jt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>an.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function rn(e,s){var n;switch(e.kind){case"paused":return`paused: scheduler is paused (${e.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${e.agentType} jobs can't launch${(n=e.block)!=null&&n.kind?` (${e.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${ee(s)}`:"";return`saturated: ${e.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=e.blockedChains.length;return`blocked: ${e.pending} pending, ${e.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${e.idleMs!=null?ee(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function ln(e){const[s,n]=f.useState(null),a=Ye(),u=js(),o=a&&u;return f.useEffect(()=>{if(!o)return;let r=!0,i=!1,d=!1;const l=()=>{i||(i=!0,window.api.schedule.queueHealth(e).then(p=>{i=!1,d=!1,r&&n(p)},p=>{i=!1,!d&&(d=!0,H.error(`Queue health refresh failed: ${p instanceof Error?p.message:String(p)}`))}))};l();const c=setInterval(l,nn);return()=>{r=!1,clearInterval(c)}},[e,o]),s}const on={running:{dot:"bg-sage",text:"text-sage-dark"},paused:{dot:"bg-amber-500",text:"text-amber-600"},idle:{dot:"bg-fg-faint",text:"text-fg-faint"}};function dn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function cn(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}const Ue="px-2.5 py-1.5 rounded border border-line text-[12.5px] font-medium text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap";function un(e,s,n){if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const a=new Date(s).getTime()-n;return a>0?`Paused for rate limit — resumes in ${ee(a)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return e==="network"?"Paused: billing endpoint unreachable for 30+ min.":e==="manual"?"Scheduler paused manually — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${e})`}function pn({now:e}){const s=Oe(c=>c.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),u=Object.entries(s.launchMitigations??{}),o=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",r="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",i="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",l="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${r} ${o?i:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:un(n.reason,n.resumeAt,e)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:l,children:"Resume"})]}),a.map(([c,p])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${r} ${i}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:c})," jobs are failing before any work starts",p.httpStatus?` (HTTP ${p.httpStatus}, ${p.kind})`:` (${p.kind})`,p.exhausted?" — held until the Claude CLI version changes or you press Retry now.":p.until?` — next automatic probe ${new Date(p.until).getTime()>e?`in ${ee(new Date(p.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:p.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:p.message,children:[p.attempts," failed probe",p.attempts===1?"":"s",p.claudeVersion?` · CLI ${p.claudeVersion}`:"",p.lastSlug?` · last: ${p.lastSlug}`:""," · ",p.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:l,children:"Retry now"})]},`launch-block-${c}`)),u.map(([c,p])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${r} ${d}`,children:t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[t.jsx("span",{className:"font-mono",children:c})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(p.env).map(([h,w])=>`${h}=${w}`).join(" ")}),")",p.claudeVersion?` since CLI ${p.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:p.hint})]})},`launch-mitigation-${c}`))]})}function fn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:u,planMode:o,onPlanMode:r,planToolsRef:i}){const d=Oe(C=>C.snapshot),l=ue(C=>C.sessions),c=ln(e),[p,h]=f.useState(()=>Date.now()),[w,x]=f.useState("—");f.useEffect(()=>{const C=setInterval(()=>h(Date.now()),3e4);return()=>clearInterval(C)},[]),f.useEffect(()=>{let C=!0;return hs(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(O=>{if(!C)return;const F=O.totals,K=F.inputTokens+F.outputTokens+F.cacheReadTokens+F.cacheCreationTokens;x(`$${F.estimatedCostUsd.toFixed(2)} · ${cn(K)} tok`)}).catch(()=>{}),()=>{C=!1}},[]);const m=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(C=>!e||C.cwd===e),[d,e]),j=f.useMemo(()=>Xs(m,p),[m,p]),_=f.useMemo(()=>{const C=st(m,{sessions:l,now:p}),O=F=>C.filter(K=>K.status===F).length;return{active:O("active"),queued:O("queued"),draft:O("draft")}},[m,l,p]),N=f.useMemo(()=>{const C=new Date(p).toDateString(),O=[];for(const F of m)if(F.status==="completed"&&F.startedAt&&F.finishedAt&&new Date(Date.parse(F.finishedAt)).toDateString()===C){const K=Date.parse(F.finishedAt)-Date.parse(F.startedAt);K>0&&O.push(K)}return O.length?Math.round(O.reduce((F,K)=>F+K,0)/O.length/6e4):null},[m,p]);if(!d)return null;const I=c&&!c.unknown?c.verdict??null:null,g=c&&!c.unknown?c.slots??null:null,A=d.paused,k=dn((I==null?void 0:I.kind)??null,!!A,j.inFlight),P=on[k],G=m.filter(C=>C.status==="pending").length,z=m.filter(C=>C.status==="running").length,Q=Ut({snap:{...d,jobs:m},now:p,avgDurationMs:0,runningJobs:m.filter(C=>C.status==="running")}),Z=c!=null&&c.unknown?`Queue health: unknown — ${c.reason??"state unavailable"}`:I?rn(I,(c==null?void 0:c.oldestRunningAgeMs)??null):"queue health loading…",$=xe(d.lastRunAt?Date.parse(d.lastRunAt):null,p),S=c!=null&&c.lastDispatchAttemptAt?xe(Date.parse(c.lastDispatchAttemptAt),p):"never",q=[Z,Q.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(c==null?void 0:c.oldestRunningAgeMs)!=null?`oldest running ${ee(c.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${$} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${S} (advances on every driver evaluation)`].filter(Boolean).join(`
2
2
  `),L=d.utilization,D=d.pollHealth,E=D!=null&&!D.lastPollOk,T=xs(d.utilizationWindow),V=d.nextReset?Date.parse(d.nextReset):null,Y=V?V>p?ee(V-p):"soon":"—",J=d.effectiveConcurrency,ne=(J==null?void 0:J.cap)??5,b=(J==null?void 0:J.source)==="env",y=d.config.firePolicy??"when-available",R=G===0&&z===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Ge,{height:40,testId:"queue-health-header",className:"gap-3",children:[t.jsx("h1",{className:"m-0 font-serif text-[21px] font-semibold leading-none tracking-tight text-fg",children:"Scheduler"}),t.jsx("span",{className:"w-px h-[20px] bg-rule-structural","aria-hidden":"true"}),t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-[12.5px] font-medium ${P.text}`,"data-testid":"scheduler-state-word","data-state":k,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${P.dot}`,"aria-hidden":"true"}),k]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[j.inFlight," in flight · ",j.heldByDeps," held · last batch ",$]}),t.jsxs(ge,{title:q,testId:"scheduler-verdict-info",popoverTestId:"scheduler-info-popover",children:[t.jsx("pre",{className:"m-0 mb-2 whitespace-pre-wrap font-mono text-[11.5px] text-fg-dim",children:q}),ft.scheduler&&t.jsx(gs,{content:ft.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(H.fromOutcome).catch(()=>H.error("Failed to rescan")),title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",className:Ue,children:"Refresh"}),A?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:Ue,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:Ue,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(H.fromOutcome).catch(()=>H.error("Failed to fire batch")),disabled:R,title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",className:"px-3 py-1.5 rounded bg-accent text-white text-[12.5px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",children:"Fire next batch"})]})]}),t.jsx(pn,{now:p}),t.jsxs(Ge,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(he,{testId:"kpi-window",label:T?`${T} used`:"Window used",info:E?`Billing poll failing — this reading may be outdated (last good reading ${xe(D.lastPollAt,p)}). Machine-wide ${T??"binding"} window.`:`Share of the machine-wide ${T??"binding"} billing window consumed — the window closest to its limit.`,value:L==null?"—":`${Math.round(L)}%`,sub:`resets in ${Y}`,third:t.jsx(ms,{pct:L??0,tone:E?"bg-amber-500":"bg-accent"})}),t.jsx(he,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(g==null?void 0:g.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:g?`${g.inUse}/${g.total}`:"—",sub:"in use",third:g?t.jsx(bs,{filled:g.inUse,total:g.total}):null}),t.jsx(he,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:j.readyNow,sub:`of ${j.totalQueued} queued`,third:`${j.heldByDeps} held by deps`}),j.needsYou>0?t.jsx(he,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:jt,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / needs-review / quarantined row",children:j.needsYou}),sub:t.jsx("button",{type:"button",onClick:jt,className:"hover:underline",children:j.needsYouStage!=null?`blocking stage ${j.needsYouStage}`:"need attention"}),third:[j.failedCount>0&&`${j.failedCount} failed`,j.needsReviewCount>0&&`${j.needsReviewCount} needs review`,j.needsYou-j.failedCount-j.needsReviewCount>0&&`${j.needsYou-j.failedCount-j.needsReviewCount} quarantined`].filter(Boolean).join(" · ")}):t.jsx(he,{testId:"kpi-needs-you",label:"Needs you",value:t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[15px]",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-sage","aria-hidden":"true"}),"all clear"]}),third:"0 failed · 0 needs review"}),t.jsx(he,{testId:"kpi-done",label:"Done today",value:j.doneToday,sub:N!=null?`avg ${N}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:w})}),t.jsx(he,{testId:"kpi-concurrency",label:"Concurrency",info:"Start-jobs policy, concurrency cap and utilization threshold",infoTestId:"kpi-concurrency-info",infoAlignRight:!0,infoContent:t.jsxs("label",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg",children:"Start jobs"}),t.jsxs("select",{"data-testid":"kpi-fire-policy",value:y,onChange:C=>window.api.schedule.setConfig({firePolicy:C.target.value}),className:"border border-line bg-bg-hi rounded px-1 py-0.5 text-[12px] text-fg-dim",title:"when-available: poll usage and fire when tokens are below threshold. on-reset: fire after each 5h reset. manual: only on Run now.","aria-label":"Start jobs policy",children:[t.jsx("option",{value:"when-available",children:"when available"}),t.jsx("option",{value:"on-reset",children:"only on reset"}),t.jsx("option",{value:"manual",children:"manually"})]})]}),value:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(vs,{value:ne,min:0,max:10,disabled:b,onChange:C=>{window.api.schedule.setSessionSlots(Math.max(0,Math.min(10,C)))},title:b?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),b&&t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-600 bg-amber-400/10 border border-amber-400/30 rounded px-1 py-0",title:"Pinned by SM_SESSION_SLOTS — unset the env var to edit",children:"env"})]}),sub:"at once",third:y==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(ws,{value:d.config.utilizationThreshold??90,min:0,max:100,testId:"kpi-threshold",title:"Fire only when 5h utilization is below this percent — click to edit",onCommit:C=>window.api.schedule.setConfig({utilizationThreshold:C})})]}):null})]}),t.jsxs(Ge,{height:30,testId:"scheduler-plans-toolbar",className:"gap-3",children:[t.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:"Plans"}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-plans-meta",children:[_.active," active · ",_.queued," queued · ",_.draft," draft · ",m.length," PRDs"]}),t.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[t.jsx("span",{ref:i,className:"contents","data-testid":"scheduler-plan-tools"}),t.jsx("input",{type:"text",value:a,onChange:C=>u(C.target.value),placeholder:"filter PRDs…","aria-label":"Filter PRDs by title, slug, or project","data-testid":"scheduler-filter-input",className:"w-[180px] bg-bg-hi border border-line rounded px-2 py-0.5 text-[12px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),t.jsx("span",{className:"inline-flex border border-line rounded overflow-hidden",role:"group","aria-label":"Plan view mode",children:[["graph","Graph"],["list","List"],["critical","Critical path"]].map(([C,O])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${C}`,"aria-pressed":o===C&&s==="queue",onClick:()=>{r(C),n("queue")},className:`px-2 py-0.5 text-[12px] ${o===C&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:O},C))}),t.jsx("span",{className:"w-px h-[16px] bg-rule-structural","aria-hidden":"true"}),[["prds","PRDs","Authored PRD source files on disk — edit, lint, archive, or queue them."],["history","History","The last 50 completed and failed jobs."],["machine","Machine","Machine-wide config that applies to every project — not this project’s live queue."]].map(([C,O,F])=>t.jsx("button",{type:"button",onClick:()=>n(C),"aria-pressed":s===C,title:F,className:`text-[12.5px] ${s===C?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:O},C))]})]})]})}function Vt({options:e,value:s,onChange:n,pillPadding:a="px-3 py-1.5"}){return t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:e.map(u=>{const o=u.value===s;return t.jsxs("button",{type:"button",onClick:()=>n(u.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${o?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[u.label,u.count!==void 0&&t.jsxs("span",{children:[" ",u.count]})]},u.value)})})}function Wt(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function hn(e){return Fe([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function Qt(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:hn(s)}))}function xn(e){const s=new Map;for(const n of e){const a=Qt(n);n.nodes.forEach((u,o)=>{const r=a.filter((i,d)=>d!==o);for(const i of Fe([u]))s.set(i.row.slug,r)})}return s}function zt({job:e,headChoices:s}){const[n,a]=f.useState(!1),u=f.useCallback((o,r)=>{a(!0),window.api.schedule.setPrdDisposition({slug:e.slug,cwd:e.cwd??void 0,disposition:o,dependsOn:r}).then(H.fromOutcome).catch(()=>H.error("Failed to change disposition")).finally(()=>a(!1))},[e.slug,e.cwd]);return e.disposition!=="append"&&s.length===0?null:t.jsxs("select",{"data-testid":"job-row-disposition-control",disabled:n,value:"",onChange:o=>{const r=o.target.value;if(r==="__new-head__")u("new-head");else if(r){const i=s.find(d=>d.rootSlug===r);i&&u("append",i.terminals)}},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border border-line/60 rounded px-1.5 py-0.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:"Change this wave's relationship to the rest of the Epic's plan",children:[t.jsx("option",{value:"",disabled:!0,children:"change disposition…"}),e.disposition==="append"&&t.jsx("option",{value:"__new-head__",children:"promote to new head"}),s.map(o=>t.jsxs("option",{value:o.rootSlug,children:["attach behind: ",Wt(o.label,40)]},o.rootSlug))]})}function gn(e,s,n=null){if(s.length===0||e.length===0)return e;const a=new Set,u=new Set;for(const r of e){a.add(r.slug);for(const i of ht(r))u.add(i)}const o=[];for(const r of s)r.archived!==!0||a.has(r.slug)||n&&r.cwd!==n||ht(r).some(i=>u.has(i))&&(a.add(r.slug),o.push({slug:r.slug,title:r.title,cwd:r.cwd,parallelGroup:r.parallelGroup,estimateMinutes:r.estimateMinutes,bodyPreview:"",status:r.archivedStatus??"completed",runId:null,startedAt:null,finishedAt:null,exitCode:null,error:null,dependsOn:r.dependsOn??void 0,sourcePromptId:r.sourcePromptId??null,epicId:r.epicId??null,synthetic:!0}));return o.length===0?e:[...e,...o]}const mn=[],bn=new Set(["failed","needs_review","quarantined"]);function wn(e){switch(e.status){case"completed":case"skipped":return"bg-sage";case"running":case"investigating":return"bg-accent";case"failed":return"bg-accent";case"needs_review":return"bg-butter";case"quarantined":return"bg-butter/60";default:return e.rowKind==="eta"||e.rowKind==="next"||e.rowKind==="retry"?"border border-fg-faint bg-transparent":"bg-fg-faint/40"}}function vn(e){switch(e.status){case"running":case"investigating":return"bg-butter/10";case"failed":return"bg-accent/10";case"needs_review":return"bg-butter/25";default:return""}}function jn(e){switch(e.rowKind){case"running":case"dep":case"failed":return"text-accent";case"review":return"text-butter font-semibold";default:return"text-fg-faint"}}function yn({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:u=mn}){const[o,r]=f.useState(!1),i=e.job,d=s!==null&&e.rowKind==="running"?Gt(i,s):e.rowTrailing,l=e.status==="completed"||e.status==="skipped",c=e.rowKind==="dep"&&e.blockers.some(h=>!h.missing&&h.status!==null&&bn.has(h.status)),p=l||c;return t.jsxs("div",{role:"listitem","data-testid":"prd-row","data-slug":e.slug,className:"border-t border-rule-inner first:border-t-0",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":i.status,"data-job-index":n,onClick:()=>r(h=>!h),onFocus:()=>a(n),"aria-expanded":o,"aria-label":`${e.prdNumber?`PRD ${e.prdNumber}, `:""}${i.title}, ${i.status}${d?`, ${d}`:""}`,title:i.title,className:`w-full h-[31px] py-1 px-2 text-left flex items-center gap-1.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${vn(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${wn(e)}`}),t.jsx("span",{className:"shrink-0 font-mono text-[10.5px] text-fg-faint w-[30px]",children:e.prdNumber?`#${e.prdNumber}`:""}),t.jsx("span",{className:`flex-1 min-w-0 truncate text-[12.5px] leading-tight ${p?"text-fg-faint":"text-fg font-medium"}`,children:i.title}),t.jsx("span",{"data-testid":"prd-row-trailing",className:`shrink-0 font-mono text-[10.5px] ${jn(e)}`,children:d})]}),o&&t.jsx(Nn,{row:e,elapsedMs:s,headChoices:u})]})}const Jt=f.memo(yn);function Nn({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[u,o]=f.useState(!1),r=ue(w=>w.sessions),i=f.useMemo(()=>Ce(a,r),[a,r]),d=i.known&&i.epicId?r[i.epicId]:null,l=f.useCallback(w=>Mt(w),[]),c="font-mono text-[11.5px] text-fg-dim leading-snug break-words",p="text-[12px] font-semibold bg-transparent border-0 cursor-pointer p-0",h=a.error?a.error.split(`
3
3
  `)[0]:null;return t.jsxs("div",{"data-testid":"prd-row-detail",className:"px-3 py-2 bg-bg-elev/50 border-t border-rule-inner flex flex-col gap-1",children:[t.jsxs("div",{className:c,children:[a.status.replace(/_/g," "),a.exitCode!==null&&` · exit ${a.exitCode}`,a.verifierVerdict&&` · ${$e(a.verifierVerdict)}`,a.startedAt&&` · started ${ie(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${ie(Date.parse(a.finishedAt))}`,s===null&&e.rowTrailing&&e.rowKind==="done"?` · took ${e.rowTrailing}`:""]}),e.cycle&&t.jsxs("div",{className:`${c} text-accent`,"data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",e.blockers.map(w=>w.slug).join(" ↔ ")||"self-referencing"]}),!e.cycle&&e.blockers.length>0&&t.jsxs("div",{className:c,"data-testid":"job-row-blockers",children:["depends on ",e.blockers.map(w=>`${w.slug} (${w.missing?"missing":(w.status??"unknown").replace(/_/g," ")})`).join(", ")]}),a.status==="pending"&&a.heldReason&&t.jsxs("div",{className:`${c} text-amber-400/90`,"data-testid":"job-row-held-reason",children:["held · ",a.heldReason]}),h&&t.jsx("div",{className:`${c} text-accent/80`,children:h}),!a.synthetic&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 pt-0.5",children:[d&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:d.goalText,onClick:()=>l(d.id),className:`${p} text-accent hover:text-accent/80`,children:"view epic →"}),a.runId&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:`${p} text-fg-dim hover:text-fg`,children:"view log →"}),a.status==="quarantined"&&t.jsx("button",{type:"button","data-testid":"job-row-adopt-prd",title:"Stamp this PRD's provenance so the scheduler will run it — no unstamped PRD runs automatically.",onClick:()=>{window.api.schedule.adoptPrd(a.slug).then(H.fromOutcome).catch(()=>H.error("Failed to adopt PRD"))},className:`${p} text-accent hover:text-accent/80`,children:"adopt PRD →"}),a.status!=="pending"&&a.status!=="running"&&a.status!=="quarantined"&&t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(a.slug),className:`${p} text-fg-dim hover:text-fg`,children:"reset to pending →"}),a.disposition&&(a.status==="pending"||a.status==="quarantined")&&t.jsx(zt,{job:a,headChoices:n})]}),u&&a.runId&&t.jsx(Le,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>o(!1)})]})}const ce=190,kn=7,Sn=5,$n=[],Kt=e=>e==="completed"||e==="skipped",Yt=e=>e==="running"||e==="investigating",Xt=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Me(e){return Yt(e.status)?0:Xt(e.status)?1:Kt(e.status)?3:2}const Cn={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},Pn={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function Dn(e,s){return e.every(n=>Kt(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&Xt(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function An({stage:e,epicId:s,now:n,hidden:a,indexBySlug:u,headChoicesBySlug:o,onRowFocused:r}){const[i,d]=f.useState(!1),l=f.useMemo(()=>e.rows.filter(g=>!(a.has(g.slug)&&(g.status==="completed"||g.status==="failed"))).map((g,A)=>({r:g,i:A})).sort((g,A)=>Me(g.r)-Me(A.r)||g.i-A.i).map(g=>g.r),[e.rows,a]),c=f.useMemo(()=>l.filter(g=>Me(g)<=1).length,[l]),p=Math.max(e.state==="done"?Sn:kn,c),h=i?l:l.slice(0,p),w=i?[]:l.slice(p),x=l.find(g=>g.status==="failed"),m=l.find(g=>g.status==="needs_review"),j=c>0&&(x!==void 0||m!==void 0),_=h.reduce((g,A,k)=>Me(A)<=1?k:g,-1),N=g=>t.jsx(Jt,{row:g,elapsedMs:Yt(g.status)&&g.job.startedAt?n-Date.parse(g.job.startedAt):null,listIndex:u.get(g.slug)??0,onFocused:r,headChoices:o.get(g.slug)??$n},g.slug),I="flex-1 min-w-0 truncate h-[24px] text-[11.5px] font-medium text-fg-dim hover:text-fg border border-rule-structural rounded-sm bg-transparent cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"stage-column","data-stage":e.n,style:{width:ce},className:"shrink-0 border-l border-rule-structural first:border-l-0 flex flex-col self-stretch",children:[t.jsxs("div",{className:"h-[30px] shrink-0 flex items-center gap-1.5 px-2 border-b border-rule-inner","data-testid":"stage-header",children:[t.jsx("span",{"aria-hidden":"true",className:`w-[7px] h-[7px] rounded-full shrink-0 ${Pn[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${Cn[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(ge,{title:"Rows in this stage are failed / need review / are quarantined, or wait on one that is."}),t.jsx("span",{"data-testid":"stage-summary",className:"ml-auto font-mono text-[10.5px] text-fg-dim truncate",children:e.summary})]}),t.jsx("div",{role:"presentation",children:h.map((g,A)=>t.jsxs("div",{children:[N(g),j&&A===_&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[x&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${x.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(x.slug).then(k=>{k.ok||H.error(k.error??`Failed to reset ${x.slug}`)}).catch(()=>H.error(`Failed to reset ${x.slug}`))},className:I,children:["Retry ",x.prdNumber?`#${x.prdNumber}`:x.slug]}),m&&t.jsxs("button",{type:"button","data-testid":"stage-review",disabled:!s,title:s?"Open the authoring Epic — a needs_review PRD is a question routed back to it":"No authoring Epic recorded for this plan",onClick:()=>{s&&Mt(s)},className:I,children:["Review ",m.prdNumber?`#${m.prdNumber}`:m.slug]})]})]},g.slug))}),(w.length>0||i&&l.length>p)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":i,onClick:()=>d(g=>!g),className:"mt-auto h-[26px] border-t border-rule-inner font-mono text-[11px] text-fg-faint hover:text-fg-dim bg-transparent cursor-pointer",children:i?"show less ▴":`${Dn(w,e.n)} ▾`})]})}const be=6,Ve=4,Ee=4,yt=12,Nt=5,Zt=2,kt=4,Mn={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function Rn(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function In(e){const s=[],n=[],a=[];let u=Nt;for(const o of e){const r=Math.max(1,Math.ceil(o.rows.length/Ee));n.push(u),a.push(r*be),o.rows.forEach((i,d)=>{s.push({x:u+Math.floor(d/Ee)*be,y:Zt+d%Ee*be,tone:Rn(i.status),title:`${i.prdNumber?`#${i.prdNumber}`:i.slug} ${i.title} — ${i.status}`})}),u+=r*be+yt}return{dots:s,stageX:n,stageW:a,width:Math.max(0,u-yt)+Nt}}function we(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const Je=e=>e==="running"||e==="investigating",Ke=e=>e==="failed"||e==="needs_review"||e==="quarantined";function En({stages:e,first:s,perView:n,onSeek:a}){const u=f.useMemo(()=>In(e),[e]),o=f.useMemo(()=>we(e,Je)>=0,[e]),r=f.useMemo(()=>we(e,Ke)>=0,[e]),i=f.useRef(!1),d=e.length,l=Math.min(d-1,s+n-1),c=u.stageX[Math.min(s,d-1)]??0,p=(u.stageX[l]??0)+(u.stageW[l]??0),h=x=>{const m=x.currentTarget.getBoundingClientRect(),j=x.clientX-m.left;let _=0;for(let N=0;N<d;N++)u.stageX[N]<=j&&(_=N);a(Math.max(0,Math.min(d-1,_-Math.floor(n/2))))},w="px-2 h-[20px] text-[11.5px] disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"plan-minimap",className:"h-[28px] flex items-center gap-3 px-3 border-t border-rule-inner",children:[t.jsxs("span",{className:"shrink-0 flex items-center gap-1 text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Whole graph",t.jsx(ge,{title:"Every PRD in this plan as one dot, grouped by stage. The rust box is the range of stages shown below — drag it to scroll."})]}),t.jsxs("div",{"data-testid":"plan-minimap-dots",role:"presentation",className:"relative shrink min-w-0 overflow-hidden cursor-ew-resize touch-none",style:{width:u.width,height:Ee*be-(be-Ve)+2*Zt},onPointerDown:x=>{var m,j;i.current=!0,(j=(m=x.currentTarget).setPointerCapture)==null||j.call(m,x.pointerId),h(x)},onPointerMove:x=>{i.current&&h(x)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},children:[u.dots.map((x,m)=>t.jsx("span",{title:x.title,"data-tone":x.tone,className:`absolute rounded-[1px] ${Mn[x.tone]}`,style:{left:x.x,top:x.y,width:Ve,height:Ve}},m)),t.jsx("span",{"data-testid":"plan-minimap-brush","aria-hidden":"true",className:"absolute top-0 bottom-0 border border-accent bg-accent/10 rounded-[2px] pointer-events-none",style:{left:c-kt,width:p-c+2*kt}})]}),t.jsxs("span",{className:"ml-auto shrink-0 font-mono text-[11.5px] text-fg-faint","data-testid":"plan-minimap-range",children:["stages ",Math.min(s+1,d),"–",l+1," of ",d]}),t.jsxs("span",{className:"shrink-0 inline-flex border border-line rounded overflow-hidden",role:"group","aria-label":"Jump the stage window",children:[t.jsx("button",{type:"button","data-testid":"minimap-running",disabled:!o,title:o?"Scroll to the lowest stage with a running PRD":"No stage has a running PRD",onClick:()=>a(we(e,Je)),className:`${w} text-fg-dim hover:text-fg`,children:"Running"}),t.jsx("button",{type:"button","data-testid":"minimap-blockers",disabled:!r,title:r?"Scroll to the lowest stage with a failed / needs-review / quarantined PRD":"No stage has a failed, needs-review or quarantined PRD",onClick:()=>a(we(e,Ke)),className:`${w} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const Tn=148;function _n({stages:e,onSeek:s}){if(e.length===0)return null;const n=e[0].n,a=e[e.length-1].n;return t.jsxs("div",{"data-testid":"further-stages",style:{width:Tn},className:"shrink-0 border-l border-rule-structural flex flex-col",children:[t.jsxs("div",{className:"h-[30px] shrink-0 flex items-center px-2 border-b border-rule-inner text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Stage ",n,"–",a]}),t.jsxs("div",{className:"h-[22px] shrink-0 flex items-center gap-1 px-2 text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Further stages",t.jsx(ge,{title:"Stages beyond the visible window. Click one to scroll the stage columns to it."})]}),e.map(u=>{const o=u.rows.length===0?0:u.doneCount/u.rows.length*100;return t.jsxs("button",{type:"button","data-testid":"further-stage-row","data-stage":u.n,title:`${u.summary} — scroll to stage ${u.n}`,onClick:()=>s(u.n-1),className:"h-[26px] px-2 flex items-center gap-2 border-t border-rule-inner bg-transparent hover:bg-bg-hi cursor-pointer text-left",children:[t.jsxs("span",{className:"font-mono text-[10.5px] text-fg-dim w-[50px] whitespace-nowrap shrink-0",children:["stage ",u.n]}),t.jsx("span",{role:"progressbar","aria-valuenow":u.doneCount,"aria-valuemin":0,"aria-valuemax":u.rows.length,className:"flex-1 h-[4px] rounded-sm bg-rule-inner overflow-hidden",children:t.jsx("span",{className:"block h-full bg-sage",style:{width:`${o}%`}})})]},u.n)})]})}const On=[],Ln=e=>e==="running"||e==="investigating";function Fn(e){const s=Zs(e),n=new Map,a=new Map;for(const i of e.stages){a.set(i.n,i.rows.length);for(const d of i.rows)n.set(d.slug,d)}const u=new Map;let o=0;const r=[];for(const i of s){const d=n.get(i);o+=d.estimateMinutes??0,u.set(d.stage,(u.get(d.stage)??0)+1),r.push({row:d,totalMinutes:o,othersInStage:0})}for(const i of r)i.othersInStage=(a.get(i.row.stage)??0)-(u.get(i.row.stage)??0);return r}function qn({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:u}){const o=f.useMemo(()=>Fn(e),[e]);return t.jsx("div",{"data-testid":"critical-path",className:"border-t border-rule-structural max-w-[640px]",children:o.map(({row:r,totalMinutes:i,othersInStage:d})=>t.jsxs("div",{"data-testid":"critical-entry","data-slug":r.slug,children:[t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(Jt,{row:r,elapsedMs:Ln(r.status)&&r.job.startedAt?s-Date.parse(r.job.startedAt):null,listIndex:n.get(r.slug)??0,onFocused:u,headChoices:a.get(r.slug)??On})}),t.jsxs("span",{"data-testid":"critical-est",className:"shrink-0 h-[31px] px-3 flex items-center gap-2 font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:[t.jsx("span",{title:"estimateMinutes",children:r.estimateMinutes?`${r.estimateMinutes}m`:"—"}),t.jsxs("span",{className:"text-fg-dim",title:"Running total along the chain",children:["Σ ",i,"m"]})]})]}),d>0&&t.jsxs("div",{"data-testid":"critical-others",className:"h-[22px] px-3 flex items-center font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:["stage ",r.stage," · +",d," not on the critical path"]})]},r.slug))})}const St=1,$t=1350,Bn={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},Hn={active:{label:"ACTIVE",cls:"bg-accent text-white border border-accent"},queued:{label:"QUEUED",cls:"text-fg-dim border border-fg-faint"},done:{label:"DONE",cls:"text-sage-dark border border-sage"},draft:{label:"DRAFT",cls:"text-fg-faint border border-dashed border-fg-faint"}},Gn=e=>String(e).padStart(2,"0");function Un({plan:e}){const s=Math.max(1,e.prdCount),n=e.doneCount/s*100,a=e.runningCount/s*100;return t.jsxs("span",{"data-testid":"plan-progress",role:"progressbar","aria-valuenow":e.doneCount,"aria-valuemin":0,"aria-valuemax":e.prdCount,className:"flex w-[160px] h-[5px] rounded-sm overflow-hidden bg-rule-inner shrink-0",children:[t.jsx("span",{className:"h-full bg-sage",style:{width:`${n}%`}}),t.jsx("span",{className:"h-full bg-accent",style:{width:`${a}%`}})]})}function Vn({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:u,headChoicesBySlug:o,onRowFocused:r,onOpenPrds:i}){var q,L;const[d,l]=f.useState(e.status==="active"||e.status==="queued"),[c,p]=f.useState(!1),h=f.useRef(null),[w,x]=f.useState(0),[m,j]=f.useState($t),_=f.useMemo(()=>{const D=we(e.stages,Je);return D>=0?D:Math.max(0,we(e.stages,Ke))},[e.stages]);f.useLayoutEffect(()=>{if(!d)return;const D=h.current,E=(D==null?void 0:D.clientWidth)||$t,T=Math.max(0,Math.min(_,e.stageCount-Math.max(1,Math.ceil(E/ce))));D!=null&&D.clientWidth&&j(D.clientWidth),D&&(D.scrollLeft=T*ce),x(T)},[d]);const N=f.useMemo(()=>{let D=null;for(const E of e.stages)for(const T of E.rows){if(!T.job.runId)continue;const V=T.job.finishedAt?Date.parse(T.job.finishedAt):0;(!D||V>D.at)&&(D={runId:T.job.runId,slug:T.slug,title:T.title,at:V})}return D},[e.stages]),I=Te((L=(q=e.stages[0])==null?void 0:q.rows[0])==null?void 0:L.job.cwd)??"—",g=Hn[e.status],A=Math.max(1,Math.ceil(m/ce)),k=Math.max(0,Math.min(w-St,e.stageCount)),P=Math.min(e.stageCount,w+A+St),G=D=>{const E=Math.max(0,Math.min(e.stageCount-1,D));h.current&&(h.current.scrollLeft=E*ce),x(E)},z=Math.min(e.stageCount,w+A),Q=D=>{const E=D.currentTarget,T=Math.floor(E.scrollLeft/ce);T!==w&&x(T),E.clientWidth&&E.clientWidth!==m&&j(E.clientWidth)},Z="h-[24px] px-3 text-[12px] font-medium text-fg border border-rule-structural rounded-sm bg-transparent hover:bg-bg-hi cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shrink-0",$=(()=>{switch(e.status){case"active":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Pauses the WHOLE scheduler (machine-wide) — there is no per-plan pause.",onClick:()=>{window.api.schedule.pause().catch(()=>H.error("Failed to pause the scheduler"))},className:Z,children:"Pause plan"});case"queued":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Fires the next scheduler batch machine-wide (force tick) — it does not target this plan.",onClick:()=>{window.api.schedule.forceTick().then(H.fromOutcome).catch(()=>H.error("Failed to fire the next batch"))},className:Z,children:"Run now"});case"done":return t.jsx("button",{type:"button","data-testid":"plan-action",disabled:!N,title:N?`Open the run log of ${N.slug}, the plan's last run`:"No run log recorded for this plan",onClick:()=>p(!0),className:Z,children:"View run"});case"draft":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Open the PRDs sub-view on this plan's first PRD (the PRDs view has no per-Epic filter).",onClick:()=>{var D,E;return i==null?void 0:i(((E=(D=e.stages[0])==null?void 0:D.rows[0])==null?void 0:E.slug)??null)},className:Z,children:"Schedule…"})}})(),S=e.etaMs>0?` · ${Ht(e.etaMs)} left`:"";return t.jsxs("section",{"data-testid":"plan-band","data-epic-id":e.epicId??"","data-plan-status":e.status,className:`border-l-[3px] ${Bn[e.status]} border-b border-rule-structural`,children:[t.jsxs("div",{className:"h-[32px] flex items-center gap-2.5 px-3","data-testid":"plan-header",children:[t.jsx("button",{type:"button","aria-expanded":d,"aria-label":d?"Collapse plan":"Expand plan","data-testid":"plan-toggle",onClick:()=>l(D=>!D),className:"shrink-0 w-[14px] text-[11px] text-fg-faint hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:d?"▾":"▸"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint shrink-0",children:Gn(e.index)}),t.jsx("span",{className:"font-serif text-[15px] font-bold text-fg truncate shrink-0 max-w-[320px]",title:e.label,"data-testid":"plan-label",children:e.label}),t.jsx("span",{"data-testid":"plan-chip",className:`shrink-0 rounded-sm px-1.5 py-[1px] text-[10px] font-bold tracking-wide ${g.cls}`,children:g.label}),t.jsx("span",{"aria-hidden":"true",className:"shrink-0 w-px h-[16px] bg-rule-structural"}),t.jsxs("span",{className:"font-mono text-[11.5px] text-fg-faint truncate min-w-0","data-testid":"plan-meta",children:[I," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.stageCount," stage",e.stageCount===1?"":"s"]}),t.jsxs("span",{className:"font-mono text-[11.5px] text-fg-dim shrink-0","data-testid":"plan-step-count",children:[e.prdCount," step",e.prdCount===1?"":"s"," · ",e.doneCount," done"]}),t.jsx(ge,{title:`${e.doneCount} done · ${e.runningCount} running · ${e.heldCount} held · ${e.blockedCount} blocked`}),t.jsxs("span",{className:"ml-auto font-mono text-[11.5px] text-fg-dim shrink-0","data-testid":"plan-progress-label",children:[e.doneCount,"/",e.prdCount,S]}),t.jsx(Un,{plan:e}),$]}),d&&s==="critical"&&t.jsx(qn,{plan:e,now:n,indexBySlug:u,headChoicesBySlug:o,onRowFocused:r}),d&&s!=="critical"&&e.status==="active"&&t.jsx(En,{stages:e.stages,first:w,perView:A,onSeek:G}),d&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:h,"data-testid":"plan-stages",onScroll:Q,className:"flex flex-1 min-w-0 overflow-x-auto",children:[k>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:k*ce}}),e.stages.slice(k,P).map(D=>t.jsx(An,{stage:D,epicId:e.epicId,now:n,hidden:a,indexBySlug:u,headChoicesBySlug:o,onRowFocused:r},D.n)),P<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-P)*ce}})]}),t.jsx(_n,{stages:e.stages.slice(z),onSeek:G})]}),c&&N&&t.jsx(Le,{runId:N.runId,slug:N.slug,title:N.title||N.slug,onClose:()=>p(!1)})]})}function Wn({page:e,pageSize:s,totalItems:n,onPageChange:a}){if(n<=s)return null;const u=Math.max(1,Math.ceil(n/s)),o=(e-1)*s+1,r=Math.min(e*s,n);return t.jsxs("div",{"data-testid":"plan-pager",className:"flex items-center justify-center gap-3 px-[18px] py-3 font-mono text-[12px] text-fg-faint",children:[t.jsx("button",{type:"button","data-testid":"plan-pager-prev",onClick:()=>a(e-1),disabled:e<=1,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Prev"}),t.jsxs("span",{"data-testid":"plan-pager-range",children:[o,"–",r," of ",n]}),t.jsx("button",{type:"button","data-testid":"plan-pager-next",onClick:()=>a(e+1),disabled:e>=u,className:"px-2 py-1 rounded border border-line bg-bg-hi text-fg-dim hover:text-fg disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:"Next"})]})}function Qn({section:e,children:s}){const[n,a]=f.useState(!0),u=Object.entries(e.counts).map(([o,r])=>`${r} ${o.replace(/_/g," ")}`).join(" · ");return t.jsxs("div",{className:"border-t border-line","data-testid":"backlog-epic-section","data-epic-id":e.epicId??"",children:[t.jsxs("button",{type:"button",onClick:()=>a(o=>!o),className:"w-full flex items-center gap-2.5 px-[18px] py-2.5 bg-bg-elev/60 hover:bg-bg-elev text-left","aria-expanded":n,title:e.label,children:[t.jsx("span",{className:`text-fg-faint inline-flex shrink-0 transition-transform duration-150 ${n?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(Xe,{name:"chevron",size:12})}),t.jsx("span",{className:"font-serif text-[14.5px] font-semibold text-fg truncate","data-testid":"backlog-epic-label",children:e.label}),t.jsxs("span",{className:"font-mono text-[11px] text-fg-faint shrink-0",children:[e.total," PRD",e.total===1?"":"s"]}),t.jsx("span",{className:"font-mono text-[11px] text-fg-faint truncate",children:u})]}),n&&s]})}const zn=[],Jn=[],Kn={depth:0,blockers:zn,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function Yn(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function Xn(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function Zn({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:u,onFocused:o,hold:r,backlog:i=Kn,headChoices:d=Jn}){const[l,c]=f.useState(!1),[p,h]=f.useState(!1),w=ue(P=>P.sessions),x=f.useMemo(()=>Ce(e,w),[e,w]),m=x.known&&x.epicId?w[x.epicId]:null,j=f.useCallback(P=>{Ze(P),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),_=e.status==="running",N=e.status==="failed";let I=null;_&&n!==null?I=`${xt(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?I=`took ${Se(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(I=s);const g=e.error??null,A=N&&g?g.split(`
4
4
  `)[0]:e.status==="needs_review"&&e.verifierVerdict?$e(e.verifierVerdict):null,k=_&&n!==null?Math.min(.99,n/a):0;return t.jsxs("div",{role:"listitem",className:"border-t border-line",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":e.status,"data-job-index":u,"data-depth":i.depth,onClick:()=>c(P=>!P),onFocus:()=>o(u),style:i.depth>0?{paddingLeft:18+i.depth*20}:void 0,className:`w-full text-left grid grid-cols-[116px_1fr_auto_auto] items-center gap-4 px-[18px] py-3.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${l?"bg-bg-elev/40":""}`,"aria-expanded":l,"aria-label":`${re(e.slug)?`PRD ${re(e.slug)}, `:""}${e.title}, ${e.status}${I?`, ${I}`:""}`,title:e.title,children:[t.jsx(Rt,{status:e.status}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug",children:[re(e.slug)&&t.jsx(It,{n:re(e.slug)}),e.title,t.jsx(Et,{leaked:e.leakedDescendants}),t.jsx(ys,{count:e.leftoverCount,truncated:e.leftoverPathsTruncated,salvagePatch:e.salvagePatch}),i.parallelEligible&&t.jsx("span",{"data-testid":"job-row-parallel-eligible",title:"No dependsOn, and nothing in this Epic depends on it — can run any time a slot is free",className:"text-[10px] font-semibold uppercase tracking-wide text-sage/90 bg-sage/10 border border-sage/30 rounded px-1.5 py-0.5",children:"parallel"})]}),i.cycle&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-accent font-mono","data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",i.blockers.map(P=>P.slug).join(" ↔ ")||"self-referencing"]}),!i.cycle&&i.blockers.length>0&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 font-mono","data-testid":"job-row-blockers",children:[t.jsx("span",{className:i.blocked||i.hasMissingDep?"text-amber-400/90":"text-fg-faint",children:i.blocked||i.hasMissingDep?"blocked by ":"depends on "}),i.blockers.map((P,G)=>t.jsxs("span",{className:Xn(P),children:[G>0&&", ",Yn(P)]},P.slug))]}),A&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${N?"text-accent/80":"text-fg-faint"}`,children:A}),r&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:r.dep?t.jsxs(t.Fragment,{children:["held · waiting on ",r.dep," (",r.depStatus,")"]}):t.jsxs(t.Fragment,{children:["held · ",r.reason??"launch blocked"]})}),!r&&e.status==="pending"&&e.heldReason&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-held-reason",children:["held · ",e.heldReason]}),t.jsx(et,{epicId:x.epicId,label:x.label?Wt(x.label):null,onOpen:j,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(tt,{cwd:e.cwd}),t.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint shrink-0",children:[t.jsx(Ns,{status:e.status,overrun:e.overrun}),I,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${l?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(Xe,{name:"chevron",size:14})})]})]}),_&&!l&&t.jsx("div",{className:"h-1 bg-line mx-[18px] mb-3 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-accent transition-all duration-1000",style:{width:`${Math.max(4,k*100)}%`}})}),l&&t.jsxs("div",{className:"px-[18px] py-5 grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-5 bg-bg-elev/50 border-t border-line",children:[t.jsxs(ae,{label:"Status",children:[t.jsx(B,{k:"result",v:e.exitCode!==null?`exit ${e.exitCode}`:"—"}),t.jsx(B,{k:"state",v:e.status.replace(/_/g," ")}),e.verifierVerdict&&t.jsx(B,{k:"verdict",v:$e(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(B,{k:"leaked",v:Tt(e.leakedDescendants),wrap:!0}),e.leftoverCount!=null&&e.leftoverCount>0&&t.jsx(B,{k:"uncommitted",v:`${e.leftoverCount} file${e.leftoverCount===1?"":"s"}${e.leftoverPathsTruncated?"+":""}: ${(e.leftoverPaths??[]).join(", ")}${e.salvagePatch?` — salvaged to ${e.salvagePatch}`:""}`,wrap:!0}),g&&t.jsx(B,{k:"error",v:g.split(`
@@ -1 +1 @@
1
- import{ak as i,S as d}from"./index-XkrLB67D.js";function a({scopes:l,active:n,onChange:o,annotate:s}){return i.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:l.map(t=>{const r=d[t],e=s==null?void 0:s(t),c=t===n;return i.jsxs("button",{title:r.hint,onClick:()=>o(t),className:`px-2.5 py-1 text-xs flex items-center gap-1.5 transition-colors ${c?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[i.jsx("span",{children:r.label}),(e==null?void 0:e.dirty)&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent",title:"unsaved edits"}),e&&e.exists===!1&&!e.dirty&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-fg-faint",title:"not yet created"})]},t)})})}export{a as S};
1
+ import{ak as i,S as d}from"./index-Cd98Q1lD.js";function a({scopes:l,active:n,onChange:o,annotate:s}){return i.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:l.map(t=>{const r=d[t],e=s==null?void 0:s(t),c=t===n;return i.jsxs("button",{title:r.hint,onClick:()=>o(t),className:`px-2.5 py-1 text-xs flex items-center gap-1.5 transition-colors ${c?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[i.jsx("span",{children:r.label}),(e==null?void 0:e.dirty)&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent",title:"unsaved edits"}),e&&e.exists===!1&&!e.dirty&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-fg-faint",title:"not yet created"})]},t)})})}export{a as S};
@@ -1,3 +1,3 @@
1
- import{az as d,ak as e,S as T,A as Q,m as P,b1 as ee,a_ as te,aT as se,d as $,aw as ae,aN as ne,aX as re,b5 as G,aZ as le,aR as D,am as ie,aq as oe,v as ce,J as de,X as ue,H,aG as xe}from"./index-XkrLB67D.js";import{S as pe}from"./ScopeSwitcher-XdxtVKP-.js";import{S as q}from"./SaveBar-BQ8y9Lkv.js";import{u as me,s as B,E as fe}from"./settingsSchema-BIvDZ1Cj.js";import{T as L}from"./Toggle-BxtAFE1i.js";import"./monaco-editor-BW5C4Iv1.js";const he=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],ge={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function W(s){return s.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((l,n)=>{const r=ge[l];return r||(n===0?l.charAt(0).toUpperCase()+l.slice(1):l)}).join(" ")}function z(s){const a=new Set,t=[];for(const n of he){const r=n.keys.filter(i=>s.has(i));r.forEach(i=>a.add(i)),r.length!==0&&t.push({id:n.id,title:n.title,summary:n.summary,advanced:!!n.advanced,keys:r})}const l=Array.from(s).filter(n=>!a.has(n)&&n!=="$schema").sort();return l.length>0&&t.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:l}),t}function be(s,a){return z(s).map(t=>({id:t.id,title:t.title,advanced:t.advanced,total:t.keys.length,setCount:t.keys.filter(l=>a.has(l)).length}))}const ye={};function V(s,a){if(a)return{text:a,authored:!1};const t=ye[s];return t?{text:t,authored:!0}:null}const je={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},ve=["user","project","local","default"],Ne={user:"user",project:"project",local:"local",default:"default"};function we({node:s,targetScope:a,onOverride:t,schema:l}){const[n,r]=d.useState(""),[i,p]=d.useState(!1),[m,v]=d.useState(!0),x=s.kind==="object"?s:null,w=x?Object.keys(x.children):[],g=l.rootKeys(),y=new Set([...w,...g]),u=d.useMemo(()=>z(y),[Array.from(y).sort().join(",")]),b=d.useMemo(()=>be(y,new Set(w)),[Array.from(y).sort().join(","),w.join(",")]),[C,E]=d.useState(null),f=d.useRef(null),k=o=>{const j=u.find(N=>N.id===o);j!=null&&j.advanced&&!i&&p(!0),E(o)};d.useEffect(()=>{if(!C)return;E(null);const o=f.current,j=document.getElementById(`settings-group-${C}`);if(!o||!j)return;const N=j.getBoundingClientRect().top-o.getBoundingClientRect().top;o.scrollBy({top:N,behavior:"smooth"})},[C]);const S=d.useMemo(()=>u.filter(o=>i||!o.advanced).map(o=>({...o,keys:o.keys.filter(j=>{const N=(x==null?void 0:x.children[j])!==void 0;if(!m&&!N)return!1;if(!n.trim())return!0;const h=l.at([j]);return[j,W(j),(h==null?void 0:h.description)??""].join(" ").toLowerCase().includes(n.toLowerCase())})})).filter(o=>o.keys.length>0),[u,n,i,m,x,l]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:T[a].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:o=>v(o.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:o=>p(o.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:n,onChange:o=>r(o.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(ke,{groups:b,onJump:k}),e.jsxs("div",{ref:f,className:"flex-1 overflow-auto py-3",children:[S.map(o=>e.jsx(Se,{id:o.id,title:o.title,summary:o.summary,advanced:o.advanced,children:o.keys.map(j=>{const N=x==null?void 0:x.children[j],h=l.at([j]);return e.jsx(Ce,{keyName:j,node:N,info:h,targetScope:a,onOverride:(c,O)=>t([j],c,O)},j)})},o.id)),S.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',n,'"']})]})]})]})}function ke({groups:s,onJump:a}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${t.title}`,children:[e.jsx(Q,{name:je[t.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:t.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[t.setCount,"/",t.total]})]},t.id))})}function Se({id:s,title:a,summary:t,advanced:l,children:n}){const[r,i]=d.useState(!0);return e.jsxs("section",{id:`settings-group-${s}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>i(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:a}),l&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:t})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:n})]})}function Ce({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const[r,i]=d.useState(!1),[p,m]=d.useState(!1),v=W(s),x=a!==void 0,g=(a==null?void 0:a.kind)==="leaf"?a:null,y=(a==null?void 0:a.kind)==="object"||(a==null?void 0:a.kind)==="array",u=t==null?void 0:t.default,b=g&&u!==void 0&&Z(g.value,u),C=Me({isSet:x,leafNode:g,defaultVal:u,isDefault:!!b,node:a}),E=Ee(g,u),f=E.length>=2,k=!!g&&!b,S=V(s,t==null?void 0:t.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>i(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:v}),e.jsx(Ie,{kind:C.kind,label:C.label}),f&&e.jsxs("button",{onClick:o=>{o.stopPropagation(),r||i(!0),m(j=>!j)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",E.map(o=>Ne[o]).join(" · ")]}),k&&g&&e.jsx("button",{onClick:o=>{o.stopPropagation(),n(void 0,g.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${T[g.winner].label}`,children:"↺ reset"}),(t==null?void 0:t.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(t==null?void 0:t.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),S&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${S.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:S.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:Le(S.text)}),r&&p&&g&&e.jsx(Te,{leaf:g,defaultVal:u,onReset:o=>n(void 0,o)}),r&&e.jsx(Oe,{keyName:s,node:a,info:t,targetScope:l,onOverride:o=>n(o)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(De,{node:a,info:t,onSet:o=>{n(o)},disabled:y&&x})})]})})}function Ee(s,a){if(!s)return[];const t=new Set;t.add(s.winner);for(const l of s.shadowed)t.add(l.scope);return a!==void 0&&t.add("default"),ve.filter(l=>t.has(l))}function Te({leaf:s,defaultVal:a,onReset:t}){const l={};l[s.winner]={value:s.value,winner:!0};for(const n of s.shadowed)l[n.scope]={value:n.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(n=>{const r=l[n],i=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:T[n].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:i?R(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>t(n),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${T[n].label}`,children:"↺"}):e.jsx("span",{})]},n)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:a!==void 0?R(a):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function Oe({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const i=(a==null?void 0:a.kind)==="leaf"?a:null,p=V(s,t==null?void 0:t.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(t==null?void 0:t.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(t.type)?t.type.join(" | "):t.type})]}),(t==null?void 0:t.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:R(t.default)})]}),(t==null?void 0:t.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:t.enum.map(m=>String(m)).join(" | ")})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:R(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",T[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((m,v)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[R(m.value)," —"," ",e.jsx("span",{className:"no-underline",children:T[m.scope].label})]},v))})]}),(a==null?void 0:a.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[a.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(Ae,{keyName:s,node:a,info:t,onChange:n,targetScope:l})})]})}function Ae({node:s,info:a,onChange:t,targetScope:l}){const r=(s==null?void 0:s.kind)==="leaf"?s.value:a==null?void 0:a.default,i=Y(a==null?void 0:a.type);if(i==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:m,label:v})=>e.jsx("button",{onClick:()=>t(m),className:`px-3 py-0.5 text-xs transition-colors ${p===m?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:v},v))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[l].label]})]})}return a!=null&&a.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),a.enum.map(p=>{const m=Z(r,p);return e.jsx("button",{onClick:()=>t(p),className:`px-2 py-0.5 text-xs rounded border ${m?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[l].label]})]}):i==="integer"||i==="number"?e.jsx(Re,{value:typeof r=="number"?r:void 0,integer:i==="integer",onCommit:t,target:T[l].label}):i==="string"?e.jsx(Pe,{value:typeof r=="string"?r:"",onCommit:t,target:T[l].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function Re({value:s,integer:a,onCommit:t,target:l}){const[n,r]=d.useState(s!==void 0?String(s):""),i=()=>{const p=a?parseInt(n,10):parseFloat(n);Number.isNaN(p)||t(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:n,onChange:p=>r(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",l]})]})}function Pe({value:s,onCommit:a,target:t}){const[l,n]=d.useState(s);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:l,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&a(l)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>a(l),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",t]})]})}function De({node:s,info:a,onSet:t,disabled:l}){const n=(s==null?void 0:s.kind)==="leaf",r=Y(a==null?void 0:a.type);if(l)return null;if(r==="boolean"){const i=n&&s.value===!0;return e.jsx("button",{onClick:()=>t(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:i?"on":"off"})}return null}function Me({isSet:s,leafNode:a,defaultVal:t,isDefault:l,node:n}){return s?(n==null?void 0:n.kind)==="array"?{kind:"accumulated",label:`${n.items.length} items`}:(n==null?void 0:n.kind)==="object"?{kind:"set",label:"configured"}:a?l?{kind:"default",label:`= default · ${T[a.winner].label}`}:a.shadowed.length>0?{kind:"override",label:`overriding ${a.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${T[a.winner].label}`}:{kind:"set",label:"configured"}:t!==void 0?{kind:"default",label:`using default: ${R(t)}`}:{kind:"unset",label:"not configured"}}function Ie({kind:s,label:a}){const t={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[s];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${t}`,children:a})}function Y(s){if(s)return Array.isArray(s)?s.find(t=>t!=="null")??s[0]:s}function Z(s,a){return s===a?!0:typeof s!=typeof a?!1:s&&a&&typeof s=="object"?JSON.stringify(s)===JSON.stringify(a):!1}function Le(s){const a=s.trim().split(`
1
+ import{az as d,ak as e,S as T,A as Q,m as P,b1 as ee,a_ as te,aT as se,d as $,aw as ae,aN as ne,aX as re,b5 as G,aZ as le,aR as D,am as ie,aq as oe,v as ce,J as de,X as ue,H,aG as xe}from"./index-Cd98Q1lD.js";import{S as pe}from"./ScopeSwitcher-CjJi8ST5.js";import{S as q}from"./SaveBar-l9jnEMES.js";import{u as me,s as B,E as fe}from"./settingsSchema-IhUfucCF.js";import{T as L}from"./Toggle-BbW4nGGf.js";import"./monaco-editor-BW5C4Iv1.js";const he=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],ge={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function W(s){return s.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((l,n)=>{const r=ge[l];return r||(n===0?l.charAt(0).toUpperCase()+l.slice(1):l)}).join(" ")}function z(s){const a=new Set,t=[];for(const n of he){const r=n.keys.filter(i=>s.has(i));r.forEach(i=>a.add(i)),r.length!==0&&t.push({id:n.id,title:n.title,summary:n.summary,advanced:!!n.advanced,keys:r})}const l=Array.from(s).filter(n=>!a.has(n)&&n!=="$schema").sort();return l.length>0&&t.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:l}),t}function be(s,a){return z(s).map(t=>({id:t.id,title:t.title,advanced:t.advanced,total:t.keys.length,setCount:t.keys.filter(l=>a.has(l)).length}))}const ye={};function V(s,a){if(a)return{text:a,authored:!1};const t=ye[s];return t?{text:t,authored:!0}:null}const je={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},ve=["user","project","local","default"],Ne={user:"user",project:"project",local:"local",default:"default"};function we({node:s,targetScope:a,onOverride:t,schema:l}){const[n,r]=d.useState(""),[i,p]=d.useState(!1),[m,v]=d.useState(!0),x=s.kind==="object"?s:null,w=x?Object.keys(x.children):[],g=l.rootKeys(),y=new Set([...w,...g]),u=d.useMemo(()=>z(y),[Array.from(y).sort().join(",")]),b=d.useMemo(()=>be(y,new Set(w)),[Array.from(y).sort().join(","),w.join(",")]),[C,E]=d.useState(null),f=d.useRef(null),k=o=>{const j=u.find(N=>N.id===o);j!=null&&j.advanced&&!i&&p(!0),E(o)};d.useEffect(()=>{if(!C)return;E(null);const o=f.current,j=document.getElementById(`settings-group-${C}`);if(!o||!j)return;const N=j.getBoundingClientRect().top-o.getBoundingClientRect().top;o.scrollBy({top:N,behavior:"smooth"})},[C]);const S=d.useMemo(()=>u.filter(o=>i||!o.advanced).map(o=>({...o,keys:o.keys.filter(j=>{const N=(x==null?void 0:x.children[j])!==void 0;if(!m&&!N)return!1;if(!n.trim())return!0;const h=l.at([j]);return[j,W(j),(h==null?void 0:h.description)??""].join(" ").toLowerCase().includes(n.toLowerCase())})})).filter(o=>o.keys.length>0),[u,n,i,m,x,l]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:T[a].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:o=>v(o.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:o=>p(o.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:n,onChange:o=>r(o.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(ke,{groups:b,onJump:k}),e.jsxs("div",{ref:f,className:"flex-1 overflow-auto py-3",children:[S.map(o=>e.jsx(Se,{id:o.id,title:o.title,summary:o.summary,advanced:o.advanced,children:o.keys.map(j=>{const N=x==null?void 0:x.children[j],h=l.at([j]);return e.jsx(Ce,{keyName:j,node:N,info:h,targetScope:a,onOverride:(c,O)=>t([j],c,O)},j)})},o.id)),S.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',n,'"']})]})]})]})}function ke({groups:s,onJump:a}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${t.title}`,children:[e.jsx(Q,{name:je[t.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:t.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[t.setCount,"/",t.total]})]},t.id))})}function Se({id:s,title:a,summary:t,advanced:l,children:n}){const[r,i]=d.useState(!0);return e.jsxs("section",{id:`settings-group-${s}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>i(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:a}),l&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:t})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:n})]})}function Ce({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const[r,i]=d.useState(!1),[p,m]=d.useState(!1),v=W(s),x=a!==void 0,g=(a==null?void 0:a.kind)==="leaf"?a:null,y=(a==null?void 0:a.kind)==="object"||(a==null?void 0:a.kind)==="array",u=t==null?void 0:t.default,b=g&&u!==void 0&&Z(g.value,u),C=Me({isSet:x,leafNode:g,defaultVal:u,isDefault:!!b,node:a}),E=Ee(g,u),f=E.length>=2,k=!!g&&!b,S=V(s,t==null?void 0:t.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>i(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:v}),e.jsx(Ie,{kind:C.kind,label:C.label}),f&&e.jsxs("button",{onClick:o=>{o.stopPropagation(),r||i(!0),m(j=>!j)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",E.map(o=>Ne[o]).join(" · ")]}),k&&g&&e.jsx("button",{onClick:o=>{o.stopPropagation(),n(void 0,g.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${T[g.winner].label}`,children:"↺ reset"}),(t==null?void 0:t.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(t==null?void 0:t.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),S&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${S.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:S.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:Le(S.text)}),r&&p&&g&&e.jsx(Te,{leaf:g,defaultVal:u,onReset:o=>n(void 0,o)}),r&&e.jsx(Oe,{keyName:s,node:a,info:t,targetScope:l,onOverride:o=>n(o)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(De,{node:a,info:t,onSet:o=>{n(o)},disabled:y&&x})})]})})}function Ee(s,a){if(!s)return[];const t=new Set;t.add(s.winner);for(const l of s.shadowed)t.add(l.scope);return a!==void 0&&t.add("default"),ve.filter(l=>t.has(l))}function Te({leaf:s,defaultVal:a,onReset:t}){const l={};l[s.winner]={value:s.value,winner:!0};for(const n of s.shadowed)l[n.scope]={value:n.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(n=>{const r=l[n],i=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:T[n].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:i?R(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>t(n),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${T[n].label}`,children:"↺"}):e.jsx("span",{})]},n)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:a!==void 0?R(a):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function Oe({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const i=(a==null?void 0:a.kind)==="leaf"?a:null,p=V(s,t==null?void 0:t.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(t==null?void 0:t.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(t.type)?t.type.join(" | "):t.type})]}),(t==null?void 0:t.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:R(t.default)})]}),(t==null?void 0:t.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:t.enum.map(m=>String(m)).join(" | ")})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:R(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",T[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((m,v)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[R(m.value)," —"," ",e.jsx("span",{className:"no-underline",children:T[m.scope].label})]},v))})]}),(a==null?void 0:a.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[a.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(Ae,{keyName:s,node:a,info:t,onChange:n,targetScope:l})})]})}function Ae({node:s,info:a,onChange:t,targetScope:l}){const r=(s==null?void 0:s.kind)==="leaf"?s.value:a==null?void 0:a.default,i=Y(a==null?void 0:a.type);if(i==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:m,label:v})=>e.jsx("button",{onClick:()=>t(m),className:`px-3 py-0.5 text-xs transition-colors ${p===m?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:v},v))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[l].label]})]})}return a!=null&&a.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),a.enum.map(p=>{const m=Z(r,p);return e.jsx("button",{onClick:()=>t(p),className:`px-2 py-0.5 text-xs rounded border ${m?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[l].label]})]}):i==="integer"||i==="number"?e.jsx(Re,{value:typeof r=="number"?r:void 0,integer:i==="integer",onCommit:t,target:T[l].label}):i==="string"?e.jsx(Pe,{value:typeof r=="string"?r:"",onCommit:t,target:T[l].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function Re({value:s,integer:a,onCommit:t,target:l}){const[n,r]=d.useState(s!==void 0?String(s):""),i=()=>{const p=a?parseInt(n,10):parseFloat(n);Number.isNaN(p)||t(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:n,onChange:p=>r(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",l]})]})}function Pe({value:s,onCommit:a,target:t}){const[l,n]=d.useState(s);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:l,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&a(l)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>a(l),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",t]})]})}function De({node:s,info:a,onSet:t,disabled:l}){const n=(s==null?void 0:s.kind)==="leaf",r=Y(a==null?void 0:a.type);if(l)return null;if(r==="boolean"){const i=n&&s.value===!0;return e.jsx("button",{onClick:()=>t(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:i?"on":"off"})}return null}function Me({isSet:s,leafNode:a,defaultVal:t,isDefault:l,node:n}){return s?(n==null?void 0:n.kind)==="array"?{kind:"accumulated",label:`${n.items.length} items`}:(n==null?void 0:n.kind)==="object"?{kind:"set",label:"configured"}:a?l?{kind:"default",label:`= default · ${T[a.winner].label}`}:a.shadowed.length>0?{kind:"override",label:`overriding ${a.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${T[a.winner].label}`}:{kind:"set",label:"configured"}:t!==void 0?{kind:"default",label:`using default: ${R(t)}`}:{kind:"unset",label:"not configured"}}function Ie({kind:s,label:a}){const t={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[s];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${t}`,children:a})}function Y(s){if(s)return Array.isArray(s)?s.find(t=>t!=="null")??s[0]:s}function Z(s,a){return s===a?!0:typeof s!=typeof a?!1:s&&a&&typeof s=="object"?JSON.stringify(s)===JSON.stringify(a):!1}function Le(s){const a=s.trim().split(`
2
2
  `)[0],t=a.match(/^([^.!?]+[.!?])/);return t?t[1]:a.length>120?a.slice(0,120)+"…":a}function R(s){if(typeof s=="string")return s===""?'""':JSON.stringify(s);if(s===null)return"null";if(s===void 0)return"—";if(typeof s=="object"){const a=JSON.stringify(s);return a.length>60?a.slice(0,60)+"…":a}return String(s)}const _e=1440*60*1e3;function J(s){if(!s)return"never";const a=new Date(s).getTime();return Number.isNaN(a)?"never":new Date(a).toLocaleString()}function U(s){return s?new Date(s).toLocaleString():"never"}function Fe(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx($e,{}),e.jsx("hr",{className:"border-line"}),e.jsx(Ge,{})]})}function $e(){const[s,a]=d.useState(null),[t,l]=d.useState(null),[n,r]=d.useState(null),[i,p]=d.useState(null),[m,v]=d.useState(!1),[x,w]=d.useState(null),[g,y]=d.useState(null);if(d.useEffect(()=>{let f=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([k,S,o])=>{f||(a(k),r(k),l(S),p(o))}).catch(k=>{console.warn("[telemetry] load failed:",k==null?void 0:k.message)}),()=>{f=!0}},[]),!n||!s)return e.jsx(P,{title:"loading…"});const u=JSON.stringify(n)!==JSON.stringify(s),b=(f,k)=>{w(null),r({...n,[f]:k})},C=async()=>{v(!0),w(null);try{const f=await window.api.otel.setConfig(n);!f.ok&&f.error&&w(f.error),a(f.config),r(f.config),l(f.status),y(Date.now())}catch(f){w(f instanceof Error?f.message:String(f))}finally{v(!1)}},E=()=>{w(null),r(s)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),i&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:i})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(L,{checked:n.enabled,onChange:f=>b("enabled",f),label:n.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:n.endpoint,onChange:f=>b("endpoint",f.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:n.headers,onChange:f=>b("headers",f.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:n.serviceName,onChange:f=>b("serviceName",f.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(L,{checked:n.includeContent,onChange:f=>b("includeContent",f),label:n.includeContent?"on":"off"})]})]}),t&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:t.enabled?"text-accent":"text-fg-dim",children:String(t.enabled)})]}),t.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",t.error]}),!t.error&&t.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:C,disabled:!u||m,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:m?"saving…":"Save"}),e.jsx("button",{onClick:E,disabled:!u||m,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),x&&e.jsx("span",{className:"text-red-400 text-xs",children:x}),!x&&g&&!u&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function Ge(){const[s,a]=d.useState(null),[t,l]=d.useState(null),[n,r]=d.useState("Copy"),[i,p]=d.useState(!1),[m,v]=d.useState(null),[x,w]=d.useState(null),[g,y]=d.useState(null),[u,b]=d.useState(!1),C=()=>{window.api.telemetry.status().then(l).catch(h=>{console.warn("[product-telemetry] status reload failed:",h==null?void 0:h.message)})};if(d.useEffect(()=>{let h=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([c,O])=>{h||(a(c),l(O))}).catch(c=>{console.warn("[product-telemetry] load failed:",c==null?void 0:c.message)}),()=>{h=!0}},[]),!s||!t)return e.jsx(P,{title:"loading…"});const E=async h=>{w(null);try{const c=await window.api.telemetry.setConfig(h);a(c.config),l(c.status)}catch(c){w(c instanceof Error?c.message:String(c))}},f=h=>{E({...s,enabled:h})},k=h=>{E({...s,enabled:h.turnOff?!1:s.enabled,noticeAckedAt:new Date().toISOString()})},S=async()=>{try{await navigator.clipboard.writeText(s.installId),r("Copied"),setTimeout(()=>r("Copy"),1500)}catch{}},o=async()=>{p(!0),v(null);try{const h=await window.api.telemetry.flushNow();v(`sent ${h.sent.length}, failed ${h.failed.length}`),C()}catch(h){v(h instanceof Error?h.message:String(h))}finally{p(!1)}},j=async()=>{if(u){b(!1);return}try{const h=await window.api.telemetry.recentRecords();y(h),b(!0)}catch(h){console.warn("[product-telemetry] recentRecords failed:",h instanceof Error?h.message:h)}},N=s.lastDailyFlushAt?new Date(s.lastDailyFlushAt).getTime()+_e:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),!s.noticeAckedAt&&e.jsxs("section",{"data-testid":"telemetry-first-run-notice",className:"border border-accent rounded p-3 space-y-2 text-xs",children:[e.jsx("div",{className:"text-fg font-medium",children:"This app sends anonymous product telemetry"}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Collected: a coarse machine profile (OS/arch/app version, no hardware id), error and warning counts, and session counts — sent on start-up, after an update, and once a day."}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Never collected: prompts, transcripts, file paths, project names, email, or username."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{onClick:()=>k({turnOff:!1}),className:"px-3 py-1 rounded bg-accent text-bg",children:"OK"}),e.jsx("button",{onClick:()=>k({turnOff:!0}),className:"px-3 py-1 rounded border border-line text-fg-dim hover:text-fg",children:"Turn off"})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(L,{checked:s.enabled,onChange:f,label:s.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:s.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:S,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:n})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:s.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),x&&e.jsx("div",{className:"text-red-400 text-xs",children:x})]}),t.pendingCount>0&&t.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[t.pendingCount," record",t.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",U(t.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",J(N?new Date(N).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",t.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",t.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",t.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",t.evictedCount]}),t.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",t.backlog.reason,", ",J(t.backlog.ranAt),"):"," ",t.backlog.linesEnqueued," enqueued, ",t.backlog.linesConfirmed," confirmed,"," ",t.backlog.watermarksRewound," watermarks rewound"]}),t.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",t.lastError.message," ","(",U(t.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:o,disabled:i,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:i?"sending…":"Send now"}),m&&e.jsx("span",{className:"text-fg-faint text-xs",children:m})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:j,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:u?"Hide last records":"Inspect last records sent"}),u&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(g??[],null,2)})]})]})}const He={compact:"Compact",roomy:"Roomy"};function Be(){const{model:s,setModel:a}=ee(),{catalog:t}=te(null),{density:l,setDensity:n}=se();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx($,{options:ae(t),value:s,onChange:a,mono:!0}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]}),e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx($,{options:["compact","roomy"],value:l,onChange:r=>n(r),labels:He}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]})]})}function Je({cwd:s}){const[a,t]=d.useState(!1),[l,n]=d.useState(!1),[r,i]=d.useState(!1),[p,m]=d.useState(!1);d.useEffect(()=>{var y,u;let g=!1;return t(!1),Promise.resolve((u=(y=window.api.promptSessions)==null?void 0:y.getWorktreeDisabled)==null?void 0:u.call(y,{cwd:s})).then(b=>{g||(n((b==null?void 0:b.disabled)??!1),i((b==null?void 0:b.disabled)??!1),t(!0))},()=>{g||t(!0)}),()=>{g=!0}},[s]);const v=a&&r!==l,x=()=>{var g,y;m(!0),Promise.resolve((y=(g=window.api.promptSessions)==null?void 0:g.setWorktreeDisabled)==null?void 0:y.call(g,{cwd:s,disabled:r})).then(u=>{n((u==null?void 0:u.disabled)??r),i((u==null?void 0:u.disabled)??r)}).catch(u=>ne.error(u instanceof Error?u.message:String(u))).finally(()=>m(!1))},w=()=>i(l);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:!a||p,onChange:g=>i(g.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),v&&e.jsx(q,{dirty:v,busy:p,onSave:x,onRevert:w})]})}const K={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function Ue(){const s=re(),a=G(c=>c.tabs),t=G(c=>c.activeTabId),l=a.find(c=>c.id===t)??null,n=(l==null?void 0:l.cwd)??null,r=le(c=>c.navFace),i=d.useRef(!1),p=d.useRef(r),[m,v]=d.useState(()=>r==="project"&&n?"project":"user"),[x,w]=d.useState("effective");d.useEffect(()=>{if(p.current!==r){if(p.current=r,i.current){i.current=!1;return}v(r==="project"&&n?"project":"user")}},[r,n]),d.useEffect(()=>{r==="project"&&(x==="telemetry"||x==="app")&&w("effective")},[r,x]);const g=c=>{i.current=!0,v(c)},y=me(H,s,n),u=y[m]??null,b=D(c=>c.files),C=D(c=>c.setDraft),E=D(c=>c.saveJson),f=D(c=>c.revert),[k,S]=d.useState(null),o=d.useMemo(()=>ie(oe(b,y)),[b,y]),j=(c,O,A)=>{var F;const M=y[A??m];if(!M)return;S(null);const _=((F=b[M])==null?void 0:F.draftRaw)??"";let I={};if(_.trim())try{I=JSON.parse(_)}catch{I={}}const X=xe(I,c,O);C(M,JSON.stringify(X,null,2)+`
3
3
  `)};if(!s)return e.jsx(P,{title:"loading…"});const N=u?b[u]:null,h=c=>c!=="user"&&!n;return e.jsx(ce,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(ue,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...r==="home"?[{key:"telemetry",label:"Telemetry"},{key:"app",label:"Session Manager"}]:[]],active:x,onChange:w}),x!=="telemetry"&&x!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(pe,{scopes:H.scopes,active:m,onChange:g,annotate:c=>{if(h(c))return{exists:!1};const O=y[c];if(!O)return null;const A=b[O];return{exists:(A==null?void 0:A.exists)??!1,dirty:(A==null?void 0:A.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:x==="effective"?`overrides → ${u??"—"}`:u??"—"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:x!=="telemetry"&&x!=="app"&&u&&N?e.jsx(q,{dirty:N.dirty,busy:N.busy,parseError:k||N.parseError,lastSavedAt:N.lastSavedAt,leading:N.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{S(null);const c=await E(u);c.ok||S(c.error??"save failed")},onRevert:()=>{S(null),f(u)}}):null,children:x==="telemetry"?e.jsx(Fe,{}):x==="app"?e.jsx(Be,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:K[m].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:K[m].body}),u&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:u})]}),m==="project"&&n&&e.jsx(Je,{cwd:n}),h(m)?e.jsx(P,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):x==="effective"?e.jsx(we,{node:o,targetScope:m,onOverride:j,schema:B()}):x==="tree"?e.jsx(fe,{node:o,targetScope:m,onOverride:j,schema:B()}):u&&N?e.jsx(de,{path:u,value:N.draftRaw,onChange:c=>{S(null),C(u,c)}}):e.jsx(P,{title:"resolving…"})]})})}const Xe=d.memo(Ue);export{K as SETTINGS_SCOPE_NOTES,Xe as Settings};
@@ -1,4 +1,4 @@
1
- import{az as Q,R as bo,ah as wo,ak as tr}from"./index-XkrLB67D.js";import"./monaco-editor-BW5C4Iv1.js";function ko(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Ao(e,n,r){return n=Ro(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return Mo(e)||ko(e,n)||fi(e,n)||Oo()}function Co(e){return So(e)||To(e)||fi(e)||Po()}function So(e){if(Array.isArray(e))return gn(e)}function Mo(e){if(Array.isArray(e))return e}function To(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function fi(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Po(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{az as Q,R as bo,ah as wo,ak as tr}from"./index-Cd98Q1lD.js";import"./monaco-editor-BW5C4Iv1.js";function ko(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Ao(e,n,r){return n=Ro(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return Mo(e)||ko(e,n)||fi(e,n)||Oo()}function Co(e){return So(e)||To(e)||fi(e)||Po()}function So(e){if(Array.isArray(e))return gn(e)}function Mo(e){if(Array.isArray(e))return e}function To(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function fi(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Po(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Eo(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function Ro(e){var n=Eo(e,"string");return typeof n=="symbol"?n:String(n)}var zo=function(n,r){var i=new Set(r);return Object.assign.apply(Object,[{}].concat(Co(Object.entries(n).filter(function(o){var a=er(o,1),s=a[0];return!i.has(s)}).map(function(o){var a=er(o,2),s=a[0],u=a[1];return Ao({},s,u)}))))};function yn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function No(e){if(Array.isArray(e))return e}function Io(e){if(Array.isArray(e))return yn(e)}function $o(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Do(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n!==0)for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function jo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.