claude-code-session-manager 0.91.1 → 0.92.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 (47) hide show
  1. package/dist/assets/{AgentLibrary-Chmfxih8.js → AgentLibrary-Bu-1eT_n.js} +1 -1
  2. package/dist/assets/{DataModel-Cp38ePS_.js → DataModel-Bk9rkJ8x.js} +1 -1
  3. package/dist/assets/{History-SMWV7lD6.js → History-BB6wpf02.js} +1 -1
  4. package/dist/assets/{Hooks-JUWiyu-r.js → Hooks-zQZH56Sv.js} +1 -1
  5. package/dist/assets/{HostBilko-DFTixTqy.js → HostBilko-CW0pHoPS.js} +1 -1
  6. package/dist/assets/{Library-zUu71gsR.js → Library-DrGdaz9N.js} +1 -1
  7. package/dist/assets/{ListDetail-BK_PH4lf.js → ListDetail-D4bxU_-2.js} +1 -1
  8. package/dist/assets/{MarkdownEditor-ITJDD0Mr.js → MarkdownEditor-H1ytN4Tk.js} +1 -1
  9. package/dist/assets/{McpServers-CWwrfGkx.js → McpServers-CYSRCI-j.js} +1 -1
  10. package/dist/assets/{Memory-DgHttor9.js → Memory-zMNpJyRU.js} +1 -1
  11. package/dist/assets/{Panel-C2Cb7TS4.js → Panel-RMz3Acpu.js} +1 -1
  12. package/dist/assets/{Permissions-hd8OBsj_.js → Permissions-Be6cIkPg.js} +1 -1
  13. package/dist/assets/{Plugins-BYa-ClGK.js → Plugins-B8sTWf2K.js} +2 -2
  14. package/dist/assets/{ProvenanceBadge-Dmhz8ZOB.js → ProvenanceBadge-CO-DZN38.js} +1 -1
  15. package/dist/assets/{SaveBar-1NvfbO9r.js → SaveBar-xQZ2EBOn.js} +1 -1
  16. package/dist/assets/{Scheduler-SYgINPCB.js → Scheduler-CF3zsJBw.js} +1 -1
  17. package/dist/assets/{ScopeSwitcher-MBmWNzFk.js → ScopeSwitcher-BAfquN6Y.js} +1 -1
  18. package/dist/assets/{Settings-C1WOHoYb.js → Settings-uPjmqutA.js} +1 -1
  19. package/dist/assets/{SkillReferenceGraph-Cuse__ul.js → SkillReferenceGraph-BI1YtCbB.js} +1 -1
  20. package/dist/assets/{Skills-CQmLYgNh.js → Skills-BEy9FDYd.js} +1 -1
  21. package/dist/assets/{SystemPrompt-DkhAYRXL.js → SystemPrompt-BYkkw-LL.js} +1 -1
  22. package/dist/assets/{TagLibrary-DGxI_3m3.js → TagLibrary-Kg3yOC5b.js} +1 -1
  23. package/dist/assets/{TiptapBody-BY-fFjwh.js → TiptapBody-BptXAVR9.js} +1 -1
  24. package/dist/assets/{Toggle--nwLR-_8.js → Toggle-BwiClCSI.js} +1 -1
  25. package/dist/assets/{index-CRPJslSA.css → index-D3P_jldk.css} +1 -1
  26. package/dist/assets/{index-4dEn1t8J.js → index-a2MVk8qh.js} +329 -329
  27. package/dist/assets/{settingsSchema-DiqEpSBA.js → settingsSchema-DgxlStF5.js} +1 -1
  28. package/dist/index.html +2 -2
  29. package/package.json +1 -1
  30. package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +52 -3
  31. package/src/main/__tests__/pty-epic-worktree-spawn-cwd.test.cjs +40 -0
  32. package/src/main/build-info.json +4 -4
  33. package/src/main/chatRunner.cjs +27 -4
  34. package/src/main/config.cjs +5 -0
  35. package/src/main/docEdit.cjs +3 -2
  36. package/src/main/index.cjs +2 -0
  37. package/src/main/lib/__tests__/epicSpawnCwd.test.cjs +58 -2
  38. package/src/main/lib/__tests__/epicSpawnPlan.test.cjs +79 -0
  39. package/src/main/lib/__tests__/updateCheck.test.cjs +63 -0
  40. package/src/main/lib/epicSpawnCwd.cjs +22 -13
  41. package/src/main/lib/epicSpawnPlan.cjs +27 -12
  42. package/src/main/lib/epicTranscriptPath.cjs +3 -2
  43. package/src/main/lib/epicWorktreeMerge.cjs +4 -4
  44. package/src/main/lib/updateCheck.cjs +102 -0
  45. package/src/main/pty.cjs +19 -7
  46. package/src/preload/api.d.ts +2 -0
  47. package/src/preload/index.cjs +1 -0
@@ -1,2 +1,2 @@
1
- import{ah as e,au as c,aN as oe,aI as ie,aP as ce,aK as N,l as O,b as Q,aH as q}from"./index-4dEn1t8J.js";import{P as $}from"./Panel-C2Cb7TS4.js";import{L as de}from"./ListDetail-BK_PH4lf.js";import{S as xe}from"./SaveBar-1NvfbO9r.js";import{S as H}from"./ScopeSwitcher-MBmWNzFk.js";import{P as Y}from"./ProvenanceBadge-Dmhz8ZOB.js";import{M as ue,V as D}from"./Library-zUu71gsR.js";import"./monaco-editor-BW5C4Iv1.js";const pe={live:"bg-emerald-400",idle:"bg-amber-400",offline:"bg-fg-faint",attention:"bg-accent",paused:"bg-zinc-500"},fe={sm:"w-1.5 h-1.5",md:"w-2 h-2"},me={on:"live",off:"offline",warn:"attention",live:"live",idle:"idle"};function W({state:n,kind:t,pulse:a=!1,size:d="sm",className:p="",title:b,"aria-label":o}){const j=n??(t?me[t]:"idle"),r=pe[j],g=fe[d],x=a?"animate-pulse":"",u=o??b??j;return e.jsx("span",{role:"img","aria-label":u,className:`inline-block rounded-full ${g} ${r} ${x} ${p}`.trim(),title:b})}const he={failed:"Failed","needs-auth":"Needs auth",pending:"Pending approval"};function G(n,t){const a=t!=null&&t.ok?t.servers.find(d=>d.name===n):void 0;return!a||a.status==="unknown"?{state:"unprobed",label:"Not checked",probeStatus:(a==null?void 0:a.status)??null,badgeTone:"dim",dotState:"offline"}:a.status==="connected"?{state:"ready",label:"Ready",probeStatus:a.status,badgeTone:"good",dotState:"live"}:{state:"not-ready",label:he[a.status],probeStatus:a.status,badgeTone:"warn",dotState:"attention"}}const U=(n,t)=>({type:"mcp",name:n,command:t.command,args:t.args,url:t.url}),ge=["stdio","http","streamable-http","sse","ws"],be=new Set(["workspace"]),je=new Set(["ide","tasks"]);function ve(n,t,a){return n==="user"?`${t}/.claude.json`:a?`${a}/.mcp.json`:null}function ye(n){if(n.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(n),a=t.mcpServers??{};return{full:t,servers:a,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Ne(n,t){return JSON.stringify({...n,mcpServers:t},null,2)+`
1
+ import{ah as e,au as c,aN as oe,aI as ie,aP as ce,aK as N,l as O,b as Q,aH as q}from"./index-a2MVk8qh.js";import{P as $}from"./Panel-RMz3Acpu.js";import{L as de}from"./ListDetail-D4bxU_-2.js";import{S as xe}from"./SaveBar-xQZ2EBOn.js";import{S as H}from"./ScopeSwitcher-BAfquN6Y.js";import{P as Y}from"./ProvenanceBadge-CO-DZN38.js";import{M as ue,V as D}from"./Library-DrGdaz9N.js";import"./monaco-editor-BW5C4Iv1.js";const pe={live:"bg-emerald-400",idle:"bg-amber-400",offline:"bg-fg-faint",attention:"bg-accent",paused:"bg-zinc-500"},fe={sm:"w-1.5 h-1.5",md:"w-2 h-2"},me={on:"live",off:"offline",warn:"attention",live:"live",idle:"idle"};function W({state:n,kind:t,pulse:a=!1,size:d="sm",className:p="",title:b,"aria-label":o}){const j=n??(t?me[t]:"idle"),r=pe[j],g=fe[d],x=a?"animate-pulse":"",u=o??b??j;return e.jsx("span",{role:"img","aria-label":u,className:`inline-block rounded-full ${g} ${r} ${x} ${p}`.trim(),title:b})}const he={failed:"Failed","needs-auth":"Needs auth",pending:"Pending approval"};function G(n,t){const a=t!=null&&t.ok?t.servers.find(d=>d.name===n):void 0;return!a||a.status==="unknown"?{state:"unprobed",label:"Not checked",probeStatus:(a==null?void 0:a.status)??null,badgeTone:"dim",dotState:"offline"}:a.status==="connected"?{state:"ready",label:"Ready",probeStatus:a.status,badgeTone:"good",dotState:"live"}:{state:"not-ready",label:he[a.status],probeStatus:a.status,badgeTone:"warn",dotState:"attention"}}const U=(n,t)=>({type:"mcp",name:n,command:t.command,args:t.args,url:t.url}),ge=["stdio","http","streamable-http","sse","ws"],be=new Set(["workspace"]),je=new Set(["ide","tasks"]);function ve(n,t,a){return n==="user"?`${t}/.claude.json`:a?`${a}/.mcp.json`:null}function ye(n){if(n.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(n),a=t.mcpServers??{};return{full:t,servers:a,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Ne(n,t){return JSON.stringify({...n,mcpServers:t},null,2)+`
2
2
  `}function we(n){let t=Object.keys(n).length+1,a=`server-${t}`;for(;n[a];)t+=1,a=`server-${t}`;return a}function Se(){const n=oe(),t=ie(),a=(t==null?void 0:t.cwd)??null,d=ce(s=>s.navFace),p=c.useRef(!1),b=c.useRef(d),[o,j]=c.useState(()=>d==="project"&&a?"project":"user"),[r,g]=c.useState(null),[x,u]=c.useState("installed"),[w,_]=c.useState("");c.useEffect(()=>{if(b.current!==d){if(b.current=d,p.current){p.current=!1;return}j(d==="project"&&a?"project":"user")}},[d,a]);const f=c.useMemo(()=>n?ve(o,n,a):null,[n,o,a]),k=N(s=>s.files),l=N(s=>s.loadJson),v=N(s=>s.setDraft),m=N(s=>s.saveJson),I=N(s=>s.revert),T=N(s=>s.watchFile),X=N(s=>s.unwatchFile);c.useEffect(()=>{if(f)return k[f]||l(f),T(f),()=>X(f)},[f]);const[ee,R]=c.useState(null),[J,K]=c.useState(null),[B,z]=c.useState(!1),F=c.useRef(0),A=c.useRef(!0);c.useEffect(()=>()=>{A.current=!1},[]);const V=async()=>{const s=++F.current;z(!0);try{const i=await window.api.mcp.status();if(!A.current||s!==F.current)return;K(i),i.ok||q.error(i.error??"MCP status probe failed")}catch(i){if(!A.current||s!==F.current)return;K(null),q.error(i.message||"MCP status probe failed")}finally{A.current&&s===F.current&&z(!1)}};if(c.useEffect(()=>{V()},[]),!n)return e.jsx(O,{title:"loading…"});if(x==="library")return e.jsx($,{toolbar:e.jsx(D,{active:x,onChange:u}),children:e.jsx(ue,{})});if(o==="project"&&!a)return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(D,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(H,{scopes:["user","project"],active:o,onChange:s=>{p.current=!0,j(s)}})]}),children:e.jsx(O,{title:"no active project"})});if(!f)return e.jsx(O,{title:"loading…"});const y=k[f],{full:te,servers:h,err:se}=y?ye(y.draftRaw):{full:{},servers:{},err:null},L=Object.keys(h).sort(),M=r?h[r]:null,P=s=>{R(null),v(f,Ne(te,s))},ae=()=>{const s=we(h);P({...h,[s]:{type:"stdio",command:"",args:[]}}),g(s)},le=s=>{const i={...h};delete i[s],P(i),r===s&&g(null)},ne=(s,i)=>{if(!i||i===s||h[i])return;const S={};for(const C of Object.keys(h))S[C===s?i:C]=h[C];P(S),g(i)},re=(s,i)=>{P({...h,[s]:i})};return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(D,{active:x,onChange:u}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(H,{scopes:["user","project"],active:o,onChange:s=>{p.current=!0,j(s)}}),e.jsxs("span",{className:"ml-3 px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-faint",children:[L.length," server",L.length===1?"":"s"]}),e.jsx("span",{className:"ml-2 text-fg-faint truncate",children:f}),e.jsx("div",{className:"flex-1"}),r&&M&&e.jsx(Y,{scope:o,input:U(r,M),className:"mr-2"}),e.jsx("button",{onClick:V,disabled:B,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50 mr-2",children:B?"checking…":"⟳ test connections"}),e.jsx("button",{onClick:ae,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ new server"})]}),footer:y?e.jsx(xe,{dirty:y.dirty,busy:y.busy,parseError:ee||se||y.parseError,lastSavedAt:y.lastSavedAt,onSave:async()=>{R(null);const s=await m(f);s.ok||R(s.error??"save failed")},onRevert:()=>{R(null),I(f)}}):null,children:e.jsx(de,{sidebar:e.jsxs("div",{className:"py-2",children:[e.jsx("div",{className:"px-2 pb-1",children:e.jsx("input",{value:w,onChange:s=>_(s.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),L.length===0?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no servers"}):L.filter(s=>!w||s.toLowerCase().includes(w.toLowerCase())).map(s=>{var C;const i=G(s,J),S=(C=h[s].description)==null?void 0:C.trim();return e.jsxs("button",{onClick:()=>g(s),className:`w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 ${r===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(W,{state:i.dotState,title:i.label}),e.jsx("span",{className:"truncate",children:s})]}),e.jsxs("span",{className:"ml-2 flex items-center gap-2 shrink-0",children:[e.jsx(Q,{tone:i.badgeTone,children:i.label}),e.jsx(Y,{interactive:!1,scope:o,input:U(s,h[s])}),e.jsx("span",{className:"text-fg-faint",children:h[s].type??"stdio"})]})]}),S?e.jsx("span",{className:"pl-5 text-fg-faint truncate",title:S,children:S}):null]},s)})]}),detail:r&&M?e.jsx(Ce,{name:r,server:M,connection:G(r,J),onTestConnection:V,testing:B,onRename:s=>ne(r,s),onChange:s=>re(r,s),onRemove:()=>le(r)}):e.jsx(O,{title:"select a server or click + new"})})})}const Pe=c.memo(Se);function Ce({name:n,server:t,connection:a,onTestConnection:d,testing:p,onRename:b,onChange:o,onRemove:j}){var k;const r=t.type??"stdio",g=be.has(n),x=je.has(n),u=(k=t.permissions)==null?void 0:k.tools,w=u===void 0?"inherit":u==="allow"?"allow":u==="deny"?"deny":"list",_=Array.isArray(u)?u:[],f=(t.disabledTools??[]).join(", ");return e.jsxs("div",{className:"p-4 space-y-4 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{state:a.dotState,size:"md",title:a.label}),e.jsx(Q,{tone:a.badgeTone,children:a.label}),e.jsx("button",{onClick:d,disabled:p,className:"ml-auto px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-50",children:p?"checking…":"test connection"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),e.jsx("input",{defaultValue:n,onBlur:l=>b(l.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("button",{onClick:j,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),e.jsx(E,{label:"description",value:t.description??"",onChange:l=>o({...t,description:l||void 0}),placeholder:"what this server does…"}),g?e.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:n})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):x?e.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",e.jsx("span",{className:"font-mono",children:n})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),e.jsx("select",{value:r,onChange:l=>o({...t,type:l.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:ge.map(l=>e.jsx("option",{value:l,children:l},l))}),r==="sse"?e.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),r==="stdio"?e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"command",value:t.command??"",onChange:l=>o({...t,command:l}),placeholder:"npx / node / python …"}),e.jsx(E,{label:"args",value:(t.args??[]).join(" "),onChange:l=>o({...t,args:l.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),e.jsx(Z,{label:"env",value:t.env??{},onChange:l=>o({...t,env:l})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{label:"url",value:t.url??"",onChange:l=>o({...t,url:l}),placeholder:"https://…"}),e.jsx(Z,{label:"headers",value:t.headers??{},onChange:l=>o({...t,headers:l})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:l=>o({...t,alwaysLoad:l.target.checked||void 0})}),e.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:"enabled"}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[e.jsx("input",{type:"checkbox",checked:t.enabled!==!1,onChange:l=>o({...t,enabled:l.target.checked?void 0:!1})}),e.jsx("span",{className:"text-fg-dim",children:"load this server in new sessions"})]})]}),e.jsx(E,{label:"disabledTools",value:f,onChange:l=>{const v=l.split(",").map(m=>m.trim()).filter(Boolean);o({...t,disabledTools:v.length?v:void 0})},placeholder:"comma-separated tool names to hide"}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs("select",{value:w,onChange:l=>{const v=l.target.value,m={...t};if(v==="inherit"){if(m.permissions){const{tools:I,...T}=m.permissions;m.permissions=Object.keys(T).length?T:void 0}}else v==="list"?m.permissions={...m.permissions??{},tools:[]}:m.permissions={...m.permissions??{},tools:v};o(m)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[e.jsx("option",{value:"inherit",children:"inherit (default)"}),e.jsx("option",{value:"allow",children:"allow all tools"}),e.jsx("option",{value:"deny",children:"deny all tools"}),e.jsx("option",{value:"list",children:"allowlist…"})]}),w==="list"?e.jsx("input",{value:_.join(", "),onChange:l=>{const v=l.target.value.split(",").map(m=>m.trim()).filter(Boolean);o({...t,permissions:{...t.permissions??{},tools:v}})},placeholder:"comma-separated tool names",className:"w-full bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}):null]})]})]})}function E({label:n,value:t,onChange:a,placeholder:d}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20",children:n}),e.jsx("input",{value:t,onChange:p=>a(p.target.value),placeholder:d,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function Z({label:n,value:t,onChange:a}){const[d,p]=c.useState(""),[b,o]=c.useState(""),j=Object.entries(t);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:n}),e.jsxs("div",{className:"flex-1 space-y-1",children:[j.map(([r,g])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:r,onChange:x=>{const u={...t};delete u[r],u[x.target.value]=g,a(u)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("input",{value:g,onChange:x=>a({...t,[r]:x.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:()=>{const x={...t};delete x[r],a(x)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},r)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:d,onChange:r=>p(r.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("input",{value:b,onChange:r=>o(r.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),e.jsx("button",{onClick:()=>{d.trim()&&(a({...t,[d.trim()]:b}),p(""),o(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}export{Pe as McpServers,we as nextServerName};
@@ -1,4 +1,4 @@
1
- import{aN as Y,aI as K,au as l,aH as A,ah as e,l as F,W as oe,a5 as H,$ as le,a9 as I,V as q}from"./index-4dEn1t8J.js";import{P as ee}from"./Panel-C2Cb7TS4.js";import{L as te}from"./ListDetail-BK_PH4lf.js";import{M as se}from"./MarkdownEditor-ITJDD0Mr.js";import"./monaco-editor-BW5C4Iv1.js";function ie(t){return!t||!t.trim()?"default":t.replace(/[^a-zA-Z0-9]/g,"-")}const re=/^[a-z0-9-_]+$/;function ce(t,o,r,i){return t.filter(m=>!o||m.name.toLowerCase().includes(o.toLowerCase())).filter(m=>{var s;return!r||((s=i[m.name])==null?void 0:s.stale)===!0})}const de=["Commands:"," list — show all memory entries"," show <slug> — read one entry"," search <text> — find entries containing <text>"," forget <slug> — delete an entry (with confirm)"," remember <free-form> — ask Claude to save this"," help — this message","","Anything else: I will offer to send it to Claude in the terminal,","or add it as a new memory entry directly."].join(`
1
+ import{aN as Y,aI as K,au as l,aH as A,ah as e,l as F,W as oe,a5 as H,$ as le,a9 as I,V as q}from"./index-a2MVk8qh.js";import{P as ee}from"./Panel-RMz3Acpu.js";import{L as te}from"./ListDetail-D4bxU_-2.js";import{M as se}from"./MarkdownEditor-H1ytN4Tk.js";import"./monaco-editor-BW5C4Iv1.js";function ie(t){return!t||!t.trim()?"default":t.replace(/[^a-zA-Z0-9]/g,"-")}const re=/^[a-z0-9-_]+$/;function ce(t,o,r,i){return t.filter(m=>!o||m.name.toLowerCase().includes(o.toLowerCase())).filter(m=>{var s;return!r||((s=i[m.name])==null?void 0:s.stale)===!0})}const de=["Commands:"," list — show all memory entries"," show <slug> — read one entry"," search <text> — find entries containing <text>"," forget <slug> — delete an entry (with confirm)"," remember <free-form> — ask Claude to save this"," help — this message","","Anything else: I will offer to send it to Claude in the terminal,","or add it as a new memory entry directly."].join(`
2
2
  `);function me(t){const o=t.trim();if(!o)return{kind:"freeform",arg:"",raw:t};const r=o.toLowerCase();if(r==="help"||r==="?")return{kind:"help",arg:"",raw:t};if(r==="list"||r==="ls"||r==="list memories"||r==="list all"||r==="what do you remember"||r==="what do you remember?")return{kind:"list",arg:"",raw:t};const i=o.match(/^(?:show|read|open)\s+(.+)$/i);if(i)return{kind:"show",arg:i[1].trim(),raw:t};const m=o.match(/^(?:forget|delete|remove)\s+(.+)$/i);if(m)return{kind:"forget",arg:m[1].trim(),raw:t};const s=o.match(/^(?:search|find)\s+(.+)$/i)||o.match(/^what (?:do )?you know about\s+(.+?)\??$/i);if(s)return{kind:"search",arg:s[1].trim(),raw:t};const u=o.match(/^remember(?:\s+that)?\s+(.+)$/i)||o.match(/^note(?:\s+that)?\s+(.+)$/i)||o.match(/^save(?:\s+that)?\s+(.+)$/i);return u?{kind:"remember",arg:u[1].trim(),raw:t}:{kind:"freeform",arg:o,raw:t}}function G(t,o){const r=t.toLowerCase().replace(/\.md$/,""),i=o.find(u=>u.name.replace(/\.md$/,"").toLowerCase()===r);if(i)return i;const m=o.filter(u=>u.name.replace(/\.md$/,"").toLowerCase().startsWith(r));if(m.length===1)return m[0];const s=o.filter(u=>u.name.replace(/\.md$/,"").toLowerCase().includes(r));return s.length===1?s[0]:null}function Z(t){const o=new Set(["the","a","an","is","are","to","of","in","for","and","or"]);return t.toLowerCase().replace(/[^a-z0-9\s-]/g," ").split(/\s+/).filter(m=>m&&!o.has(m)).slice(0,4).join("-").replace(/-+/g,"-").replace(/^-|-$/g,"")||`note-${Date.now().toString(36).slice(-4)}`}function Q(t,o){return[`Please save this to my workspace memory (workspace: ${t}).`,`Use the memory tool (or write a markdown file under ~/.claude/projects/${t}/memory/).`,"Pick a short kebab-case filename and add a one-line title at the top.","","Memory to save:",o].join(`
3
3
  `)}function X(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function xe({workspace:t,entries:o,onChanged:r}){const i=Y(),m=K(),s=(m==null?void 0:m.id)??null,[u,f]=l.useState(""),[c,b]=l.useState(()=>[{id:X(),role:"system",text:"Hi — I am the memory assistant for this workspace. Type `help` for what I understand, or just talk to me."}]),[C,g]=l.useState(!1),N=l.useRef(null),$=l.useRef(null);l.useEffect(()=>{const a=N.current;a&&(a.scrollTop=a.scrollHeight)},[c]);const x=l.useCallback(a=>{b(p=>[...p,{...a,id:X()}])},[]),S=l.useCallback(()=>{if(o.length===0){x({role:"result",text:"No memories saved for this workspace yet."});return}x({role:"result",text:`Found ${o.length} ${o.length===1?"memory":"memories"}:`,payload:{kind:"entries",entries:o}})},[o,x]),T=l.useCallback(async a=>{const p=G(a,o);if(!p){x({role:"result",text:`No memory matches "${a}". Try \`list\` to see what is here.`});return}const y=await window.api.memory.read(p.name,t);if(y.error){A.error(`Memory read failed: ${y.error}`),x({role:"result",text:`Read failed: ${y.error}`});return}x({role:"result",text:`${p.name}`,payload:{kind:"entry",entry:p,content:y.content}})},[o,t,x]),B=l.useCallback(async a=>{const p=a.toLowerCase(),y=o.filter(k=>k.name.toLowerCase().includes(p)),O=[];for(const k of o){if(y.includes(k))continue;const L=await window.api.memory.read(k.name,t);if(L.error)continue;const d=L.content.split(`
4
4
  `),h=d.findIndex(w=>w.toLowerCase().includes(p));h>=0&&O.push({entry:k,snippet:d[h].trim().slice(0,200)})}const n=[...y.map(k=>({entry:k,snippet:"(filename match)"})),...O];if(n.length===0){x({role:"result",text:`No matches for "${a}".`});return}x({role:"result",text:`Found ${n.length} ${n.length===1?"match":"matches"} for "${a}":`,payload:{kind:"search",query:a,hits:n}})},[o,t,x]),D=l.useCallback(async a=>{const p=G(a,o);if(!p){x({role:"result",text:`No memory matches "${a}". Try \`list\` to see what is here.`});return}if(!window.confirm(`Delete memory "${p.name}"? This cannot be undone.`))return;const y=await window.api.memory.delete(p.name,t);if(!y.ok){A.error(`Memory delete failed: ${y.error??"unknown error"}`),x({role:"result",text:`Delete failed: ${y.error??"unknown error"}`});return}x({role:"result",text:`Deleted ${p.name}.`}),r()},[o,t,x,r]),v=l.useCallback(a=>{const p=Z(a),y=Q(t,a);x({role:"result",text:"I do not write to memory from this panel. Send the request to Claude in the active terminal, or add it directly as a new memory entry below.",payload:{kind:"suggest-send",prompt:y,original:a}}),x({role:"result",text:`Add it directly as \`${p}.md\` instead?`,payload:{kind:"suggest-add",slug:p,content:a}})},[t,x]),_=l.useCallback(a=>{const p=Z(a),y=Q(t,a);x({role:"result",text:"Not a recognised command. Options:",payload:{kind:"suggest-send",prompt:y,original:a}}),x({role:"result",text:`…or save it directly as \`${p}.md\`.`,payload:{kind:"suggest-add",slug:p,content:a}})},[t,x]),M=l.useCallback(async a=>{g(!0);try{switch(a.kind){case"list":S();break;case"show":await T(a.arg);break;case"search":await B(a.arg);break;case"forget":await D(a.arg);break;case"help":x({role:"result",text:de});break;case"remember":v(a.arg);break;case"freeform":_(a.arg);break}}finally{g(!1)}},[S,T,B,D,v,_,x]),R=l.useCallback(async()=>{const a=u.trim();!a||C||(f(""),x({role:"user",text:a}),await M(me(a)))},[u,C,M,x]),j=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),R())},E=l.useCallback(a=>{if(!s){A.error("No active terminal session — open or focus a tab first.");return}window.api.pty.write({tabId:s,data:a}),A.info("Prompt sent to active terminal (not submitted)")},[s]),P=l.useCallback(async(a,p)=>{if(!re.test(a)){A.error(`Invalid slug "${a}" — must be [a-z0-9-_]+`);return}const y=`${a}.md`,O=await window.api.memory.create(y,void 0,t);if(!O.ok){A.error(`Create failed: ${O.error??"unknown error"}`);return}const n=await window.api.memory.read(y,t),k=n.error?p:`${n.content.trimEnd()}
@@ -1 +1 @@
1
- import{ah as e}from"./index-4dEn1t8J.js";function n({toolbar:s,footer:l,children:r}){return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:s}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:r}),l&&e.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:l})]})}export{n as P};
1
+ import{ah as e}from"./index-a2MVk8qh.js";function n({toolbar:s,footer:l,children:r}){return e.jsxs("div",{className:"h-full flex flex-col",children:[s&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:s}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:r}),l&&e.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:l})]})}export{n as P};
@@ -1,3 +1,3 @@
1
- import{au as d,aN as B,aI as H,aP as W,aK as N,aj as q,an as G,ad as Q,ah as e,l as w,P as D,V as U,az as X}from"./index-4dEn1t8J.js";import{P as A}from"./Panel-C2Cb7TS4.js";import{S as Y}from"./ScopeSwitcher-MBmWNzFk.js";import{S as Z}from"./SaveBar-1NvfbO9r.js";import{P as ee}from"./Library-zUu71gsR.js";import{u as te,E as se,s as re}from"./settingsSchema-DiqEpSBA.js";import"./monaco-editor-BW5C4Iv1.js";const ne=["allow","deny","ask"];function ae(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function oe(r,n){const a={...r,permissions:n};return JSON.stringify(a,null,2)+`
1
+ import{au as d,aN as B,aI as H,aP as W,aK as N,aj as q,an as G,ad as Q,ah as e,l as w,P as D,V as U,az as X}from"./index-a2MVk8qh.js";import{P as A}from"./Panel-RMz3Acpu.js";import{S as Y}from"./ScopeSwitcher-BAfquN6Y.js";import{S as Z}from"./SaveBar-xQZ2EBOn.js";import{P as ee}from"./Library-DrGdaz9N.js";import{u as te,E as se,s as re}from"./settingsSchema-DgxlStF5.js";import"./monaco-editor-BW5C4Iv1.js";const ne=["allow","deny","ask"];function ae(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function oe(r,n){const a={...r,permissions:n};return JSON.stringify(a,null,2)+`
2
2
  `}function ie(){const r=B(),n=H(),a=(n==null?void 0:n.cwd)??null,s=W(t=>t.navFace),i=d.useRef(!1),u=d.useRef(s),[p,c]=d.useState(()=>s==="project"&&a?"project":"user"),[m,P]=d.useState("effective");d.useEffect(()=>{if(u.current!==s){if(u.current=s,i.current){i.current=!1;return}c(s==="project"&&a?"project":"user")}},[s,a]),d.useEffect(()=>{s==="project"&&m==="presets"&&P("effective")},[s,m]);const I=t=>{i.current=!0,c(t)},b=te(D,r,a),f=b[p]??null,j=N(t=>t.files),E=N(t=>t.setDraft),J=N(t=>t.saveJson),O=N(t=>t.revert),[M,y]=d.useState(null),k=e.jsx(U,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:m,onChange:P}),$=d.useMemo(()=>{const t=q(G(j,b));return Q(t,["permissions"])??{kind:"object",children:{}}},[j,b]),F=(t,l)=>{var R;const o=b[p];if(!o)return;y(null);const g=((R=j[o])==null?void 0:R.draftRaw)??"";let v={};if(g.trim())try{v=JSON.parse(g)}catch{v={}}const V=X(v.permissions??{},t,l),z={...v,permissions:V};E(o,JSON.stringify(z,null,2)+`
3
3
  `)};if(!r)return e.jsx(w,{title:"loading…"});if(m==="presets")return e.jsx(A,{toolbar:k,children:e.jsx(ee,{})});const C=t=>t!=="user"&&!a,h=f?j[f]:null,{perms:x,full:L,err:T}=h?ae(h.draftRaw):{perms:{},full:{},err:null},S=t=>{f&&(y(null),E(f,oe(L,t)))},_=(t,l)=>{const o=l.trim();if(!o)return;const g=x[t]??[];g.includes(o)||S({...x,[t]:[...g,o]})},K=(t,l)=>{const o=x[t]??[];S({...x,[t]:o.filter((g,v)=>v!==l)})};return e.jsx(A,{toolbar:e.jsxs(e.Fragment,{children:[k,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(Y,{scopes:D.scopes,active:p,onChange:I,annotate:t=>{if(C(t))return{exists:!1};const l=b[t];if(!l)return null;const o=j[l];return{exists:(o==null?void 0:o.exists)??!1,dirty:(o==null?void 0:o.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:f??"—"}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings#permissions",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"rule syntax ↗"})]}),footer:f&&h?e.jsx(Z,{dirty:h.dirty,busy:h.busy,parseError:M||T||h.parseError,lastSavedAt:h.lastSavedAt,onSave:async()=>{y(null);const t=await J(f);t.ok||y(t.error??"save failed")},onRevert:()=>{y(null),O(f)}}):null,children:C(p)?e.jsx(w,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):m==="effective"?e.jsx(se,{node:$,targetScope:p,onOverride:F,schema:re().rootedAt(["permissions"]),rootLabel:"permissions"}):f&&h?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[e.jsx(le,{value:x.defaultMode??"default",onChange:t=>S({...x,defaultMode:t})}),ne.map(t=>e.jsx(ce,{list:t,rules:x[t]??[],onAdd:l=>_(t,l),onRemove:l=>K(t,l)},t)),e.jsx(de,{dirs:x.additionalDirectories??[],onChange:t=>S({...x,additionalDirectories:t})})]}):e.jsx(w,{title:"resolving…"})})}const ve=d.memo(ie);function le({value:r,onChange:n}){const a=["default","acceptEdits","plan","bypassPermissions"];return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Default Mode"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:a.map(s=>e.jsx("button",{onClick:()=>n(s),className:`px-2.5 py-1 text-xs transition-colors ${r===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ce({list:r,rules:n,onAdd:a,onRemove:s}){const[i,u]=d.useState(""),p=r==="allow"?"text-green-400":r==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${p}`,children:r}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,onChange:c=>u(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(a(i),u(""))},placeholder:r==="allow"?"e.g. Bash(ls:*) or Read(~/.claude/**)":"e.g. Write(/etc/**)",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"}),e.jsx("button",{onClick:()=>{a(i),u("")},disabled:!i.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((c,m)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:c}),e.jsx("button",{onClick:()=>s(m),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${m}-${c}`))})]})}function de({dirs:r,onChange:n}){const[a,s]=d.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:a,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a.trim()&&(n([...r,a.trim()]),s(""))},placeholder:"/absolute/path/to/dir",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"})}),e.jsx("ul",{className:"space-y-0.5",children:r.map((i,u)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:i}),e.jsx("button",{onClick:()=>n(r.filter((p,c)=>c!==u)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${u}-${i}`))})]})}export{ve as Permissions};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-Cuse__ul.js","./index-4dEn1t8J.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./index-CRPJslSA.css"])))=>i.map(i=>d[i]);
2
- import{ah as e,au as p,l as y,aN as X,aH as R,b as Y}from"./index-4dEn1t8J.js";import{P as V}from"./Panel-C2Cb7TS4.js";import{P as z}from"./ProvenanceBadge-Dmhz8ZOB.js";import{e as Z}from"./Library-zUu71gsR.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as ee}from"./monaco-editor-BW5C4Iv1.js";import{L as te}from"./ListDetail-BK_PH4lf.js";import{M as ne}from"./MarkdownEditor-ITJDD0Mr.js";function se({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:m}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:m??"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(f=>e.jsx("td",{className:`px-3 py-1 ${f.className??""}`,children:f.render(l)},f.key))},r)})})]})}async function ie(t,n,o){var f,b;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 m=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!m)return null;const l=(b=(f=i.plugins[m])==null?void 0:f[0])==null?void 0:b.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function ae(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,m=await window.api.config.readText(i);if(!m.exists)continue;const l=G(m.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function le(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const m=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${m}\\b`,`\`${m}\``];if(i.id.length>=4&&l.push(`\\b${m}\\b`),!l.some(f=>new RegExp(f,"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 re=p.lazy(()=>ee(()=>import("./SkillReferenceGraph-Cuse__ul.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function oe({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var b;const[i,m]=p.useState(a??((b=n[0])==null?void 0:b.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=p.useMemo(()=>le(n),[n]),[d,f]=p.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:()=>f("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:()=>f("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(y,{title:"no skills in this plugin"}):d==="graph"?e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(re,{skills:n,edges:r,selectedId:i,onSelect:m})}):e.jsx(te,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>m(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(ne,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(y,{title:"select a skill"})})})]})}const q=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 ce(){const t=X(),[n,o]=p.useState([]),[a,i]=p.useState(!0),[m,l]=p.useState(null),[r,d]=p.useState("installed"),[f,b]=p.useState(null),[c,L]=p.useState(new Set);p.useEffect(()=>{var x,k;let s=!1;return(k=(x=window.api.app).seedStatus)==null||k.call(x).then(j=>{s||b(j)}).catch(()=>{}),()=>{s=!0}},[]),p.useEffect(()=>{if(!t)return;let s=!1;return(async()=>{var k;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 w=j.data;for(const[C,A]of Object.entries(w.plugins??{})){if(!Array.isArray(A))continue;const _=C.split("@")[0],u=C.split("@")[1];for(const g of A){if(!(g!=null&&g.installPath))continue;const B={name:_,path:g.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},v=await fe(B);(k=v.manifest)!=null&&k.version||(v.manifest={...v.manifest??{},version:g.version}),v.marketplace=u,x.push(v)}}}}catch{}s||(x.sort((j,w)=>j.name.localeCompare(w.name)),s||(o(x),i(!1)))})(),()=>{s=!0}},[t]);const S=[{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(z,{interactive:!1,input:q(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})}],$=p.useMemo(()=>f?Object.keys(f).filter(s=>f[s].status==="exhausted"&&!c.has(s)):[],[f,c]),E=$.length>0?e.jsx(de,{seeders:$,seedStatus:f,onDismiss:s=>L(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(V,{toolbar:e.jsx(W,{active:r,onChange:d}),children:[E,e.jsx(Z,{})]});const h=m?n.find(s=>s.path===m)??null:null;return e.jsxs(V,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(W,{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:[E,a?e.jsx(y,{title:"scanning plugins…"}):h?e.jsx(me,{row:h,home:t,onBack:()=>l(null)},h.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(se,{columns:S,rows:n,getKey:s=>s.path,activeKey:m,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 ke=p.memo(ce),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function de({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 W({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 j,w,C,A,_;const[a,i]=p.useState([]),[m,l]=p.useState([]),[r,d]=p.useState([]),[f,b]=p.useState([]),[c,L]=p.useState("skills"),[S,$]=p.useState(null),[E,h]=p.useState(!0);p.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{h(!0);try{const[g,B,v,Q]=await Promise.all([ie(t.name,t.path,n),O(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),O(`${t.path}/bin`,{filesOnly:!0})]),J=g?await ae(g):[],T=B.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),I=[];T.forEach((N,F)=>{const M=U[F];if(!M.exists)return;const D=G(M.text);I.push({id:N,name:D.name??N.replace(/\.md$/,""),description:D.description})});const H=[];if(v&&v.exists&&!v.parseError&&v.data&&typeof v.data=="object"){const N=v.data.mcpServers;if(N&&typeof N=="object")for(const[F,M]of Object.entries(N)){const D=M&&typeof M=="object"?M.command:void 0;H.push({id:F,name:F,description:typeof D=="string"?D:null})}}if(u)return;i(J),l(I),d(H),b(Q),L(J.length>0?"skills":I.length>0?"agents":H.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(g){if(u)return;R.error(`Failed to load plugin contents: ${g instanceof Error?g.message:String(g)}`),i([]),l([]),d([]),b([])}finally{u||h(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const s=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:m.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:f.length}],x=(j=t.manifest)!=null&&j.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,k=async u=>{const g=await window.api.shell.open({as:"external",url:u});g.ok||R.error(g.error??`Failed to open ${u}`)};return S?e.jsx(oe,{pluginName:((w=t.manifest)==null?void 0:w.name)??t.name,skills:a,initialSelectedId:S.id,onBack:()=>$(null)},S.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:((C=t.manifest)==null?void 0:C.name)??t.name}),(A=t.manifest)!=null&&A.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(_=t.manifest)!=null&&_.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(z,{input:q(t)}),t.hasMcp?e.jsx(Y,{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:[x?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),x]}):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:()=>k(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:s.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:E?e.jsx(y,{title:"scanning…"}):e.jsx(he,{active:c,row:t,skills:a,agents:m,mcpServers:r,files:f,onOpenSkill:$})})]})]})}function he({active:t,row:n,skills:o,agents:a,mcpServers:i,files:m,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(P,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(P,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(P,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:e.jsx(P,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:e.jsx(P,{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(P,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(y,{title:"no components"}):m.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:m.map((r,d)=>e.jsx(P,{n:d+1,name:r,description:null},r))})}function P({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 fe(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 h=await window.api.config.readJson(n);h.exists&&!h.parseError&&h.data&&typeof h.data=="object"&&(a=h.data)}const[i,m,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 h=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(h.data)?d=h.data.length:h.data&&typeof h.data=="object"&&Array.isArray(h.data.monitors)&&(d=h.data.monitors.length)}let f=0;if(r){const h=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(h.data&&typeof h.data=="object"){const s=h.data;f=Object.values(s).reduce((x,k)=>Array.isArray(k)?x+k.reduce((j,w)=>j+(Array.isArray(w.hooks)?w.hooks.length:0),0):x,0)}}const[b,c,L]=await Promise.all([O(`${t.path}/agents`,{filesOnly:!0}),O(`${t.path}/bin`,{filesOnly:!0}),O(`${t.path}/skills`,{dirsOnly:!0})]),S=b.filter(h=>h.endsWith(".md")).length,$=c.length,E=L.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:f,agents:S,skills:E,binCount:$,hasMcp:m}}async function O(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{ke as Plugins};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-BI1YtCbB.js","./index-a2MVk8qh.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./index-D3P_jldk.css"])))=>i.map(i=>d[i]);
2
+ import{ah as e,au as p,l as y,aN as X,aH as R,b as Y}from"./index-a2MVk8qh.js";import{P as V}from"./Panel-RMz3Acpu.js";import{P as z}from"./ProvenanceBadge-CO-DZN38.js";import{e as Z}from"./Library-DrGdaz9N.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as ee}from"./monaco-editor-BW5C4Iv1.js";import{L as te}from"./ListDetail-D4bxU_-2.js";import{M as ne}from"./MarkdownEditor-H1ytN4Tk.js";function se({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:m}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:m??"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(f=>e.jsx("td",{className:`px-3 py-1 ${f.className??""}`,children:f.render(l)},f.key))},r)})})]})}async function ie(t,n,o){var f,b;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 m=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!m)return null;const l=(b=(f=i.plugins[m])==null?void 0:f[0])==null?void 0:b.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function ae(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,m=await window.api.config.readText(i);if(!m.exists)continue;const l=G(m.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function le(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const m=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${m}\\b`,`\`${m}\``];if(i.id.length>=4&&l.push(`\\b${m}\\b`),!l.some(f=>new RegExp(f,"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 re=p.lazy(()=>ee(()=>import("./SkillReferenceGraph-BI1YtCbB.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function oe({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var b;const[i,m]=p.useState(a??((b=n[0])==null?void 0:b.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=p.useMemo(()=>le(n),[n]),[d,f]=p.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:()=>f("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:()=>f("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(y,{title:"no skills in this plugin"}):d==="graph"?e.jsx(p.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(re,{skills:n,edges:r,selectedId:i,onSelect:m})}):e.jsx(te,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>m(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(ne,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(y,{title:"select a skill"})})})]})}const q=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 ce(){const t=X(),[n,o]=p.useState([]),[a,i]=p.useState(!0),[m,l]=p.useState(null),[r,d]=p.useState("installed"),[f,b]=p.useState(null),[c,L]=p.useState(new Set);p.useEffect(()=>{var x,k;let s=!1;return(k=(x=window.api.app).seedStatus)==null||k.call(x).then(j=>{s||b(j)}).catch(()=>{}),()=>{s=!0}},[]),p.useEffect(()=>{if(!t)return;let s=!1;return(async()=>{var k;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 w=j.data;for(const[C,A]of Object.entries(w.plugins??{})){if(!Array.isArray(A))continue;const _=C.split("@")[0],u=C.split("@")[1];for(const g of A){if(!(g!=null&&g.installPath))continue;const B={name:_,path:g.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},v=await fe(B);(k=v.manifest)!=null&&k.version||(v.manifest={...v.manifest??{},version:g.version}),v.marketplace=u,x.push(v)}}}}catch{}s||(x.sort((j,w)=>j.name.localeCompare(w.name)),s||(o(x),i(!1)))})(),()=>{s=!0}},[t]);const S=[{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(z,{interactive:!1,input:q(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})}],$=p.useMemo(()=>f?Object.keys(f).filter(s=>f[s].status==="exhausted"&&!c.has(s)):[],[f,c]),E=$.length>0?e.jsx(de,{seeders:$,seedStatus:f,onDismiss:s=>L(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(V,{toolbar:e.jsx(W,{active:r,onChange:d}),children:[E,e.jsx(Z,{})]});const h=m?n.find(s=>s.path===m)??null:null;return e.jsxs(V,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(W,{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:[E,a?e.jsx(y,{title:"scanning plugins…"}):h?e.jsx(me,{row:h,home:t,onBack:()=>l(null)},h.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(se,{columns:S,rows:n,getKey:s=>s.path,activeKey:m,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 ke=p.memo(ce),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function de({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 W({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 j,w,C,A,_;const[a,i]=p.useState([]),[m,l]=p.useState([]),[r,d]=p.useState([]),[f,b]=p.useState([]),[c,L]=p.useState("skills"),[S,$]=p.useState(null),[E,h]=p.useState(!0);p.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{h(!0);try{const[g,B,v,Q]=await Promise.all([ie(t.name,t.path,n),O(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),O(`${t.path}/bin`,{filesOnly:!0})]),J=g?await ae(g):[],T=B.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),I=[];T.forEach((N,F)=>{const M=U[F];if(!M.exists)return;const D=G(M.text);I.push({id:N,name:D.name??N.replace(/\.md$/,""),description:D.description})});const H=[];if(v&&v.exists&&!v.parseError&&v.data&&typeof v.data=="object"){const N=v.data.mcpServers;if(N&&typeof N=="object")for(const[F,M]of Object.entries(N)){const D=M&&typeof M=="object"?M.command:void 0;H.push({id:F,name:F,description:typeof D=="string"?D:null})}}if(u)return;i(J),l(I),d(H),b(Q),L(J.length>0?"skills":I.length>0?"agents":H.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(g){if(u)return;R.error(`Failed to load plugin contents: ${g instanceof Error?g.message:String(g)}`),i([]),l([]),d([]),b([])}finally{u||h(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const s=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:m.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:f.length}],x=(j=t.manifest)!=null&&j.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,k=async u=>{const g=await window.api.shell.open({as:"external",url:u});g.ok||R.error(g.error??`Failed to open ${u}`)};return S?e.jsx(oe,{pluginName:((w=t.manifest)==null?void 0:w.name)??t.name,skills:a,initialSelectedId:S.id,onBack:()=>$(null)},S.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:((C=t.manifest)==null?void 0:C.name)??t.name}),(A=t.manifest)!=null&&A.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(_=t.manifest)!=null&&_.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(z,{input:q(t)}),t.hasMcp?e.jsx(Y,{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:[x?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),x]}):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:()=>k(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:s.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:E?e.jsx(y,{title:"scanning…"}):e.jsx(he,{active:c,row:t,skills:a,agents:m,mcpServers:r,files:f,onOpenSkill:$})})]})]})}function he({active:t,row:n,skills:o,agents:a,mcpServers:i,files:m,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(P,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(P,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(P,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:e.jsx(P,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:e.jsx(P,{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(P,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(y,{title:"no components"}):m.length===0?e.jsx(y,{title:"no components"}):e.jsx("div",{children:m.map((r,d)=>e.jsx(P,{n:d+1,name:r,description:null},r))})}function P({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 fe(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 h=await window.api.config.readJson(n);h.exists&&!h.parseError&&h.data&&typeof h.data=="object"&&(a=h.data)}const[i,m,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 h=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(h.data)?d=h.data.length:h.data&&typeof h.data=="object"&&Array.isArray(h.data.monitors)&&(d=h.data.monitors.length)}let f=0;if(r){const h=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(h.data&&typeof h.data=="object"){const s=h.data;f=Object.values(s).reduce((x,k)=>Array.isArray(k)?x+k.reduce((j,w)=>j+(Array.isArray(w.hooks)?w.hooks.length:0),0):x,0)}}const[b,c,L]=await Promise.all([O(`${t.path}/agents`,{filesOnly:!0}),O(`${t.path}/bin`,{filesOnly:!0}),O(`${t.path}/skills`,{dirsOnly:!0})]),S=b.filter(h=>h.endsWith(".md")).length,$=c.length,E=L.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:f,agents:S,skills:E,binCount:$,hasMcp:m}}async function O(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{ke as Plugins};
@@ -1 +1 @@
1
- import{$ as P,aN as G,au as x,ah as i,Z as R,B as T,b as _}from"./index-4dEn1t8J.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-zUu71gsR.js";const N=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(N(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(N(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),$=new Set,j=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)])),J=new Set(S.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(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(E.map(e=>e.command.trim())),F=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(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 $.has(t)?l("official MCP server (catalog)"):j.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?y("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.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":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&F.has(t))return l("built-in Claude Code command");if(Q.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"},O={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(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!b)return;const s=C=>{v.current&&!v.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)}},[b]);const w=ne(e.type,t??null,e.name),f=te(e),p=d[w],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:O[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:v,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}),b&&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(w,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[O[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(w,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{$ as P,aN as G,au as x,ah as i,Z as R,B as T,b as _}from"./index-a2MVk8qh.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-DrGdaz9N.js";const N=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(N(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(N(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),$=new Set,j=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)])),J=new Set(S.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(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(E.map(e=>e.command.trim())),F=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(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 $.has(t)?l("official MCP server (catalog)"):j.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?y("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.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":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&F.has(t))return l("built-in Claude Code command");if(Q.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"},O={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(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!b)return;const s=C=>{v.current&&!v.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)}},[b]);const w=ne(e.type,t??null,e.name),f=te(e),p=d[w],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:O[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:v,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}),b&&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(w,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[O[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(w,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{ah as e,ab as x}from"./index-4dEn1t8J.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{ah as e,ab as x}from"./index-a2MVk8qh.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{ay as Ce,ao as te,aC as ts,ac as ke,a6 as se,aa as z,aH as J,aT as Ee,aR as oe,au as h,aX as ss,a4 as pe,ah as t,c as Fe,I as he,L as rt,o as ns,K as ue,r as as,H as rs,d as is,Q as ls,am as kt,aW as Se,y as Ie,as as Re,a as Ke,aB as Qe,a7 as it,G as St,t as Ct,n as $t,p as os,m as ze,v as Xe,O as ds,D as ee,f as B,a8 as Dt,aQ as Pt,at as cs,T as us,ap as lt,aL as ot,l as ye,u as dt,k as ps,aF as hs,U as fs,s as At,aN as xs,aK as ve,z as gs,C as ms,aU as bs,av as ws,N as vs,aY as js,aV as ct,aA as ys}from"./index-4dEn1t8J.js";import{l as Ns}from"./listSkills-QORduPIk.js";import{T as ks}from"./Toggle--nwLR-_8.js";import"./monaco-editor-BW5C4Iv1.js";function Ss(e){const s=new Map(e.map(l=>[l.slug,l])),n=new Map,a=new Set,c=[];function p(l){n.set(l,1),c.push(l);const i=s.get(l);for(const d of(i==null?void 0:i.dependsOn)??[]){if(!s.has(d))continue;const r=n.get(d);if(r===1){const o=c.indexOf(d);for(let u=o;u<c.length;u++)a.add(c[u])}else r===void 0&&p(d)}c.pop(),n.set(l,2)}for(const l of e)n.has(l.slug)||p(l.slug);return a}function Cs(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 $s(e,s,n){const a=new Set(e.map(r=>r.slug)),c=new Set;for(const r of e)for(const o of r.dependsOn??[])a.has(o)&&c.add(o);const p=new Map,l=[];for(const r of e){const o=n.has(r.slug)?void 0:(r.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));o?(p.has(o)||p.set(o,[]),p.get(o).push(r)):l.push(r)}const i=(r,o)=>r.slug.localeCompare(o.slug);l.sort(i);for(const r of p.values())r.sort(i);function d(r,o,u){const f=Cs(r,s),m=n.has(r.slug);u.add(r.slug);const g=m?[]:(p.get(r.slug)??[]).filter(b=>!u.has(b.slug)).map(b=>d(b,o+1,u));return u.delete(r.slug),{row:r,depth:o,children:g,blockers:f,blocked:f.some(b=>!b.missing&&b.status!=="completed"),hasNeedsReviewBlocker:f.some(b=>b.needsReview),hasMissingDep:f.some(b=>b.missing),cycle:m,parallelEligible:(r.dependsOn??[]).length===0&&!c.has(r.slug)}}return l.map(r=>d(r,0,new Set))}function Mt(e,s,n){const a=new Map((n??e).map(r=>[r.slug,r])),c=Ss(e),p=[],l=new Map,i=new Map;for(const r of e){const o=Ce(r,s),u=o.epicId??"__none__";l.has(u)||(p.push(u),l.set(u,[]),i.set(u,{epicId:o.epicId,label:o.known&&o.label?o.label:o.epicId?`Epic ${o.epicId.slice(0,12)}…`:"No Epic",known:o.known})),l.get(u).push(r)}const d=p.map(r=>{const o=i.get(r),u=l.get(r),f=$s(u,a,c),m={};for(const g of u){const b=g.status??"unknown";m[b]=(m[b]??0)+1}return{epicId:o.epicId,label:o.label,known:o.known,nodes:f,counts:m,total:u.length}});return d.sort((r,o)=>r.epicId===null?1:o.epicId===null?-1:r.known!==o.known?r.known?-1:1:r.label.localeCompare(o.label)),d}function Te(e){const s=[],n=a=>{s.push(a);for(const c of a.children)n(c)};for(const a of e)n(a);return s}const Ds=15e4,Ve=e=>e==="completed"||e==="skipped",Ne=e=>e==="running"||e==="investigating",Rt=e=>e==="failed"||e==="needs_review"||e==="quarantined",Ps=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Et(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),c=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(c).padStart(2,"0")}s`:`${c}s`}function It(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 Tt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Et(s)}function As(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const c=Date.parse(a.finishedAt)-Date.parse(a.startedAt);c>0&&(s+=c,n++)}return n===0?Ds:s/n}function Je(e){const s=te(e);return s===null?1/0:Number(s)}function ut(e,s){const n=Je(e.slug)-Je(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ms(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Rs(e){return e.some(n=>Ne(n.status))?"active":e.every(n=>Ve(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Es(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 Ze(e,s){if(e.length===0)return[];const n=s.now??Date.now(),a=s.avgDurationMs??As(e),c=Math.max(1,s.concurrency??1),p=new Map(e.map(o=>[o.slug,o])),l=o=>o.status==="pending"&&(o.dependsOn??[]).every(u=>p.get(u)===void 0||p.get(u).status==="completed"),i=new Map;e.filter(l).sort(ut).forEach((o,u)=>i.set(o.slug,u));const d=Mt(e,s.sessions,e),r=[];for(const o of d){const u=Te(o.nodes),f=new Set(u.map(k=>k.row.slug)),m=new Map(u.map(k=>[k.row.slug,k])),g=new Map,b=new Set,w=k=>{const S=m.get(k);return(S.row.dependsOn??[]).filter(_=>f.has(_)&&!(S.cycle&&m.get(_).cycle))},D=k=>{const S=g.get(k);if(S!==void 0)return S;if(b.has(k))return 0;b.add(k);let _=0;for(const O of w(k))_=Math.max(_,D(O));return b.delete(k),g.set(k,_+1),_+1};for(const k of u)D(k.row.slug);const $=u.map(k=>{const S=k.row,_=(S.dependsOn??[]).filter(O=>f.has(O));return{slug:S.slug,title:S.title,status:S.status,stage:g.get(S.slug),prdNumber:te(S.slug),rowKind:"dep",rowTrailing:"",cycle:k.cycle,estimateMinutes:S.estimateMinutes??null,deps:_,crossEpicDeps:(S.dependsOn??[]).filter(O=>!f.has(O)),blockers:k.blockers,job:S}});$.sort(ut);const I=$.reduce((k,S)=>Math.max(k,S.stage),0),x=new Map;for(const k of $){const S=k.job,_=m.get(k.slug),O=S.status;let H;if(Ve(O)){const L=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;H={kind:"done",trailing:L>0?Et(L):"",held:!1,blocked:!1}}else if(Ne(O)){const L=S.startedAt?Math.max(0,n-Date.parse(S.startedAt)):null;H={kind:"running",trailing:L===null?"":Tt(S,L),held:!1,blocked:!1}}else if(O==="failed")H={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(O==="needs_review")H={kind:"review",trailing:"review",held:!1,blocked:!1};else if(O==="quarantined")H={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const L=_.blockers.filter(U=>!U.missing&&U.status!=="completed");if(L.length>0){const U=L.some(A=>Ps(A.status)),Y=L[0].slug;H={kind:"dep",trailing:`←${te(Y)??Y}`,held:!U,blocked:U}}else if(S.heldReason)H={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const U=Ms(S),Y=i.get(S.slug)??0;H=U>0?{kind:"retry",trailing:`${U} ${U===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:It(Y*a/c),held:!1,blocked:!1}}}x.set(k.slug,H)}const E=[];for(let k=1;k<=I;k++){const S=$.filter(q=>q.stage===k),_=S.find(q=>{const W=x.get(q.slug).kind;return q.status==="pending"&&(W==="eta"||W==="retry")});if(_){const q=x.get(_.slug);q.kind="next",q.trailing="next"}let O=0,H=0,L=0,U=0,Y=0,A=0;for(const q of S){const W=x.get(q.slug);q.rowKind=W.kind,q.rowTrailing=W.trailing,Ve(q.status)?O++:Ne(q.status)?H++:q.status==="pending"?(Y++,W.held&&L++,W.blocked&&U++):Rt(q.status)&&A++}const G=O===S.length?"done":H>0?"running":U+A>0?"blocked":L>0?"held":"pending",F={n:k,rows:S,doneCount:O,runningCount:H,heldCount:L,blockedCount:U};E.push({...F,state:G,summary:Es(G,F,Y,A)})}let N=0;for(const k of $){const S=k.estimateMinutes?k.estimateMinutes*6e4:a;if(k.status==="pending")N+=S;else if(Ne(k.status)){const _=k.job.startedAt?Math.max(0,n-Date.parse(k.job.startedAt)):0;N+=Math.max(0,S-_)}}const P=$.reduce((k,S)=>Math.min(k,Je(S.slug)),1/0);r.push({epicId:o.epicId,index:0,label:o.known?ts(o.label).title:o.label,status:Rs($),prdCount:$.length,stageCount:I,doneCount:E.reduce((k,S)=>k+S.doneCount,0),runningCount:E.reduce((k,S)=>k+S.runningCount,0),heldCount:E.reduce((k,S)=>k+S.heldCount,0),blockedCount:E.reduce((k,S)=>k+S.blockedCount,0),etaMs:N/c,stages:E,_firstNum:P})}return r.sort((o,u)=>o._firstNum!==u._firstNum?o._firstNum<u._firstNum?-1:1:(o.epicId??"").localeCompare(u.epicId??"")),r.map(({_firstNum:o,...u},f)=>({...u,index:f+1}))}function Is(e,s=Date.now()){const n=new Map(e.map(f=>[f.slug,f])),a=new Date(s).toDateString();let c=0,p=0,l=0,i=0,d=0,r=0,o=0;for(const f of e)f.status==="pending"?(p++,(f.dependsOn??[]).every(g=>n.get(g)===void 0||n.get(g).status==="completed")&&c++):Ne(f.status)?o++:f.status==="failed"?l++:f.status==="needs_review"?i++:f.status==="quarantined"?d++:f.status==="completed"&&f.finishedAt&&new Date(Date.parse(f.finishedAt)).toDateString()===a&&r++;let u=null;if(l+i+d>0){for(const f of Ze(e,{sessions:{},now:s}))for(const m of f.stages)if(m.rows.some(g=>Rt(g.status))){(u===null||m.n<u)&&(u=m.n);break}}return{readyNow:c,totalQueued:p,heldByDeps:p-c,needsYou:l+i+d,needsYouStage:u,failedCount:l,needsReviewCount:i,doneToday:r,inFlight:o}}function Ts(e){const s=new Map;for(const d of e.stages)for(const r of d.rows)s.set(r.slug,r);const n=d=>{var r;return((r=s.get(d))==null?void 0:r.cycle)===!0},a=new Map,c=new Set,p=(d,r)=>d.chain.length!==r.chain.length?d.chain.length>r.chain.length:d.est!==r.est?d.est>r.est:d.chain.join("\0")<r.chain.join("\0"),l=d=>{const r=a.get(d);if(r)return r;const o=s.get(d),u=o.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let f=null;for(const g of o.deps){if(!s.has(g)||o.cycle&&n(g))continue;const b=l(g);(!f||p(b,f))&&(f=b)}c.delete(d);const m=f?{chain:[...f.chain,d],est:f.est+u}:{chain:[d],est:u};return a.set(d,m),m};let i=null;for(const d of s.keys()){const r=l(d);(!i||p(r,i))&&(i=r)}return i?i.chain:[]}function _t({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:p,paused:l,nextReset:i,utilization:d,effectiveConcurrency:r}=e;let o=0,u=0;for(const D of p)D.status==="pending"?o++:D.status==="completed"&&u++;const f=a.length,m=o+f,g=(r==null?void 0:r.cap)??5;if(f>0){const D=a.reduce((N,P)=>(N.startedAt??"")<(P.startedAt??"")?N:P),$=D.startedAt?s-Date.parse(D.startedAt):0,I=u+f,x=u+m,E=f>1?` · ${f}/${g} parallel`:"";return{kind:"running",line1:`Running ${I}/${x}${E} · ${ke($)}`,line2:f===1?D.title:a.map(N=>N.title).join(", "),tooltip:a.map(N=>`${N.slug} (g${N.parallelGroup})`).join("; ")}}if(l){const D=l.resumeAt?Date.parse(l.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)"}[l.reason]??`Paused — ${l.reason}`,line2:l.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":D!==null&&D>0?`auto-resume ${se(Date.parse(l.resumeAt))} (in ${z(D)})`:l.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:l.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(m===0)return{kind:"idle",line1:"No work queued",line2:null};const b=c.firePolicy??"when-available";if(b==="manual")return{kind:"manual",line1:`Manual · ${o} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(J.fromOutcome).catch(()=>J.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(b==="on-reset"){if(!i)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const D=Date.parse(i)+c.offsetMinutes*6e4,$=D-s;return{kind:"on-reset",line1:`On-reset · ${o} pending`,line2:$>0?`fires ${se(D)} (in ${z($)})`:"firing now…"}}const w=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${o} pending`,line2:"checking token availability…"};if(d>=w){const D=i?Date.parse(i)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${w}%)`,line2:D&&D>0?`next reset ${se(Date.parse(i))} (in ${z(D)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${o} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const _s=15e3,Os=new Set(["failed","needs_review","quarantined"]);function pt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>Os.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function Ls(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 ${z(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?z(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function Fs(e){const[s,n]=h.useState(null);return h.useEffect(()=>{let a=!0;const c=()=>{window.api.schedule.queueHealth(e).then(l=>{a&&n(l)}).catch(()=>{})};c();const p=setInterval(c,_s);return()=>{a=!1,clearInterval(p)}},[e]),s}const qs={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 Bs(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function Hs(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 qe="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 Gs(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 ${z(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 Us({now:e}){const s=Ee(o=>o.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),p=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",l="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",r="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:`${l} ${p?i:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:Gs(n.reason,n.resumeAt,e)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:r,children:"Resume"})]}),a.map(([o,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${l} ${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:o})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${z(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:r,children:"Retry now"})]},`launch-block-${o}`)),c.map(([o,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${l} ${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:o})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([f,m])=>`${f}=${m}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${o}`))]})}function Vs({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:p,onPlanMode:l,planToolsRef:i}){const d=Ee(y=>y.snapshot),r=oe(y=>y.sessions),o=Fs(e),[u,f]=h.useState(()=>Date.now()),[m,g]=h.useState("—");h.useEffect(()=>{const y=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(y)},[]),h.useEffect(()=>{let y=!0;return ss(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(M=>{if(!y)return;const R=M.totals,K=R.inputTokens+R.outputTokens+R.cacheReadTokens+R.cacheCreationTokens;g(`$${R.estimatedCostUsd.toFixed(2)} · ${Hs(K)} tok`)}).catch(()=>{}),()=>{y=!1}},[]);const b=h.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(y=>!e||y.cwd===e),[d,e]),w=h.useMemo(()=>Is(b,u),[b,u]),D=h.useMemo(()=>{const y=Ze(b,{sessions:r,now:u}),M=R=>y.filter(K=>K.status===R).length;return{active:M("active"),queued:M("queued"),draft:M("draft")}},[b,r,u]),$=h.useMemo(()=>{const y=new Date(u).toDateString(),M=[];for(const R of b)if(R.status==="completed"&&R.startedAt&&R.finishedAt&&new Date(Date.parse(R.finishedAt)).toDateString()===y){const K=Date.parse(R.finishedAt)-Date.parse(R.startedAt);K>0&&M.push(K)}return M.length?Math.round(M.reduce((R,K)=>R+K,0)/M.length/6e4):null},[b,u]);if(!d)return null;const I=o&&!o.unknown?o.verdict??null:null,x=o&&!o.unknown?o.slots??null:null,E=d.paused,N=Bs((I==null?void 0:I.kind)??null,!!E,w.inFlight),P=qs[N],k=b.filter(y=>y.status==="pending").length,S=b.filter(y=>y.status==="running").length,_=_t({snap:{...d,jobs:b},now:u,avgDurationMs:0,runningJobs:b.filter(y=>y.status==="running")}),O=o!=null&&o.unknown?`Queue health: unknown — ${o.reason??"state unavailable"}`:I?Ls(I,(o==null?void 0:o.oldestRunningAgeMs)??null):"queue health loading…",H=pe(d.lastRunAt?Date.parse(d.lastRunAt):null,u),L=o!=null&&o.lastDispatchAttemptAt?pe(Date.parse(o.lastDispatchAttemptAt),u):"never",U=[O,_.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(o==null?void 0:o.oldestRunningAgeMs)!=null?`oldest running ${z(o.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${H} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${L} (advances on every driver evaluation)`].filter(Boolean).join(`
1
+ import{ay as Ce,ao as te,aC as ts,ac as ke,a6 as se,aa as z,aH as J,aT as Ee,aR as oe,au as h,aX as ss,a4 as pe,ah as t,c as Fe,I as he,L as rt,o as ns,K as ue,r as as,H as rs,d as is,Q as ls,am as kt,aW as Se,y as Ie,as as Re,a as Ke,aB as Qe,a7 as it,G as St,t as Ct,n as $t,p as os,m as ze,v as Xe,O as ds,D as ee,f as B,a8 as Dt,aQ as Pt,at as cs,T as us,ap as lt,aL as ot,l as ye,u as dt,k as ps,aF as hs,U as fs,s as At,aN as xs,aK as ve,z as gs,C as ms,aU as bs,av as ws,N as vs,aY as js,aV as ct,aA as ys}from"./index-a2MVk8qh.js";import{l as Ns}from"./listSkills-QORduPIk.js";import{T as ks}from"./Toggle-BwiClCSI.js";import"./monaco-editor-BW5C4Iv1.js";function Ss(e){const s=new Map(e.map(l=>[l.slug,l])),n=new Map,a=new Set,c=[];function p(l){n.set(l,1),c.push(l);const i=s.get(l);for(const d of(i==null?void 0:i.dependsOn)??[]){if(!s.has(d))continue;const r=n.get(d);if(r===1){const o=c.indexOf(d);for(let u=o;u<c.length;u++)a.add(c[u])}else r===void 0&&p(d)}c.pop(),n.set(l,2)}for(const l of e)n.has(l.slug)||p(l.slug);return a}function Cs(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 $s(e,s,n){const a=new Set(e.map(r=>r.slug)),c=new Set;for(const r of e)for(const o of r.dependsOn??[])a.has(o)&&c.add(o);const p=new Map,l=[];for(const r of e){const o=n.has(r.slug)?void 0:(r.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));o?(p.has(o)||p.set(o,[]),p.get(o).push(r)):l.push(r)}const i=(r,o)=>r.slug.localeCompare(o.slug);l.sort(i);for(const r of p.values())r.sort(i);function d(r,o,u){const f=Cs(r,s),m=n.has(r.slug);u.add(r.slug);const g=m?[]:(p.get(r.slug)??[]).filter(b=>!u.has(b.slug)).map(b=>d(b,o+1,u));return u.delete(r.slug),{row:r,depth:o,children:g,blockers:f,blocked:f.some(b=>!b.missing&&b.status!=="completed"),hasNeedsReviewBlocker:f.some(b=>b.needsReview),hasMissingDep:f.some(b=>b.missing),cycle:m,parallelEligible:(r.dependsOn??[]).length===0&&!c.has(r.slug)}}return l.map(r=>d(r,0,new Set))}function Mt(e,s,n){const a=new Map((n??e).map(r=>[r.slug,r])),c=Ss(e),p=[],l=new Map,i=new Map;for(const r of e){const o=Ce(r,s),u=o.epicId??"__none__";l.has(u)||(p.push(u),l.set(u,[]),i.set(u,{epicId:o.epicId,label:o.known&&o.label?o.label:o.epicId?`Epic ${o.epicId.slice(0,12)}…`:"No Epic",known:o.known})),l.get(u).push(r)}const d=p.map(r=>{const o=i.get(r),u=l.get(r),f=$s(u,a,c),m={};for(const g of u){const b=g.status??"unknown";m[b]=(m[b]??0)+1}return{epicId:o.epicId,label:o.label,known:o.known,nodes:f,counts:m,total:u.length}});return d.sort((r,o)=>r.epicId===null?1:o.epicId===null?-1:r.known!==o.known?r.known?-1:1:r.label.localeCompare(o.label)),d}function Te(e){const s=[],n=a=>{s.push(a);for(const c of a.children)n(c)};for(const a of e)n(a);return s}const Ds=15e4,Ve=e=>e==="completed"||e==="skipped",Ne=e=>e==="running"||e==="investigating",Rt=e=>e==="failed"||e==="needs_review"||e==="quarantined",Ps=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Et(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),c=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(c).padStart(2,"0")}s`:`${c}s`}function It(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 Tt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Et(s)}function As(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const c=Date.parse(a.finishedAt)-Date.parse(a.startedAt);c>0&&(s+=c,n++)}return n===0?Ds:s/n}function Je(e){const s=te(e);return s===null?1/0:Number(s)}function ut(e,s){const n=Je(e.slug)-Je(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ms(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Rs(e){return e.some(n=>Ne(n.status))?"active":e.every(n=>Ve(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Es(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 Ze(e,s){if(e.length===0)return[];const n=s.now??Date.now(),a=s.avgDurationMs??As(e),c=Math.max(1,s.concurrency??1),p=new Map(e.map(o=>[o.slug,o])),l=o=>o.status==="pending"&&(o.dependsOn??[]).every(u=>p.get(u)===void 0||p.get(u).status==="completed"),i=new Map;e.filter(l).sort(ut).forEach((o,u)=>i.set(o.slug,u));const d=Mt(e,s.sessions,e),r=[];for(const o of d){const u=Te(o.nodes),f=new Set(u.map(k=>k.row.slug)),m=new Map(u.map(k=>[k.row.slug,k])),g=new Map,b=new Set,w=k=>{const S=m.get(k);return(S.row.dependsOn??[]).filter(_=>f.has(_)&&!(S.cycle&&m.get(_).cycle))},D=k=>{const S=g.get(k);if(S!==void 0)return S;if(b.has(k))return 0;b.add(k);let _=0;for(const O of w(k))_=Math.max(_,D(O));return b.delete(k),g.set(k,_+1),_+1};for(const k of u)D(k.row.slug);const $=u.map(k=>{const S=k.row,_=(S.dependsOn??[]).filter(O=>f.has(O));return{slug:S.slug,title:S.title,status:S.status,stage:g.get(S.slug),prdNumber:te(S.slug),rowKind:"dep",rowTrailing:"",cycle:k.cycle,estimateMinutes:S.estimateMinutes??null,deps:_,crossEpicDeps:(S.dependsOn??[]).filter(O=>!f.has(O)),blockers:k.blockers,job:S}});$.sort(ut);const I=$.reduce((k,S)=>Math.max(k,S.stage),0),x=new Map;for(const k of $){const S=k.job,_=m.get(k.slug),O=S.status;let H;if(Ve(O)){const L=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;H={kind:"done",trailing:L>0?Et(L):"",held:!1,blocked:!1}}else if(Ne(O)){const L=S.startedAt?Math.max(0,n-Date.parse(S.startedAt)):null;H={kind:"running",trailing:L===null?"":Tt(S,L),held:!1,blocked:!1}}else if(O==="failed")H={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(O==="needs_review")H={kind:"review",trailing:"review",held:!1,blocked:!1};else if(O==="quarantined")H={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const L=_.blockers.filter(U=>!U.missing&&U.status!=="completed");if(L.length>0){const U=L.some(A=>Ps(A.status)),Y=L[0].slug;H={kind:"dep",trailing:`←${te(Y)??Y}`,held:!U,blocked:U}}else if(S.heldReason)H={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const U=Ms(S),Y=i.get(S.slug)??0;H=U>0?{kind:"retry",trailing:`${U} ${U===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:It(Y*a/c),held:!1,blocked:!1}}}x.set(k.slug,H)}const E=[];for(let k=1;k<=I;k++){const S=$.filter(q=>q.stage===k),_=S.find(q=>{const W=x.get(q.slug).kind;return q.status==="pending"&&(W==="eta"||W==="retry")});if(_){const q=x.get(_.slug);q.kind="next",q.trailing="next"}let O=0,H=0,L=0,U=0,Y=0,A=0;for(const q of S){const W=x.get(q.slug);q.rowKind=W.kind,q.rowTrailing=W.trailing,Ve(q.status)?O++:Ne(q.status)?H++:q.status==="pending"?(Y++,W.held&&L++,W.blocked&&U++):Rt(q.status)&&A++}const G=O===S.length?"done":H>0?"running":U+A>0?"blocked":L>0?"held":"pending",F={n:k,rows:S,doneCount:O,runningCount:H,heldCount:L,blockedCount:U};E.push({...F,state:G,summary:Es(G,F,Y,A)})}let N=0;for(const k of $){const S=k.estimateMinutes?k.estimateMinutes*6e4:a;if(k.status==="pending")N+=S;else if(Ne(k.status)){const _=k.job.startedAt?Math.max(0,n-Date.parse(k.job.startedAt)):0;N+=Math.max(0,S-_)}}const P=$.reduce((k,S)=>Math.min(k,Je(S.slug)),1/0);r.push({epicId:o.epicId,index:0,label:o.known?ts(o.label).title:o.label,status:Rs($),prdCount:$.length,stageCount:I,doneCount:E.reduce((k,S)=>k+S.doneCount,0),runningCount:E.reduce((k,S)=>k+S.runningCount,0),heldCount:E.reduce((k,S)=>k+S.heldCount,0),blockedCount:E.reduce((k,S)=>k+S.blockedCount,0),etaMs:N/c,stages:E,_firstNum:P})}return r.sort((o,u)=>o._firstNum!==u._firstNum?o._firstNum<u._firstNum?-1:1:(o.epicId??"").localeCompare(u.epicId??"")),r.map(({_firstNum:o,...u},f)=>({...u,index:f+1}))}function Is(e,s=Date.now()){const n=new Map(e.map(f=>[f.slug,f])),a=new Date(s).toDateString();let c=0,p=0,l=0,i=0,d=0,r=0,o=0;for(const f of e)f.status==="pending"?(p++,(f.dependsOn??[]).every(g=>n.get(g)===void 0||n.get(g).status==="completed")&&c++):Ne(f.status)?o++:f.status==="failed"?l++:f.status==="needs_review"?i++:f.status==="quarantined"?d++:f.status==="completed"&&f.finishedAt&&new Date(Date.parse(f.finishedAt)).toDateString()===a&&r++;let u=null;if(l+i+d>0){for(const f of Ze(e,{sessions:{},now:s}))for(const m of f.stages)if(m.rows.some(g=>Rt(g.status))){(u===null||m.n<u)&&(u=m.n);break}}return{readyNow:c,totalQueued:p,heldByDeps:p-c,needsYou:l+i+d,needsYouStage:u,failedCount:l,needsReviewCount:i,doneToday:r,inFlight:o}}function Ts(e){const s=new Map;for(const d of e.stages)for(const r of d.rows)s.set(r.slug,r);const n=d=>{var r;return((r=s.get(d))==null?void 0:r.cycle)===!0},a=new Map,c=new Set,p=(d,r)=>d.chain.length!==r.chain.length?d.chain.length>r.chain.length:d.est!==r.est?d.est>r.est:d.chain.join("\0")<r.chain.join("\0"),l=d=>{const r=a.get(d);if(r)return r;const o=s.get(d),u=o.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let f=null;for(const g of o.deps){if(!s.has(g)||o.cycle&&n(g))continue;const b=l(g);(!f||p(b,f))&&(f=b)}c.delete(d);const m=f?{chain:[...f.chain,d],est:f.est+u}:{chain:[d],est:u};return a.set(d,m),m};let i=null;for(const d of s.keys()){const r=l(d);(!i||p(r,i))&&(i=r)}return i?i.chain:[]}function _t({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:p,paused:l,nextReset:i,utilization:d,effectiveConcurrency:r}=e;let o=0,u=0;for(const D of p)D.status==="pending"?o++:D.status==="completed"&&u++;const f=a.length,m=o+f,g=(r==null?void 0:r.cap)??5;if(f>0){const D=a.reduce((N,P)=>(N.startedAt??"")<(P.startedAt??"")?N:P),$=D.startedAt?s-Date.parse(D.startedAt):0,I=u+f,x=u+m,E=f>1?` · ${f}/${g} parallel`:"";return{kind:"running",line1:`Running ${I}/${x}${E} · ${ke($)}`,line2:f===1?D.title:a.map(N=>N.title).join(", "),tooltip:a.map(N=>`${N.slug} (g${N.parallelGroup})`).join("; ")}}if(l){const D=l.resumeAt?Date.parse(l.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)"}[l.reason]??`Paused — ${l.reason}`,line2:l.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":D!==null&&D>0?`auto-resume ${se(Date.parse(l.resumeAt))} (in ${z(D)})`:l.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:l.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(m===0)return{kind:"idle",line1:"No work queued",line2:null};const b=c.firePolicy??"when-available";if(b==="manual")return{kind:"manual",line1:`Manual · ${o} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(J.fromOutcome).catch(()=>J.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(b==="on-reset"){if(!i)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const D=Date.parse(i)+c.offsetMinutes*6e4,$=D-s;return{kind:"on-reset",line1:`On-reset · ${o} pending`,line2:$>0?`fires ${se(D)} (in ${z($)})`:"firing now…"}}const w=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${o} pending`,line2:"checking token availability…"};if(d>=w){const D=i?Date.parse(i)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${w}%)`,line2:D&&D>0?`next reset ${se(Date.parse(i))} (in ${z(D)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${o} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const _s=15e3,Os=new Set(["failed","needs_review","quarantined"]);function pt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>Os.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function Ls(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 ${z(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?z(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function Fs(e){const[s,n]=h.useState(null);return h.useEffect(()=>{let a=!0;const c=()=>{window.api.schedule.queueHealth(e).then(l=>{a&&n(l)}).catch(()=>{})};c();const p=setInterval(c,_s);return()=>{a=!1,clearInterval(p)}},[e]),s}const qs={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 Bs(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function Hs(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 qe="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 Gs(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 ${z(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 Us({now:e}){const s=Ee(o=>o.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),p=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",l="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",r="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:`${l} ${p?i:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:Gs(n.reason,n.resumeAt,e)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:r,children:"Resume"})]}),a.map(([o,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${l} ${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:o})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${z(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:r,children:"Retry now"})]},`launch-block-${o}`)),c.map(([o,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${l} ${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:o})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([f,m])=>`${f}=${m}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${o}`))]})}function Vs({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:p,onPlanMode:l,planToolsRef:i}){const d=Ee(y=>y.snapshot),r=oe(y=>y.sessions),o=Fs(e),[u,f]=h.useState(()=>Date.now()),[m,g]=h.useState("—");h.useEffect(()=>{const y=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(y)},[]),h.useEffect(()=>{let y=!0;return ss(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(M=>{if(!y)return;const R=M.totals,K=R.inputTokens+R.outputTokens+R.cacheReadTokens+R.cacheCreationTokens;g(`$${R.estimatedCostUsd.toFixed(2)} · ${Hs(K)} tok`)}).catch(()=>{}),()=>{y=!1}},[]);const b=h.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(y=>!e||y.cwd===e),[d,e]),w=h.useMemo(()=>Is(b,u),[b,u]),D=h.useMemo(()=>{const y=Ze(b,{sessions:r,now:u}),M=R=>y.filter(K=>K.status===R).length;return{active:M("active"),queued:M("queued"),draft:M("draft")}},[b,r,u]),$=h.useMemo(()=>{const y=new Date(u).toDateString(),M=[];for(const R of b)if(R.status==="completed"&&R.startedAt&&R.finishedAt&&new Date(Date.parse(R.finishedAt)).toDateString()===y){const K=Date.parse(R.finishedAt)-Date.parse(R.startedAt);K>0&&M.push(K)}return M.length?Math.round(M.reduce((R,K)=>R+K,0)/M.length/6e4):null},[b,u]);if(!d)return null;const I=o&&!o.unknown?o.verdict??null:null,x=o&&!o.unknown?o.slots??null:null,E=d.paused,N=Bs((I==null?void 0:I.kind)??null,!!E,w.inFlight),P=qs[N],k=b.filter(y=>y.status==="pending").length,S=b.filter(y=>y.status==="running").length,_=_t({snap:{...d,jobs:b},now:u,avgDurationMs:0,runningJobs:b.filter(y=>y.status==="running")}),O=o!=null&&o.unknown?`Queue health: unknown — ${o.reason??"state unavailable"}`:I?Ls(I,(o==null?void 0:o.oldestRunningAgeMs)??null):"queue health loading…",H=pe(d.lastRunAt?Date.parse(d.lastRunAt):null,u),L=o!=null&&o.lastDispatchAttemptAt?pe(Date.parse(o.lastDispatchAttemptAt),u):"never",U=[O,_.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(o==null?void 0:o.oldestRunningAgeMs)!=null?`oldest running ${z(o.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${H} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${L} (advances on every driver evaluation)`].filter(Boolean).join(`
2
2
  `),Y=d.utilization,A=d.pollHealth,G=A!=null&&!A.lastPollOk,F=d.nextReset?Date.parse(d.nextReset):null,q=F?F>u?z(F-u):"soon":"—",W=d.effectiveConcurrency,be=(W==null?void 0:W.cap)??5,de=(W==null?void 0:W.source)==="env",v=d.config.firePolicy??"when-available",C=k===0&&S===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Fe,{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":N,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${P.dot}`,"aria-hidden":"true"}),N]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[w.inFlight," in flight · ",w.heldByDeps," held · last batch ",H]}),t.jsxs(he,{title:U,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:U}),rt.scheduler&&t.jsx(ns,{content:rt.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(J.fromOutcome).catch(()=>J.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:qe,children:"Refresh"}),E?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:qe,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:qe,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(J.fromOutcome).catch(()=>J.error("Failed to fire batch")),disabled:C,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(Us,{now:u}),t.jsxs(Fe,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(ue,{testId:"kpi-window",label:"Window used",info:G?`Billing poll failing — this reading may be outdated (last good reading ${pe(A.lastPollAt,u)}). Machine-wide 5h window.`:"Share of the machine-wide 5h billing window consumed.",value:Y==null?"—":`${Math.round(Y)}%`,sub:`resets in ${q}`,third:t.jsx(as,{pct:Y??0,tone:G?"bg-amber-500":"bg-accent"})}),t.jsx(ue,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(x==null?void 0:x.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:x?`${x.inUse}/${x.total}`:"—",sub:"in use",third:x?t.jsx(rs,{filled:x.inUse,total:x.total}):null}),t.jsx(ue,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:w.readyNow,sub:`of ${w.totalQueued} queued`,third:`${w.heldByDeps} held by deps`}),w.needsYou>0?t.jsx(ue,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:pt,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / needs-review / quarantined row",children:w.needsYou}),sub:t.jsx("button",{type:"button",onClick:pt,className:"hover:underline",children:w.needsYouStage!=null?`blocking stage ${w.needsYouStage}`:"need attention"}),third:[w.failedCount>0&&`${w.failedCount} failed`,w.needsReviewCount>0&&`${w.needsReviewCount} needs review`,w.needsYou-w.failedCount-w.needsReviewCount>0&&`${w.needsYou-w.failedCount-w.needsReviewCount} quarantined`].filter(Boolean).join(" · ")}):t.jsx(ue,{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(ue,{testId:"kpi-done",label:"Done today",value:w.doneToday,sub:$!=null?`avg ${$}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:m})}),t.jsx(ue,{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:v,onChange:y=>window.api.schedule.setConfig({firePolicy:y.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(ls,{value:be,min:0,max:10,disabled:de,onChange:y=>{window.api.schedule.setSessionSlots(Math.max(0,Math.min(10,y)))},title:de?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),de&&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:v==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(is,{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:y=>window.api.schedule.setConfig({utilizationThreshold:y})})]}):null})]}),t.jsxs(Fe,{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:[D.active," active · ",D.queued," queued · ",D.draft," draft · ",b.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:y=>c(y.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(([y,M])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${y}`,"aria-pressed":p===y&&s==="queue",onClick:()=>{l(y),n("queue")},className:`px-2 py-0.5 text-[12px] ${p===y&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:M},y))}),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(([y,M,R])=>t.jsx("button",{type:"button",onClick:()=>n(y),"aria-pressed":s===y,title:R,className:`text-[12.5px] ${s===y?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:M},y))]})]})]})}function Ot({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(c=>{const p=c.value===s;return t.jsxs("button",{type:"button",onClick:()=>n(c.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${p?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[c.label,c.count!==void 0&&t.jsxs("span",{children:[" ",c.count]})]},c.value)})})}function Lt(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function Js(e){return Te([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function Ft(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:Js(s)}))}function Ws(e){const s=new Map;for(const n of e){const a=Ft(n);n.nodes.forEach((c,p)=>{const l=a.filter((i,d)=>d!==p);for(const i of Te([c]))s.set(i.row.slug,l)})}return s}function qt({job:e,headChoices:s}){const[n,a]=h.useState(!1),c=h.useCallback((p,l)=>{a(!0),window.api.schedule.setPrdDisposition({slug:e.slug,cwd:e.cwd??void 0,disposition:p,dependsOn:l}).then(J.fromOutcome).catch(()=>J.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:p=>{const l=p.target.value;if(l==="__new-head__")c("new-head");else if(l){const i=s.find(d=>d.rootSlug===l);i&&c("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(p=>t.jsxs("option",{value:p.rootSlug,children:["attach behind: ",Lt(p.label,40)]},p.rootSlug))]})}const Ys=[],Ks=new Set(["failed","needs_review","quarantined"]);function Qs(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 zs(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 Xs(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 Zs({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:c=Ys}){const[p,l]=h.useState(!1),i=e.job,d=s!==null&&e.rowKind==="running"?Tt(i,s):e.rowTrailing,r=e.status==="completed"||e.status==="skipped",o=e.rowKind==="dep"&&e.blockers.some(f=>!f.missing&&f.status!==null&&Ks.has(f.status)),u=r||o;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:()=>l(f=>!f),onFocus:()=>a(n),"aria-expanded":p,"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 ${zs(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${Qs(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 ${u?"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] ${Xs(e)}`,children:d})]}),p&&t.jsx(en,{row:e,elapsedMs:s,headChoices:c})]})}const Bt=h.memo(Zs);function en({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[c,p]=h.useState(!1),l=oe(m=>m.sessions),i=h.useMemo(()=>Ce(a,l),[a,l]),d=i.known&&i.epicId?l[i.epicId]:null,r=h.useCallback(m=>kt(m),[]),o="font-mono text-[11.5px] text-fg-dim leading-snug break-words",u="text-[12px] font-semibold bg-transparent border-0 cursor-pointer p-0",f=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:o,children:[a.status.replace(/_/g," "),a.exitCode!==null&&` · exit ${a.exitCode}`,a.verifierVerdict&&` · ${Se(a.verifierVerdict)}`,a.startedAt&&` · started ${se(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${se(Date.parse(a.finishedAt))}`,s===null&&e.rowTrailing&&e.rowKind==="done"?` · took ${e.rowTrailing}`:""]}),e.cycle&&t.jsxs("div",{className:`${o} text-accent`,"data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",e.blockers.map(m=>m.slug).join(" ↔ ")||"self-referencing"]}),!e.cycle&&e.blockers.length>0&&t.jsxs("div",{className:o,"data-testid":"job-row-blockers",children:["depends on ",e.blockers.map(m=>`${m.slug} (${m.missing?"missing":(m.status??"unknown").replace(/_/g," ")})`).join(", ")]}),a.status==="pending"&&a.heldReason&&t.jsxs("div",{className:`${o} text-amber-400/90`,"data-testid":"job-row-held-reason",children:["held · ",a.heldReason]}),f&&t.jsx("div",{className:`${o} text-accent/80`,children:f}),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:()=>r(d.id),className:`${u} text-accent hover:text-accent/80`,children:"view epic →"}),a.runId&&t.jsx("button",{type:"button",onClick:()=>p(!0),className:`${u} 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(J.fromOutcome).catch(()=>J.error("Failed to adopt PRD"))},className:`${u} 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:`${u} text-fg-dim hover:text-fg`,children:"reset to pending →"}),a.disposition&&(a.status==="pending"||a.status==="quarantined")&&t.jsx(qt,{job:a,headChoices:n})]}),c&&a.runId&&t.jsx(Ie,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>p(!1)})]})}const le=190,tn=7,sn=5,nn=[],Ht=e=>e==="completed"||e==="skipped",Gt=e=>e==="running"||e==="investigating",Ut=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Pe(e){return Gt(e.status)?0:Ut(e.status)?1:Ht(e.status)?3:2}const an={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},rn={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function ln(e,s){return e.every(n=>Ht(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&Ut(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function on({stage:e,epicId:s,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l}){const[i,d]=h.useState(!1),r=h.useMemo(()=>e.rows.filter(x=>!(a.has(x.slug)&&(x.status==="completed"||x.status==="failed"))).map((x,E)=>({r:x,i:E})).sort((x,E)=>Pe(x.r)-Pe(E.r)||x.i-E.i).map(x=>x.r),[e.rows,a]),o=h.useMemo(()=>r.filter(x=>Pe(x)<=1).length,[r]),u=Math.max(e.state==="done"?sn:tn,o),f=i?r:r.slice(0,u),m=i?[]:r.slice(u),g=r.find(x=>x.status==="failed"),b=r.find(x=>x.status==="needs_review"),w=o>0&&(g!==void 0||b!==void 0),D=f.reduce((x,E,N)=>Pe(E)<=1?N:x,-1),$=x=>t.jsx(Bt,{row:x,elapsedMs:Gt(x.status)&&x.job.startedAt?n-Date.parse(x.job.startedAt):null,listIndex:c.get(x.slug)??0,onFocused:l,headChoices:p.get(x.slug)??nn},x.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:le},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 ${rn[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${an[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(he,{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:f.map((x,E)=>t.jsxs("div",{children:[$(x),w&&E===D&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[g&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${g.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(g.slug).then(N=>{N.ok||J.error(N.error??`Failed to reset ${g.slug}`)}).catch(()=>J.error(`Failed to reset ${g.slug}`))},className:I,children:["Retry ",g.prdNumber?`#${g.prdNumber}`:g.slug]}),b&&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&&kt(s)},className:I,children:["Review ",b.prdNumber?`#${b.prdNumber}`:b.slug]})]})]},x.slug))}),(m.length>0||i&&r.length>u)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":i,onClick:()=>d(x=>!x),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 ▴":`${ln(m,e.n)} ▾`})]})}const ge=6,Be=4,Me=4,ht=12,ft=5,Vt=2,xt=4,dn={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function cn(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function un(e){const s=[],n=[],a=[];let c=ft;for(const p of e){const l=Math.max(1,Math.ceil(p.rows.length/Me));n.push(c),a.push(l*ge),p.rows.forEach((i,d)=>{s.push({x:c+Math.floor(d/Me)*ge,y:Vt+d%Me*ge,tone:cn(i.status),title:`${i.prdNumber?`#${i.prdNumber}`:i.slug} ${i.title} — ${i.status}`})}),c+=l*ge+ht}return{dots:s,stageX:n,stageW:a,width:Math.max(0,c-ht)+ft}}function me(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const We=e=>e==="running"||e==="investigating",Ye=e=>e==="failed"||e==="needs_review"||e==="quarantined";function pn({stages:e,first:s,perView:n,onSeek:a}){const c=h.useMemo(()=>un(e),[e]),p=h.useMemo(()=>me(e,We)>=0,[e]),l=h.useMemo(()=>me(e,Ye)>=0,[e]),i=h.useRef(!1),d=e.length,r=Math.min(d-1,s+n-1),o=c.stageX[Math.min(s,d-1)]??0,u=(c.stageX[r]??0)+(c.stageW[r]??0),f=g=>{const b=g.currentTarget.getBoundingClientRect(),w=g.clientX-b.left;let D=0;for(let $=0;$<d;$++)c.stageX[$]<=w&&(D=$);a(Math.max(0,Math.min(d-1,D-Math.floor(n/2))))},m="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(he,{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:c.width,height:Me*ge-(ge-Be)+2*Vt},onPointerDown:g=>{var b,w;i.current=!0,(w=(b=g.currentTarget).setPointerCapture)==null||w.call(b,g.pointerId),f(g)},onPointerMove:g=>{i.current&&f(g)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},children:[c.dots.map((g,b)=>t.jsx("span",{title:g.title,"data-tone":g.tone,className:`absolute rounded-[1px] ${dn[g.tone]}`,style:{left:g.x,top:g.y,width:Be,height:Be}},b)),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:o-xt,width:u-o+2*xt}})]}),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),"–",r+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:!p,title:p?"Scroll to the lowest stage with a running PRD":"No stage has a running PRD",onClick:()=>a(me(e,We)),className:`${m} text-fg-dim hover:text-fg`,children:"Running"}),t.jsx("button",{type:"button","data-testid":"minimap-blockers",disabled:!l,title:l?"Scroll to the lowest stage with a failed / needs-review / quarantined PRD":"No stage has a failed, needs-review or quarantined PRD",onClick:()=>a(me(e,Ye)),className:`${m} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const hn=148;function fn({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:hn},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(he,{title:"Stages beyond the visible window. Click one to scroll the stage columns to it."})]}),e.map(c=>{const p=c.rows.length===0?0:c.doneCount/c.rows.length*100;return t.jsxs("button",{type:"button","data-testid":"further-stage-row","data-stage":c.n,title:`${c.summary} — scroll to stage ${c.n}`,onClick:()=>s(c.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 ",c.n]}),t.jsx("span",{role:"progressbar","aria-valuenow":c.doneCount,"aria-valuemin":0,"aria-valuemax":c.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:`${p}%`}})})]},c.n)})]})}const xn=[],gn=e=>e==="running"||e==="investigating";function mn(e){const s=Ts(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 c=new Map;let p=0;const l=[];for(const i of s){const d=n.get(i);p+=d.estimateMinutes??0,c.set(d.stage,(c.get(d.stage)??0)+1),l.push({row:d,totalMinutes:p,othersInStage:0})}for(const i of l)i.othersInStage=(a.get(i.row.stage)??0)-(c.get(i.row.stage)??0);return l}function bn({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:c}){const p=h.useMemo(()=>mn(e),[e]);return t.jsx("div",{"data-testid":"critical-path",className:"border-t border-rule-structural max-w-[640px]",children:p.map(({row:l,totalMinutes:i,othersInStage:d})=>t.jsxs("div",{"data-testid":"critical-entry","data-slug":l.slug,children:[t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(Bt,{row:l,elapsedMs:gn(l.status)&&l.job.startedAt?s-Date.parse(l.job.startedAt):null,listIndex:n.get(l.slug)??0,onFocused:c,headChoices:a.get(l.slug)??xn})}),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:l.estimateMinutes?`${l.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 ",l.stage," · +",d," not on the critical path"]})]},l.slug))})}const gt=1,mt=1350,wn={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},vn={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"}},jn=e=>String(e).padStart(2,"0");function yn({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 Nn({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l,onOpenPrds:i}){var U,Y;const[d,r]=h.useState(e.status==="active"||e.status==="queued"),[o,u]=h.useState(!1),f=h.useRef(null),[m,g]=h.useState(0),[b,w]=h.useState(mt),D=h.useMemo(()=>{const A=me(e.stages,We);return A>=0?A:Math.max(0,me(e.stages,Ye))},[e.stages]);h.useLayoutEffect(()=>{if(!d)return;const A=f.current,G=(A==null?void 0:A.clientWidth)||mt,F=Math.max(0,Math.min(D,e.stageCount-Math.max(1,Math.ceil(G/le))));A!=null&&A.clientWidth&&w(A.clientWidth),A&&(A.scrollLeft=F*le),g(F)},[d]);const $=h.useMemo(()=>{let A=null;for(const G of e.stages)for(const F of G.rows){if(!F.job.runId)continue;const q=F.job.finishedAt?Date.parse(F.job.finishedAt):0;(!A||q>A.at)&&(A={runId:F.job.runId,slug:F.slug,title:F.title,at:q})}return A},[e.stages]),I=Re((Y=(U=e.stages[0])==null?void 0:U.rows[0])==null?void 0:Y.job.cwd)??"—",x=vn[e.status],E=Math.max(1,Math.ceil(b/le)),N=Math.max(0,Math.min(m-gt,e.stageCount)),P=Math.min(e.stageCount,m+E+gt),k=A=>{const G=Math.max(0,Math.min(e.stageCount-1,A));f.current&&(f.current.scrollLeft=G*le),g(G)},S=Math.min(e.stageCount,m+E),_=A=>{const G=A.currentTarget,F=Math.floor(G.scrollLeft/le);F!==m&&g(F),G.clientWidth&&G.clientWidth!==b&&w(G.clientWidth)},O="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",H=(()=>{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(()=>J.error("Failed to pause the scheduler"))},className:O,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(J.fromOutcome).catch(()=>J.error("Failed to fire the next batch"))},className:O,children:"Run now"});case"done":return t.jsx("button",{type:"button","data-testid":"plan-action",disabled:!$,title:$?`Open the run log of ${$.slug}, the plan's last run`:"No run log recorded for this plan",onClick:()=>u(!0),className:O,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 A,G;return i==null?void 0:i(((G=(A=e.stages[0])==null?void 0:A.rows[0])==null?void 0:G.slug)??null)},className:O,children:"Schedule…"})}})(),L=e.etaMs>0?` · ${It(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] ${wn[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:()=>r(A=>!A),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:jn(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 ${x.cls}`,children:x.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.jsx(he,{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,L]}),t.jsx(yn,{plan:e}),H]}),d&&s==="critical"&&t.jsx(bn,{plan:e,now:n,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l}),d&&s!=="critical"&&e.status==="active"&&t.jsx(pn,{stages:e.stages,first:m,perView:E,onSeek:k}),d&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:f,"data-testid":"plan-stages",onScroll:_,className:"flex flex-1 min-w-0 overflow-x-auto",children:[N>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:N*le}}),e.stages.slice(N,P).map(A=>t.jsx(on,{stage:A,epicId:e.epicId,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l},A.n)),P<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-P)*le}})]}),t.jsx(fn,{stages:e.stages.slice(S),onSeek:k})]}),o&&$&&t.jsx(Ie,{runId:$.runId,slug:$.slug,title:$.title||$.slug,onClose:()=>u(!1)})]})}function kn({section:e,children:s}){const[n,a]=h.useState(!0),c=Object.entries(e.counts).map(([p,l])=>`${l} ${p.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(p=>!p),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(Ke,{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:c})]}),n&&s]})}const Sn=[],Cn=[],$n={depth:0,blockers:Sn,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function Dn(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function Pn(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function An({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:c,onFocused:p,hold:l,backlog:i=$n,headChoices:d=Cn}){const[r,o]=h.useState(!1),[u,f]=h.useState(!1),m=oe(P=>P.sessions),g=h.useMemo(()=>Ce(e,m),[e,m]),b=g.known&&g.epicId?m[g.epicId]:null,w=h.useCallback(P=>{Qe(P),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),D=e.status==="running",$=e.status==="failed";let I=null;D&&n!==null?I=`${it(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?I=`took ${ke(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(I=s);const x=e.error??null,E=$&&x?x.split(`
4
4
  `)[0]:e.status==="needs_review"&&e.verifierVerdict?Se(e.verifierVerdict):null,N=D&&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":c,"data-depth":i.depth,onClick:()=>o(P=>!P),onFocus:()=>p(c),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 ${r?"bg-bg-elev/40":""}`,"aria-expanded":r,"aria-label":`${te(e.slug)?`PRD ${te(e.slug)}, `:""}${e.title}, ${e.status}${I?`, ${I}`:""}`,title:e.title,children:[t.jsx(St,{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:[te(e.slug)&&t.jsx(Ct,{n:te(e.slug)}),e.title,t.jsx($t,{leaked:e.leakedDescendants}),t.jsx(os,{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,k)=>t.jsxs("span",{className:Pn(P),children:[k>0&&", ",Dn(P)]},P.slug))]}),E&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${$?"text-accent/80":"text-fg-faint"}`,children:E}),l&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:l.dep?t.jsxs(t.Fragment,{children:["held · waiting on ",l.dep," (",l.depStatus,")"]}):t.jsxs(t.Fragment,{children:["held · ",l.reason??"launch blocked"]})}),!l&&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(ze,{epicId:g.epicId,label:g.label?Lt(g.label):null,onOpen:w,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(Xe,{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(ds,{status:e.status,overrun:e.overrun}),I,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${r?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(Ke,{name:"chevron",size:14})})]})]}),D&&!r&&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,N*100)}%`}})}),r&&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(ee,{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:Se(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(B,{k:"leaked",v:Dt(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}),x&&t.jsx(B,{k:"error",v:x.split(`
@@ -1 +1 @@
1
- import{ah as i,S as d}from"./index-4dEn1t8J.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{ah as i,S as d}from"./index-a2MVk8qh.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};