claude-code-session-manager 0.138.0 → 0.140.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/README.md +352 -79
- package/dist/assets/AppSettings-CMFEM68R.js +2 -0
- package/dist/assets/History--JwsFnbn.js +2 -0
- package/dist/assets/HomeClaudeConfig-ijEXs--3.js +3 -0
- package/dist/assets/{Panel-CeDiyuNn.js → Panel-CALyU0pe.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-sdlA-fUb.js +26 -0
- package/dist/assets/Scheduler-YT3j8SUa.js +16 -0
- package/dist/assets/{SkillReferenceGraph-CFMK8NJh.js → SkillReferenceGraph-CxAuwhNN.js} +1 -1
- package/dist/assets/Skills-DtRzghn5.js +67 -0
- package/dist/assets/{TiptapBody-D1kTj-tn.js → TiptapBody-DApeu7x8.js} +60 -54
- package/dist/assets/ViewTabs-B7qLXRAH.js +1 -0
- package/dist/assets/{VoiceButton-CZeyPM31.js → VoiceButton-DtStfv1H.js} +1 -1
- package/dist/assets/{historyTotals-B00l64Jw.js → historyTotals-ydfnwepc.js} +1 -1
- package/dist/assets/index-CtxruO1L.js +3121 -0
- package/dist/assets/{index-62tyjEQB.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +467 -451
- package/package.json +17 -6
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +12 -4
- package/plugins/session-manager-dev/skills/builder/scripts/publish-preflight.cjs +255 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +36 -22
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +2 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +360 -35
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +2 -2
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/exchanges.cjs +70 -5
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +172 -63
- package/src/main/historyDashboard.cjs +87 -17
- package/src/main/index.cjs +78 -4
- package/src/main/ipcSchemas.cjs +233 -20
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +92 -22
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/modelPricing.cjs +148 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +121 -0
- package/src/main/lib/epic/epicJobReceipt.cjs +87 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +423 -0
- package/src/main/lib/epic/epicOutsideState.cjs +233 -0
- package/src/main/lib/epic/epicSettle.cjs +1 -1
- package/src/main/lib/epic/epicStateWatcher.cjs +157 -0
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/externalRef.cjs +37 -0
- package/src/main/lib/epic/externalRefIndex.cjs +136 -0
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/epic/restorableSessions.cjs +151 -17
- package/src/main/lib/epic/transcriptUsage.cjs +197 -0
- package/src/main/lib/externalContract.cjs +137 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +176 -5
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +186 -9
- package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -6
- package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +50 -8
- package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +218 -4
- package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +19 -3
- package/src/main/lib/feedback-remote/feedbackImages.cjs +171 -0
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +11 -10
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +167 -21
- package/src/main/lib/feedback-remote/needsYouAdminRoutes.cjs +133 -0
- package/src/main/lib/feedback-remote/needsYouIpc.cjs +50 -0
- package/src/main/lib/feedback-remote/needsYouStore.cjs +285 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +58 -5
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +232 -25
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/agentAdminRoutes.cjs +121 -0
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +351 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +96 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/promptSessionSchema.cjs +4 -0
- package/src/main/lib/remoteTranscriptTail.cjs +32 -1
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +12 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/lib/telemetry/auditEvents.cjs +176 -0
- package/src/main/lib/telemetry/eventsAdminRoutes.cjs +45 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +11 -2
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +4 -1
- package/src/main/scheduler/starvation.cjs +20 -18
- package/src/main/scheduler.cjs +774 -64
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +7 -1
- package/src/main/transcripts.cjs +62 -7
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +132 -20
- package/src/preload/api.d.ts +434 -28
- package/src/preload/apiSurface.cjs +7 -0
- package/src/preload/apiSurface.json +485 -81
- package/src/preload/index.cjs +38 -5
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AgentLibrary-C1d_D7uQ.js +0 -2
- package/dist/assets/AppSettings-CgDhqrsU.js +0 -2
- package/dist/assets/Button-Bk23rEnZ.js +0 -1
- package/dist/assets/DocumentEditorPane-BqY5Nq6W.js +0 -1
- package/dist/assets/Extensions-CXem-uwI.js +0 -2
- package/dist/assets/History-BwO3coo4.js +0 -2
- package/dist/assets/Library-BDV69fSe.js +0 -32
- package/dist/assets/ListDetail-CD-Fm6mh.js +0 -1
- package/dist/assets/ProjectClaudeConfig-NjdKdwe8.js +0 -25
- package/dist/assets/ProvenanceBadge-Bu8NmI_R.js +0 -1
- package/dist/assets/Scheduler-CkhTvG7C.js +0 -16
- package/dist/assets/Settings-COT34hBF.js +0 -2
- package/dist/assets/Skills-BgexoUkQ.js +0 -29
- package/dist/assets/SourceChip-BXjcdeb1.js +0 -1
- package/dist/assets/SystemPrompt-CeeH3EeW.js +0 -1
- package/dist/assets/Toggle-CENi19iK.js +0 -1
- package/dist/assets/ViewTabs-DDBb0x96.js +0 -1
- package/dist/assets/claude-settings-schema-COigsajx.js +0 -3
- package/dist/assets/index-CgCxpunJ.js +0 -3116
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{aB as e,x as Ae,o as Me,bz as P,aR as o,aw as Le,$ as De,v as Oe,aE as le,D as $e,aD as _e,a4 as de,a3 as ce,a5 as G,a$ as He,a2 as Be,m as q,a6 as Fe,ag as Ue,ba as H,a1 as ze,b as B,by as te,c as L,be as We,bq as Je,a as Ve,a8 as Ge,bl as qe,bh as Ye,e as Xe,aS as Ke,bD as Ze}from"./index-CtxruO1L.js";import{T as O,V as xe,S as Qe}from"./ViewTabs-B7qLXRAH.js";import{V as et,T as tt}from"./VoiceButton-DtStfv1H.js";import{P as nt}from"./Panel-CALyU0pe.js";import"./monaco-editor-BsIlgG7c.js";function st({open:t,onClose:n,title:s,children:r,variant:i="overlay"}){return e.jsxs(Ae,{open:t,onClose:n,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:i,children:[i==="overlay"&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[e.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:s}),e.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(Me,{children:r})})]})}function at(){const t=P(g=>g.isRecording),n=P(g=>g.levelMeterEnabled),[s,r]=o.useState(0),[i,a]=o.useState(0),l=o.useRef(0);l.current=i;const[c,y]=o.useState(0),[m,f]=o.useState(!1),u=o.useRef(null);if(o.useEffect(()=>{if(!t||!n){r(0),a(0);return}let g=0,j=!1,v=null,N=null;const S=()=>{if(j)return;const w=N??Le();if(!w){g=requestAnimationFrame(S);return}N!==w&&(N=w,v=new Uint8Array(new ArrayBuffer(w.fftSize)));const C=v;w.getByteTimeDomainData(C);let T=0;for(let R=0;R<C.length;R++){const U=C[R]-128;T+=U*U}const E=Math.sqrt(T/C.length)/128,b=E>0?20*Math.log10(E):-60,k=Math.max(0,Math.min(1,(b+60)/60));a(E),r(k),E>=.95&&(f(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>f(!1),150)),g=requestAnimationFrame(S)};g=requestAnimationFrame(S);const h=setInterval(()=>{j||y(Math.round(l.current*100))},250);return()=>{j=!0,cancelAnimationFrame(g),clearInterval(h),u.current&&(clearTimeout(u.current),u.current=null)}},[t,n]),!t||!n)return null;const p=m?"bg-red-500":i>=.7?"bg-amber-400":"bg-green-500";return e.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${m?"ring-1 ring-red-500":""}`,children:e.jsx("div",{className:`h-full ${p} transition-[width] duration-75 ease-out`,style:{width:`${s*100}%`}})})}function rt({open:t,onClose:n,variant:s="overlay"}){return e.jsx(st,{open:t,onClose:n,title:"Voice / Microphone",variant:s,children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(dt,{}),e.jsx(De,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(et,{}),e.jsx(Oe,{}),e.jsx(tt,{})]}),e.jsx(it,{}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>P.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),e.jsx(lt,{})]}),e.jsx(at,{})]})})}function it(){const t=P(a=>a.isRecording),[n,s]=o.useState(null);if(o.useEffect(()=>{let a=!1;window.api.voice.getHotkeyConfig().then(c=>{a||s(c)}).catch(()=>{});const l=window.api.voice.onHotkeyConfigChanged(c=>s(c));return()=>{a=!0,l()}},[]),t||!n)return null;const r=n.mode==="hold"?"Hold":"Press",i=ot(n.accelerator);return e.jsxs("div",{className:"text-[11px] text-fg-faint",children:[e.jsxs("span",{children:[r," "]}),e.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:i}),e.jsx("span",{children:" to record"})]})}function ot(t){const n=typeof navigator<"u"&&/Mac/.test(navigator.platform);return t.replace(/CommandOrControl/g,n?"⌘":"Ctrl").replace(/CmdOrCtrl/g,n?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,n?"⌥":"Alt").replace(/Shift/g,n?"⇧":"Shift")}function lt(){const[t,n]=o.useState(null);if(o.useEffect(()=>{let r=!1;window.api.voice.getHotkeyConfig().then(a=>{r||n(a)}).catch(a=>le.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(a)}));const i=window.api.voice.onHotkeyConfigChanged(a=>{n(a)});return()=>{r=!0,i()}},[]),!t)return null;const s=async r=>{if(t.mode===r)return;const i={...t,mode:r};n(i);try{await window.api.voice.setHotkeyConfig(i)}catch(a){le.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:a instanceof Error?a.message:String(a)})}};return e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[e.jsx("input",{type:"radio",name:"hotkey-mode",checked:t.mode==="toggle",onChange:()=>s("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),e.jsx("span",{children:"Tap on/off"})]}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[e.jsx("input",{type:"radio",name:"hotkey-mode",checked:t.mode==="hold",onChange:()=>s("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),e.jsx("span",{children:"Hold to talk"})]})]})}function dt(){const t=P(a=>a.isRecording),n=P(a=>a.lastTranscript),s=P(a=>a.error),r=P(a=>a.modelStatus),i=P(a=>a.loadingProgress);return s?e.jsxs("div",{className:"text-[11px] text-red-400",title:s,children:["⚠ ",s]}):t?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),e.jsx("span",{className:"truncate",title:n,children:n||"Listening…"})]}):r==="loading"?e.jsxs("div",{className:"text-[11px] text-fg-faint",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"Loading speech model"}),e.jsxs("span",{className:"font-mono",children:[i,"%"]})]}),e.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${i}%`}})})]}):null}const ct=["dark","light","paper"];function pt(){const[t,n]=o.useState($e),[s,r]=o.useState(!1);o.useEffect(()=>{let l=!1;return _e().then(c=>{l||(n(c),r(!0))}),()=>{l=!0}},[]);const i=l=>{s&&n(c=>{const y={...c,...l};return He(y),y})},a=l=>{i({fontSize:Math.min(ce,Math.max(de,t.fontSize+l))})};return e.jsxs("section",{className:"mb-6","data-testid":"home-terminal-appearance",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Terminal appearance"}),e.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:"every terminal, this machine"})]}),e.jsxs("div",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsxs("p",{className:"mt-0 mb-4 text-[13px] text-fg-dim leading-relaxed",children:["Applies to ",e.jsx("strong",{className:"text-fg",children:"every terminal in the app at once"})," — project Terminal tabs, an Epic’s Terminal view of its session, and the inline permission prompt. It is not per project, per session, or per tab. It does not restyle the app chrome (there is no app theme switch), and the code editor keeps its own separate paper/dark setting in the Editor tab’s Display menu. Stored in"," ",e.jsx("code",{className:"font-mono text-[12px]",children:"~/.claude/session-manager/ui-settings-prefs.json"}),", applied live without restarting a session."]}),e.jsxs("div",{className:"grid gap-5",style:{gridTemplateColumns:"minmax(0,1fr) 220px"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-fg-faint mb-1.5",children:"Theme"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:ct.map(l=>e.jsxs("button",{type:"button",onClick:()=>i({theme:l}),disabled:!s,"aria-pressed":t.theme===l,"data-testid":`terminal-theme-${l}`,className:`px-2 py-2 rounded-lg text-[11px] font-medium border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${t.theme===l?"bg-bg border-accent text-fg":"bg-bg border-line text-fg-dim hover:text-fg hover:border-fg-faint"}`,children:[e.jsx(mt,{theme:l}),e.jsx("div",{className:"mt-1.5 capitalize",children:l})]},l))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-fg-faint",children:"Font size"}),e.jsxs("span",{className:"font-mono text-[11px] text-fg-dim",children:[t.fontSize,"px"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>a(-1),disabled:!s||t.fontSize<=de,"aria-label":"Decrease font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"−"}),e.jsx("button",{type:"button",onClick:()=>i({fontSize:Be}),disabled:!s,className:"flex-1 py-1.5 rounded border border-line bg-bg text-[11px] text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"reset"}),e.jsx("button",{type:"button",onClick:()=>a(1),disabled:!s||t.fontSize>=ce,"aria-label":"Increase font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"+"})]}),e.jsxs("div",{className:"mt-3 rounded border border-line px-3 py-2 font-mono",style:{background:G[t.theme].background,color:G[t.theme].foreground,fontSize:`${t.fontSize}px`,lineHeight:1.35},"aria-hidden":!0,children:[e.jsx("span",{style:{color:G[t.theme].green},children:"$"})," claude"]})]})]})]})]})}function mt({theme:t}){const n=G[t];return e.jsxs("div",{"aria-hidden":!0,className:"w-full h-5 rounded border relative overflow-hidden",style:{background:n.background,borderColor:"rgba(0,0,0,0.15)"},children:[e.jsx("div",{style:{position:"absolute",top:3,left:4,width:"40%",height:2,background:n.foreground}}),e.jsx("div",{style:{position:"absolute",top:9,left:4,width:"25%",height:2,background:n.green??n.foreground}}),e.jsx("div",{style:{position:"absolute",top:15,left:4,width:"55%",height:2,background:n.cyan??n.foreground}})]})}const ut=1440*60*1e3;function ft(t){if(!t)return"never";const n=new Date(t).getTime();return Number.isNaN(n)?"never":new Date(n).toLocaleString()}function pe(t){return t?new Date(t).toLocaleString():"never"}function gt(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(ht,{}),e.jsx("hr",{className:"border-line"}),e.jsx(xt,{})]})}function ht(){const[t,n]=o.useState(null),[s,r]=o.useState(null),[i,a]=o.useState(null),[l,c]=o.useState(null),[y,m]=o.useState(!1),[f,u]=o.useState(null),[p,g]=o.useState(null);if(o.useEffect(()=>{let h=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([w,C,T])=>{h||(n(w),a(w),r(C),c(T))}).catch(w=>{console.warn("[telemetry] load failed:",w==null?void 0:w.message)}),()=>{h=!0}},[]),!i||!t)return e.jsx(q,{title:"loading…"});const j=JSON.stringify(i)!==JSON.stringify(t),v=(h,w)=>{u(null),a({...i,[h]:w})},N=async()=>{m(!0),u(null);try{const h=await window.api.otel.setConfig(i);!h.ok&&h.error&&u(h.error),n(h.config),a(h.config),r(h.status),g(Date.now())}catch(h){u(h instanceof Error?h.message:String(h))}finally{m(!1)}},S=()=>{u(null),a(t)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),l&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:l})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(O,{checked:i.enabled,onChange:h=>v("enabled",h),label:i.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:i.endpoint,onChange:h=>v("endpoint",h.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:i.headers,onChange:h=>v("headers",h.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:i.serviceName,onChange:h=>v("serviceName",h.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(O,{checked:i.includeContent,onChange:h=>v("includeContent",h),label:i.includeContent?"on":"off"})]})]}),s&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:s.enabled?"text-accent":"text-fg-dim",children:String(s.enabled)})]}),s.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",s.error]}),!s.error&&s.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:N,disabled:!j||y,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:y?"saving…":"Save"}),e.jsx("button",{onClick:S,disabled:!j||y,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),f&&e.jsx("span",{className:"text-red-400 text-xs",children:f}),!f&&p&&!j&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function xt(){const[t,n]=o.useState(null),[s,r]=o.useState(null),[i,a]=o.useState("Copy"),[l,c]=o.useState(!1),[y,m]=o.useState(null),[f,u]=o.useState(null),[p,g]=o.useState(null),[j,v]=o.useState(!1),N=()=>{window.api.telemetry.status().then(r).catch(b=>{console.warn("[product-telemetry] status reload failed:",b==null?void 0:b.message)})};if(o.useEffect(()=>{let b=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([k,R])=>{b||(n(k),r(R))}).catch(k=>{console.warn("[product-telemetry] load failed:",k==null?void 0:k.message)}),()=>{b=!0}},[]),!t||!s)return e.jsx(q,{title:"loading…"});const S=async b=>{u(null);try{const k=await window.api.telemetry.setConfig(b);n(k.config),r(k.status),window.dispatchEvent(new CustomEvent(ze,{detail:k.config}))}catch(k){u(k instanceof Error?k.message:String(k))}},h=b=>{S({...t,enabled:b})},w=async()=>{await Ue(t.installId)?(a("Copied"),setTimeout(()=>a("Copy"),1500)):H.error("Could not copy install id to the clipboard")},C=async()=>{c(!0),m(null);try{const b=await window.api.telemetry.flushNow();m(`sent ${b.sent.length}, failed ${b.failed.length}`),N()}catch(b){m(b instanceof Error?b.message:String(b))}finally{c(!1)}},T=async()=>{if(j){v(!1);return}try{const b=await window.api.telemetry.recentRecords();g(b),v(!0)}catch(b){console.warn("[product-telemetry] recentRecords failed:",b instanceof Error?b.message:b)}},E=t.lastDailyFlushAt?new Date(t.lastDailyFlushAt).getTime()+ut:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),e.jsx(Fe,{cfg:t,onSaved:(b,k)=>{n(b),r(k)}}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(O,{checked:t.enabled,onChange:h,label:t.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:t.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:w,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:i})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:t.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),f&&e.jsx("div",{className:"text-red-400 text-xs",children:f})]}),s.pendingCount>0&&s.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[s.pendingCount," record",s.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",pe(s.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",ft(E?new Date(E).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",s.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",s.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",s.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",s.evictedCount]}),s.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",s.lastError.message," ","(",pe(s.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:C,disabled:l,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:l?"sending…":"Send now"}),y&&e.jsx("span",{className:"text-fg-faint text-xs",children:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:T,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:j?"Hide last records":"Inspect last records sent"}),j&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(p??[],null,2)})]})]})}function z({children:t,right:n}){return e.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[e.jsx("span",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint",children:t}),n]})}function Z({kind:t="soft",icon:n,children:s,onClick:r,disabled:i,testId:a}){return e.jsxs("button",{type:"button","data-testid":a,onClick:r,disabled:i,className:`shrink-0 inline-flex items-center gap-2 rounded-lg px-3.5 py-2 text-[13px] font-semibold transition-colors disabled:opacity-50 ${t==="soft"?"bg-bg-hi border border-line text-fg hover:bg-bg":"text-fg-dim hover:text-fg"}`,children:[n&&e.jsx(B,{name:n,size:15}),s]})}function yt({icon:t,title:n,subtitle:s,badge:r,action:i,testId:a}){return e.jsxs("div",{"data-testid":a,className:"flex items-center gap-3.5 bg-bg-hi border border-line rounded-xl px-[18px] py-3.5",children:[e.jsx("span",{className:"w-[34px] h-[34px] rounded-lg bg-bg border border-line grid place-items-center text-fg-dim shrink-0",children:e.jsx(B,{name:t,size:17})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-0.5",children:[e.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:n}),r]}),e.jsx("div",{className:"font-mono text-[11.5px] text-fg-faint truncate",children:s})]}),i]})}function bt({onClick:t,disabled:n,testId:s,children:r="Revoke"}){return e.jsx("button",{"data-testid":s,onClick:t,disabled:n,className:"shrink-0 rounded-lg border border-line bg-bg text-accent px-3.5 py-1.5 text-[12.5px] font-semibold hover:bg-bg-hi disabled:opacity-50 transition-colors",children:r})}function me({code:t,onConfirm:n,testId:s,codeTestId:r,confirmTestId:i,peer:a="browser"}){return e.jsxs("div",{"data-testid":s,className:"flex items-start gap-3.5 px-5 py-4 rounded-2xl border border-accent/40 bg-accent/[0.06]",children:[e.jsx("span",{className:"w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center bg-bg-hi text-accent",children:e.jsx(B,{name:"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-fg",children:[e.jsx("strong",{className:"font-semibold",children:"Verify E2E session."})," Compare this code with the ",a," — they must match.",e.jsx("div",{"data-testid":r,className:"my-2 text-3xl font-mono tracking-[0.3em] text-center text-accent select-all",children:t}),e.jsx("p",{className:"text-[12.5px] text-fg-faint mb-3",children:"If the codes match, confirm below. Mutating commands are blocked until confirmed."}),e.jsx("button",{"data-testid":i,onClick:n,className:"rounded-lg bg-accent text-white px-4 py-2 text-[13px] font-semibold hover:opacity-90 transition-opacity",children:"Codes match — confirm"})]})]})}function jt({children:t,testId:n}){return e.jsx("div",{"data-testid":n,className:"bg-bg-hi border border-line rounded-xl p-5 text-center text-[13.5px] text-fg-faint italic font-serif",children:t})}function ue({label:t,hint:n,on:s,onChange:r,warn:i,disabled:a,first:l,testId:c}){return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-[18px] py-[15px] ${l?"":"border-t border-rule"} ${a?"opacity-50":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-fg mb-0.5",children:t}),e.jsxs("div",{className:`text-[12.5px] leading-snug flex items-center gap-1.5 ${i?"text-honey-dark":"text-fg-faint"}`,children:[i&&e.jsx("span",{"aria-hidden":!0,children:"⚠"}),n]})]}),e.jsx("span",{"data-testid":c,className:"inline-flex",children:e.jsx(O,{checked:s,onChange:a?()=>{}:r,disabled:a})})]})}function vt({device:t,online:n,onRevoke:s,revoking:r}){const i=t.lastConnectedAt?new Date(t.lastConnectedAt).toLocaleString():`paired ${new Date(t.issuedAt).toLocaleDateString()}`;return e.jsx(yt,{testId:"settings-remote-device",icon:"wifi",title:t.deviceName,badge:n?e.jsx(L,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.deviceId} · last seen ${i}`,action:e.jsx(bt,{testId:"settings-remote-revoke",onClick:()=>s(t.deviceId),disabled:r})})}const M=t=>(t==null?void 0:t.message)||String(t);function wt(){var oe;const t=te(d=>d.show),[n,s]=o.useState(null),[r,i]=o.useState(!0),[a,l]=o.useState(!1),[c,y]=o.useState(!1),[m,f]=o.useState("idle"),[u,p]=o.useState(""),[g,j]=o.useState(null),[v,N]=o.useState(!1),[S,h]=o.useState([]),[w,C]=o.useState(!1),T=o.useRef(null);o.useEffect(()=>{let d=!1;const x=()=>window.api.webRemote.getStatus().then(I=>{d||s(I)}).catch(()=>{});window.api.webRemote.getStatus().then(I=>{d||(s(I),i(!1))}).catch(I=>{d||(t("error",`Remote status: ${M(I)}`),i(!1))});const Ie=window.api.webRemote.onStatus(I=>s(I)),Pe=window.api.webRemote.onTokenRevoked(()=>{t("warn","Remote device token was revoked. Re-pair to reconnect."),x()}),Re=window.api.webRemote.onRevokedAll(({revokedCount:I})=>{t("info",`Panic: all ${I} device(s) revoked and sessions torn down.`),x()});return()=>{d=!0,Ie(),Pe(),Re()}},[t]),o.useEffect(()=>{if(m!=="enter-otp")return;const d=setTimeout(()=>{var x;return(x=T.current)==null?void 0:x.focus()},50);return()=>clearTimeout(d)},[m]);const E=async()=>s(await window.api.webRemote.getStatus()),b=async()=>{if(n){l(!0);try{const d=n.enabled?await window.api.webRemote.disable():await window.api.webRemote.enable();d&&d.ok===!1&&t("error",d.error||"Failed to change remote state."),await E()}catch(d){t("error",`Failed: ${M(d)}`)}finally{l(!1)}}},k=async()=>{if(n){y(!0);try{const d=n.remoteControlEnabled?await window.api.webRemote.disableControl():await window.api.webRemote.enableControl();d&&d.ok===!1&&t("error",d.error||"Failed to change command writes."),await E()}catch(d){t("error",`Failed: ${M(d)}`)}finally{y(!1)}}},R=async()=>{const d=u.trim().toUpperCase();if(!/^[A-Z0-9]{8}$/.test(d)){t("warn","Pairing code must be 8 alphanumeric characters.");return}f("pairing");try{const x=await window.api.webRemote.pair(d);if(!x.ok){t("error",x.error||"Pairing failed."),f("enter-otp");return}t("info","Device paired successfully."),p(""),f("idle"),await E()}catch(x){t("error",`Pairing error: ${M(x)}`),f("enter-otp")}},U=async d=>{j(d);try{const x=await window.api.webRemote.revokeDevice(d);if(!x.ok){t("error",x.error||"Revoke failed.");return}await E()}catch(x){t("error",`Revoke error: ${M(x)}`)}finally{j(null)}},Ne=async()=>{N(!0);try{const d=await window.api.webRemote.revokeAll();d.ok||t("error",d.error||"Panic revoke failed.")}catch(d){t("error",`Panic revoke error: ${M(d)}`)}finally{N(!1)}},Se=async()=>{if(w){C(!1);return}try{const d=await window.api.webRemote.auditTail(100);if(!d.ok){t("error",`Audit log: ${d.error||"unavailable"}`);return}h(d.lines??[]),C(!0)}catch(d){t("error",`Audit log: ${M(d)}`)}},se=async d=>{try{const x=await window.api.webRemote.confirmSas(d);x!=null&&x.ok||t("error",`SAS confirm failed: ${(x==null?void 0:x.error)??"unexpected state — reconnect the mobile app"}`)}catch(x){t("error",`SAS confirm failed: ${M(x)}`)}};if(r)return e.jsx("div",{className:"p-6 text-fg-faint text-sm",children:"Loading…"});const A=(n==null?void 0:n.enabled)??!1,X=(n==null?void 0:n.remoteControlEnabled)??!1,ae=(n==null?void 0:n.connected)??!1,re=(n==null?void 0:n.e2eActive)??!1,Ce=(n==null?void 0:n.e2eAuthenticated)??!1,Ee=(n==null?void 0:n.e2eState)??"idle",ie=(n==null?void 0:n.pendingSas)??null,K=((n==null?void 0:n.clients)??[]).filter(d=>d.state==="pending_sas"&&d.pendingSas),$=(n==null?void 0:n.devices)??[],_=A&&ae,Te=ae?((oe=$.reduce((d,x)=>x.lastConnectedAt&&(!d||(d.lastConnectedAt??"")<x.lastConnectedAt)?x:d,null))==null?void 0:oe.deviceId)??null:null;return e.jsxs("div",{"data-testid":"settings-remote",className:"p-4 max-w-[760px] space-y-[22px]",children:[K.length>0?K.map((d,x)=>e.jsxs("div",{"data-testid":"settings-remote-sas-row",children:[K.length>1&&e.jsxs("div",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:["Browser ",x+1]}),e.jsx(me,{testId:x===0?"settings-remote-sas":void 0,codeTestId:x===0?"settings-remote-sas-code":void 0,confirmTestId:x===0?"settings-remote-sas-confirm":void 0,code:d.pendingSas,onConfirm:()=>se(d.key)})]},d.key)):ie&&e.jsx(me,{testId:"settings-remote-sas",codeTestId:"settings-remote-sas-code",confirmTestId:"settings-remote-sas-confirm",code:ie,onConfirm:()=>se()}),Ee==="failed"&&e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 rounded-2xl border border-[#eccdbe] bg-[#f8e8e0]",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsxs("div",{className:"text-[13px] text-[#9a3f1f]",children:[e.jsx("strong",{className:"font-semibold",children:"E2E key exchange failed."})," ",e.jsx("span",{className:"text-fg-dim",children:"The session key could not be established. Reconnect the mobile app to retry."})]})]}),e.jsxs("div",{className:`flex items-center gap-3.5 px-5 py-4 rounded-2xl border ${_?"border-[#e8cdb9] bg-[#f5e9df]":"border-line bg-bg-hi"}`,children:[e.jsx("span",{className:`w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center ${_?"bg-[#f0d9c8] text-accent":"bg-[#e4ebd6] text-sage"}`,children:e.jsx(B,{name:_?"wifi":"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-fg mb-0.5",children:_?"Remote control is active":A?"Remote control is idle":"Remote control is off"}),e.jsx("div",{className:"text-[13px] text-fg-dim leading-snug",children:_?"A web session can send commands to this machine. Revoke below if unexpected.":A&&(n==null?void 0:n.linkState)==="repair-needed"?"The relay no longer recognises this device. Re-pair it with a new code to reconnect.":A?"The relay is on but no device is connected. Pair a device to begin.":"The relay connection is closed — no remote commands are accepted. Enable it below only when you need it."})]}),re&&Ce?e.jsx(L,{tone:"default",className:"!text-sage !border-sage/40",children:"E2E authenticated"}):re?e.jsx(L,{tone:"warn",children:"E2E · awaiting SAS"}):e.jsx(L,{tone:"dim",children:"relay only · not E2E yet"})]}),e.jsxs("div",{children:[e.jsx(z,{children:"Remote control"}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx(ue,{first:!0,testId:"settings-remote-enable",label:"Allow remote control from the web",hint:"Master switch. When off, the relay refuses every connection.",on:A,disabled:a,onChange:()=>{a||b()}}),e.jsx(ue,{testId:"settings-remote-control",label:"Allow command writes (pty + scheduler)",hint:X?"A paired device can run shell commands and queue jobs on this machine.":"Paired devices can watch session output but cannot send commands.",warn:X,disabled:!A||c,on:X&&A,onChange:()=>{A&&!c&&k()}})]})]}),e.jsxs("div",{children:[e.jsx(z,{children:"Pair a device"}),m==="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsxs("div",{"data-testid":"settings-remote-pair-hint",className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:["On your phone open ",e.jsx("strong",{className:"text-fg font-semibold",children:"bilko.run/projects/session-manager"}),", sign in, and tap"," ",e.jsx("strong",{className:"text-fg font-semibold",children:"Generate pairing code"}),". Enter the 8-character code here."]}),e.jsx(Z,{testId:"settings-remote-pair-start",kind:"soft",icon:"link",onClick:()=>f("enter-otp"),children:"Pair Device…"})]}):e.jsxs("div",{className:"flex items-center gap-5 bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[22px]",children:[e.jsx("span",{className:"w-[52px] h-[52px] rounded-xl bg-bg border border-line grid place-items-center text-accent shrink-0",children:e.jsx(B,{name:"link",size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint mb-2",children:"Enter the code from your phone"}),e.jsx("input",{ref:T,"data-testid":"settings-remote-otp",value:u,onChange:d=>p(d.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")),onKeyDown:d=>{d.key==="Enter"&&R()},maxLength:8,placeholder:"XXXXXXXX",disabled:m==="pairing",className:"w-full bg-transparent border-0 outline-none font-mono text-[30px] font-semibold tracking-[6px] text-fg placeholder:text-fg-faint/40 disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(Z,{testId:"settings-remote-pair-confirm",kind:"soft",onClick:R,disabled:m==="pairing"||u.length<8,children:m==="pairing"?"Pairing…":"Confirm"}),e.jsx(Z,{kind:"ghost",onClick:()=>{f("idle"),p("")},disabled:m==="pairing",children:"cancel"})]})]})]}),e.jsxs("div",{children:[e.jsx(z,{right:$.length>0?e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[$.length," paired"]}):void 0,children:"Paired devices"}),$.length===0?e.jsx(jt,{children:"No devices paired yet."}):e.jsx("div",{className:"space-y-2",children:$.map(d=>e.jsx(vt,{device:d,online:d.deviceId===Te,onRevoke:U,revoking:g===d.deviceId},d.deviceId))})]}),e.jsxs("div",{children:[e.jsx(z,{right:e.jsx("button",{"data-testid":"settings-remote-audit-toggle",onClick:Se,className:"text-[12px] text-fg-faint hover:text-fg-dim transition-colors",children:w?"Hide":"Show last 100 · 0600, stays on this machine"}),children:"Audit log"}),w&&e.jsx("div",{className:"bg-bg-hi border border-line rounded-xl overflow-auto max-h-64 mb-2",children:S.length===0?e.jsx("p",{className:"p-4 text-[12.5px] text-fg-faint",children:"No entries today."}):e.jsx("pre",{"data-testid":"settings-remote-audit",className:"p-4 text-[12px] text-fg-dim font-mono whitespace-pre-wrap leading-relaxed",children:S.join(`
|
|
2
|
+
`)})}),e.jsxs("p",{className:"text-[12px] text-fg-faint",children:["Full log at"," ",e.jsx("code",{className:"font-mono text-fg-faint",children:"~/.claude/session-manager/logs/remote-audit-YYYY-MM-DD.log"})," ","(0600, never leaves this machine)"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-[#f8e8e0] border border-[#eccdbe] rounded-2xl px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsx("span",{className:"text-sm font-semibold text-[#9a3f1f]",children:"Panic — disconnect & revoke everything"})]}),e.jsx("div",{className:"text-[12.5px] text-fg-dim leading-snug max-w-[440px]",children:"Tears down every active session and invalidates all paired-device tokens. Devices must re-pair. Use if you suspect compromise."})]}),e.jsx("button",{"data-testid":"settings-remote-revoke-all",onClick:Ne,disabled:v,className:"shrink-0 rounded-lg bg-accent text-white px-[18px] py-2 text-[13px] font-semibold hover:opacity-90 disabled:opacity-50 transition-opacity",children:v?"Revoking…":"Revoke all"})]})]})}const W="px-2 py-1 rounded border border-line text-xs text-fg hover:bg-bg-hi disabled:opacity-50";function kt(){const t=We(),n=te(c=>c.show),s=async c=>{try{const m=await c();m&&m.ok===!1&&n("error",m.error??"Update action failed")}catch(y){n("error",y instanceof Error?y.message:String(y))}};if(!t)return null;const{state:r}=t,i=r==="unsupported",a=t.latest?`v${t.latest}`:"—",l=()=>{window.confirm("Installing now will stop all running jobs and terminals. Continue?")&&s(()=>window.api.updater.install(!0))};return e.jsxs("section",{"data-testid":"settings-updates",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Updates"}),e.jsxs("div",{className:"text-fg-dim text-xs flex gap-4",children:[e.jsxs("span",{children:["Current v",t.current]}),e.jsxs("span",{children:["Latest ",a]})]})]}),i?e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Auto-update runs only in the installed Windows app or the Linux AppImage. npx builds update via npx."}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(O,{checked:t.enabled,onChange:c=>void s(()=>window.api.updater.setEnabled(c)),label:"Update automatically"}),e.jsx("button",{type:"button","data-testid":"updates-check",className:W,disabled:r==="checking"||r==="downloading",onClick:()=>void s(()=>window.api.updater.check()),children:"Check for updates"})]}),r==="checking"&&e.jsx("p",{className:"text-fg-dim text-xs",children:"Checking…"}),r==="downloading"&&e.jsxs("p",{className:"text-fg-dim text-xs",children:["Downloading… ",t.progress!=null?`${Math.round(t.progress)}%`:""]}),r==="ready"&&e.jsxs("button",{type:"button","data-testid":"updates-install",className:W,onClick:()=>void s(()=>window.api.updater.install(!1)),children:["Restart to install v",t.latest]}),r==="deferred"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-fg-dim text-xs",children:["Waiting for ",t.busyReason??"work"," to finish"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:W,onClick:l,children:"Install now"}),e.jsx("button",{type:"button",className:W,onClick:()=>void s(()=>window.api.updater.cancelDeferred()),children:"Cancel"})]})]}),r==="error"&&e.jsx("p",{className:"text-red-400 text-xs",children:t.error})]})}function Nt(t){return t?t.supported?t.starts==="npx"?"Runs npx claude-code-session-manager@latest at login, so it starts the newest release.":t.starts==="app"?"Starts the installed app at login.":t.reason??"":t.reason??"Start at login is not available here.":"Checking…"}function St(){const[t,n]=o.useState(null),[s,r]=o.useState(!1);o.useEffect(()=>{let l=!0;return window.api.loginItem.status().then(c=>{l&&n(c)}).catch(c=>H.error(c instanceof Error?c.message:String(c))),()=>{l=!1}},[]);const i=async l=>{r(!0);try{const c=await window.api.loginItem.setEnabled(l);c.ok?n(c.status):H.error(c.error)}catch(c){H.error(c instanceof Error?c.message:String(c))}finally{r(!1)}},a=(t==null?void 0:t.supported)===!0;return e.jsxs("section",{"data-testid":"settings-start-at-login",className:"space-y-1",children:[e.jsx(O,{checked:(t==null?void 0:t.enabled)===!0,onChange:l=>void i(l),disabled:!a||s,label:"Start at login"}),e.jsx("p",{"data-testid":"start-at-login-desc",className:"text-fg-faint text-[11px]",children:Nt(t)})]})}const Ct=[{key:"maxAgeDays",label:"Run logs: keep for",unit:"days",min:3,max:3650},{key:"runsArchiveDays",label:"Runs archive: keep for",unit:"days",min:1,max:3650},{key:"auditLogMonths",label:"Audit log: keep for",unit:"months",min:1,max:120},{key:"reservedMarkersKeep",label:"Reserved markers: keep",unit:"markers",min:1,max:1e5}],Et="w-24 px-2 py-1 rounded border border-line bg-transparent text-xs text-fg";function fe(t,n){return n==="maxAgeDays"?t.runLogs.maxAgeDays:t[n]}function Tt(t,n){return t==="maxAgeDays"?{runLogs:{maxAgeDays:n}}:{[t]:n}}function ye(t){if(!Number.isFinite(t)||t<=0)return"0 B";const n=["B","KB","MB","GB","TB"];let s=0,r=t;for(;r>=1024&&s<n.length-1;)r/=1024,s++;return`${s===0?r:r.toFixed(1)} ${n[s]}`}function Q(t,n,s){return`${t}: ${ye(n)} in ${s.toLocaleString("en-US")} files`}function It(){const t=te(p=>p.show),[n,s]=o.useState(null),[r,i]=o.useState({}),[a,l]=o.useState(null),c=o.useCallback(p=>t("error",p instanceof Error?p.message:String(p)),[t]),y=o.useCallback(async()=>{try{l(await window.api.opsRetention.preview())}catch(p){c(p)}},[c]);o.useEffect(()=>{let p=!0;return window.api.opsRetention.get().then(g=>{p&&s(g)}).catch(g=>{p&&c(g)}),y(),()=>{p=!1}},[c,y]);const m=async p=>{if(!n)return;const g=r[p.key];if(g===void 0)return;const j=Number(g);if(i(N=>{const{[p.key]:S,...h}=N;return h}),g.trim()===""||!Number.isFinite(j))return;const v=Math.min(p.max,Math.max(p.min,Math.round(j)));if(v!==fe(n,p.key))try{s(await window.api.opsRetention.set(Tt(p.key,v))),await y()}catch(N){c(N)}},f=a?a.runLogs.bytes+a.runsArchive.bytes+a.tmp.bytes:0,u=a?a.runLogs.files+a.runsArchive.entries+a.tmp.files:0;return e.jsxs("section",{"data-testid":"settings-ops-retention",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Ops data retention"}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"How long the daily sweep keeps scheduler and audit data. Machine-wide."})]}),n&&e.jsxs("div",{className:"space-y-2",children:[Ct.map(p=>e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:"w-48",children:p.label}),e.jsx("input",{type:"number","data-testid":`ops-retention-${p.key}`,className:Et,min:p.min,max:p.max,value:r[p.key]??String(fe(n,p.key)),onChange:g=>i(j=>({...j,[p.key]:g.target.value})),onBlur:()=>void m(p)}),e.jsx("span",{className:"text-fg-faint",children:p.unit})]},p.key)),e.jsx("p",{className:"text-fg-dim text-xs",children:"Archived transcripts: kept forever"})]}),a&&e.jsxs("div",{"data-testid":"ops-retention-preview",className:"space-y-1 text-xs text-fg-dim",children:[e.jsxs("div",{className:"text-fg",children:["Current policy would free ",ye(f)," in ",u.toLocaleString("en-US")," files"]}),e.jsx("div",{children:Q("Run logs",a.runLogs.bytes,a.runLogs.files)}),e.jsx("div",{children:Q("Runs archive",a.runsArchive.bytes,a.runsArchive.entries)}),e.jsx("div",{children:Q("Stale temp files",a.tmp.bytes,a.tmp.files)}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Nothing is deleted until the daily sweep runs."})]})]})}const Y=[{id:"project",label:"Project & Tab",realm:"machine",blurb:"A PROJECT is a cwd; a TAB is one open project.",tone:{chip:"bg-bg-elev text-fg-dim",border:"border-line",dot:"bg-fg-faint"}},{id:"epic",label:"Epic (PromptSession)",realm:"project",blurb:"The central aggregate root — one unit of work, one claude session.",tone:{chip:"bg-accent-muted text-accent-dark",border:"border-accent",dot:"bg-accent"}},{id:"scheduler",label:"Scheduler",realm:"project",blurb:"PRDs + the headless jobs that execute them.",tone:{chip:"bg-butter/30 text-honey-dark",border:"border-honey",dot:"bg-honey"}},{id:"agents",label:"Agents & Taxonomy",realm:"machine",blurb:"The ACTOR and MISSION halves of AIM.",tone:{chip:"bg-sage/20 text-sage-dark",border:"border-sage",dot:"bg-sage"}},{id:"memory",label:"Memory",realm:"machine",blurb:"Workspace, cross-project, and per-agent memory.",tone:{chip:"bg-hive-teal/20 text-hive-teal",border:"border-hive-teal",dot:"bg-hive-teal"}},{id:"transcript",label:"Transcript & Usage",realm:"machine",blurb:"The Claude CLI's own JSONL, classified events, and billing.",tone:{chip:"bg-bg-hi text-fg-dim",border:"border-rule",dot:"bg-fg-dim"}},{id:"brief",label:"Project Home & Publishing",realm:"project",blurb:"The synthesized Brief, generated pages, and bilko.run publish state.",tone:{chip:"bg-accent-muted/60 text-accent-dark",border:"border-accent-muted",dot:"bg-accent-muted"}},{id:"config",label:"Machine Config",realm:"machine",blurb:"Settings, layout, and the single-writer ownership map.",tone:{chip:"bg-line text-fg-faint",border:"border-rule",dot:"bg-fg-faint"}}];function be(t){const n=Y.find(s=>s.id===t);if(!n)throw new Error(`unknown ErdGroupId: ${t}`);return n}const F=[{id:"project",name:"Project",aka:"cwd — Main Project",group:"project",store:{path:"identity only, no record of its own — folded at read time from ~/.claude/projects/<encoded>",format:"in-memory",definedIn:"src/renderer/lib/knownProjectAggregate.ts (aggregateProjectsByCwd) "},summary:"A folder whose cwd never resolved from transcript content is DROPPED, never guessed — the naive decode once reported 2044 phantom projects.",fields:[{name:"cwd",type:"string",key:"pk",note:"resolved working directory — the project's identity"},{name:"name",type:"string",note:"display name: the cwd's last path segment"},{name:"encoded",type:"string",note:"representative transcript folder (most recently active)"},{name:"encodedIds",type:"string[]",note:"every ~/.claude/projects/<encoded> folder that resolved to this cwd"},{name:"sessionCount",type:"number"},{name:"sizeBytes",type:"number"},{name:"lastSession",type:"number"}]},{id:"tab",name:"PersistedTab",aka:"TAB",group:"project",store:{path:"~/.claude/session-manager/tabs.json",format:"json",definedIn:"src/main/sessionsStore.cjs "},summary:"One TAB per project — extra sessions within a project are Epics, not tabs.",fields:[{name:"id",type:"string",key:"pk"},{name:"sessionId",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"label",type:"string"},{name:"presetId",type:"string | null"}]},{id:"epic",name:"PromptSession",aka:"EPIC",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> sessions[id]",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicMint.cjs (ensureEpic) + src/renderer/state/promptSessions.ts "},summary:"The central aggregate root — created in exactly ONE place, a human pressing New Epic.",fields:[{name:"id",type:"string",key:"pk"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"goalText",type:"string",note:"the original top-level prompt text that started this goal"},{name:"claudeSessionId",type:"string",note:"independently minted — never shared with any tab.sessionId"},{name:"status",type:"'proposed' | 'active' | 'completed'"},{name:"createdAt",type:"string"},{name:"completedAt",type:"string | null"},{name:"resumedFromId",type:"string",optional:!0,key:"fk",ref:"epic.id"},{name:"tag",type:"TicketTag",optional:!0,key:"fk",ref:"tag.tag"},{name:"openingPrompt",type:"string | null",optional:!0},{name:"source",type:"EpicSource",optional:!0,note:"{ producer, prdSlug?, runId?, sourceTabId?, fromCwd?, fromEpicId? }"},{name:"agentType",type:"string",optional:!0,key:"fk",ref:"agentPersona.name"},{name:"model",type:"string",optional:!0,note:"per-Epic model override; absent = the persona model"},{name:"effort",type:"string",optional:!0,note:"per-Epic effort override; absent = the persona effort"},{name:"developLoop",type:"false",optional:!0,note:"false = started with the develop loop off; absent = on"},{name:"restoredSession",type:"true",optional:!0,note:"claudeSessionId adopted from an existing CLI session"},{name:"agentCli",type:"string",optional:!0,note:"agent CLI running the session; absent = Claude Code; fixed for the session"},{name:"agentCliModel",type:"string",optional:!0,note:"model string passed to agentCli; absent = its default"},{name:"sections",type:"EpicIntakeSection[]",optional:!0},{name:"worktree",type:"{ dir, branch, baseCwd, status, conflictReason? }",optional:!0,note:"own git worktree on branch 'sm-epic/<id>' when Active"}],notes:["SINGLE-CREATOR LAW, fail-closed in epicMint.cjs — the New Epic IPC handler and crossProjectFeedback.cjs are the only mint authorities.","Every Epic is born proposed; nothing is created directly as active.","EPIC : claude-session is 1:1 — Chat and Terminal are two VIEWS over one session.","Title + objective are fixed for the life of the session — iterate in follow-up messages, don't repurpose."]},{id:"epicEvent",name:"PromptSessionEvent",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> events[]",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts + src/main/lib/epic/activeIndexMerge.cjs "},summary:"One step in an Epic's Prompt → PRD → Response → ... → Closed chain.",fields:[{name:"id",type:"string",key:"pk"},{name:"promptSessionId",type:"string",key:"fk",ref:"epic.id"},{name:"kind",type:"'prompt' | 'prd_created' | 'response' | 'closed'"},{name:"causedByEventId",type:"string | null",key:"fk",ref:"epicEvent.id",note:"must be the session's current tail event — a chain, not a tree"},{name:"at",type:"string"},{name:"prdSlug",type:"string",optional:!0,key:"fk",ref:"prd.slug"},{name:"text",type:"string",optional:!0},{name:"outcome",type:"'completed' | 'failed' | 'needs_review'",optional:!0},{name:"validation",type:"'unvalidated' | 'validating' | 'verified' | 'refuted'",optional:!0}]},{id:"epicTranscriptTurn",name:"PromptSessionTranscriptTurn",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/transcripts/<epicId>.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/promptSessionTranscript.cjs "},summary:"The durable per-Epic transcript store, kept alongside the CLI's own JSONL as a fallback source of turns.",fields:[{name:"v",type:"1"},{name:"epicId",type:"string",key:"fk",ref:"epic.id"},{name:"eventId",type:"string | null",key:"fk",ref:"epicEvent.id"},{name:"role",type:"'user' | 'assistant'"},{name:"at",type:"string"},{name:"text",type:"string"}]},{id:"epicArchive",name:"PromptSessionArchive",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/<epicId>.json",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts (promptSessionArchivePath) "},summary:"On-disk archive written once at completion — freezes the Epic, its events, and its transcript.",fields:[{name:"session",type:"PromptSession"},{name:"events",type:"PromptSessionEvent[]"},{name:"transcript",type:"string"},{name:"archivedAt",type:"string"},{name:"durableTurns",type:"Array<{ role, text, at }>",optional:!0}]},{id:"epicWorktreeConfig",name:"EpicWorktreeConfig",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/epic-worktree-config.json",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicWorktreeProjectConfig.cjs "},summary:"Per-project 'disable Epic worktree isolation' toggle, read by gitWorktree.cjs's isWorktreeDisabled('epic', cwd) on every worktree creation attempt.",fields:[{name:"disabled",type:"boolean"}],notes:["One-shot migration from the legacy machine-wide ~/.claude/session-manager/epic-worktree-project-config.json map, keyed by project cwd — that file is left in place, never deleted."]},{id:"exchange",name:"Exchange",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/exchanges.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/exchanges.cjs "},summary:"One durable NDJSON record per completed terminal-chat exchange, appended off the hot path.",fields:[{name:"ts",type:"string"},{name:"sessionId",type:"string",key:"fk",ref:"epic.claudeSessionId",note:"the tab's claude session id"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"prompt",type:"string"},{name:"result",type:"string"},{name:"summary",type:"string",note:"produced by the shared Haiku summarizer"},{name:"model",type:"string"},{name:"degraded",type:"string",optional:!0,note:"set when summarization failed — the exchange itself is never dropped"},{name:"promptId",type:"string",optional:!0,key:"fk",ref:"prd.slug",note:"originating PromptTicket.id when dispatched from the per-tab queue; forward-only, never backfilled"}],notes:["Written via raw fs O_APPEND (not config.cjs writeJson) for atomicity across concurrent writers — assertOpsWrite is called explicitly since raw fs bypasses the normal enforcement point.","Historical rows from before this store existed remain, untouched and unmigrated, in the old global ~/.claude/knowledge-log/exchanges/<encodeCwd(cwd)>.jsonl."]},{id:"prd",name:"PRD",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/epics/<epicId>/prds/<slug>.md",format:"markdown",writer:"scheduler",definedIn:"src/main/lib/prd/prdLocations.cjs + scheduler_create_prd MCP tool "},summary:"PRD authoring is API-only via the scheduler_create_prd MCP tool — a PRD joins an EXISTING Epic and never conjures one.",fields:[{name:"slug",type:"string",key:"pk",note:"<nn>-<kebab-title>.md filename stem"},{name:"title",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"epicId",type:"string | null",key:"fk",ref:"epic.id",note:"derived from the PRD's DIRECTORY — fact on disk"},{name:"sourcePromptId",type:"string",optional:!0,key:"fk",ref:"epic.id",note:"frontmatter intent — can disagree with epicId"},{name:"sourceTabId",type:"string",optional:!0},{name:"estimateMinutes",type:"number"},{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",optional:!0,key:"fk",ref:"tag.tag"},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug",note:"the SOLE ordering primitive"},{name:"goal",type:"string"},{name:"acceptanceCriteria",type:"string[]"},{name:"implementationNotes",type:"string"},{name:"outOfScope",type:"string[]",optional:!0},{name:"createdVia",type:"string",optional:!0},{name:"issuedAt",type:"string",optional:!0}],notes:["Flat scheduler/prds/ is RETIRED — auto-consolidated into prds-archived/ on every reconcile() pass.","epicId is derived from the DIRECTORY (fact on disk) while sourcePromptId is frontmatter intent and can disagree."]},{id:"scheduleJob",name:"ScheduleJob",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs + src/main/lib/scheduler/scheduleJobSchema.cjs "},summary:"dependsOn is the SOLE ordering primitive — parallelGroup is a display hint, never a barrier.",fields:[{name:"slug",type:"string",key:"pk",note:"shared identity with the PRD it executes"},{name:"title",type:"string"},{name:"cwd",type:"string | null",key:"fk",ref:"project.cwd"},{name:"parallelGroup",type:"number"},{name:"estimateMinutes",type:"number | null"},{name:"bodyPreview",type:"string"},{name:"status",type:"'pending' | 'running' | 'investigating' | 'completed' | 'failed' | 'needs_review' | 'quarantined'"},{name:"runId",type:"string | null",key:"fk",ref:"runLog.runId"},{name:"startedAt",type:"string | null"},{name:"finishedAt",type:"string | null"},{name:"exitCode",type:"number | null"},{name:"error",type:"string | null"},{name:"sessionId",type:"string",optional:!0},{name:"runtime",type:"ScheduleJobRuntime",optional:!0,note:"{ pid, runId, startedAt, sessionId?, cwd? }"},{name:"verifierVerdict",type:"string",optional:!0},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug"},{name:"originSessionId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"sourceTabId",type:"string | null",optional:!0},{name:"sourcePromptId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id",note:"authoritative — derived from the PRD directory"},{name:"statusHistory",type:"ScheduleJobStatusHistoryEntry[]",optional:!0}],notes:["Every launch must take a slot from lib/scheduler/sessionSlots.cjs — the single machine-wide concurrency limit.","--model is always pinned on every claude -p call site.","A job in needs_review is a QUESTION routed back to the authoring Epic and never creates work on its own."]},{id:"scheduleJobStatusHistory",name:"ScheduleJobStatusHistoryEntry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[].statusHistory[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/scheduleJobTransitions.cjs "},summary:"Bounded trail (~20 entries) of accepted status transitions for one ScheduleJob.",fields:[{name:"from",type:"string | null"},{name:"to",type:"string"},{name:"reason",type:"string | null"},{name:"source",type:"string | null"},{name:"at",type:"string"}]},{id:"scheduleHistoryEntry",name:"Schedule history entry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/history.jsonl",format:"jsonl",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs "},summary:"Terminal jobs aged out of queue.json land here, one JSON object per line.",fields:[{name:"slug",type:"string",key:"fk",ref:"prd.slug"},{name:"status",type:"ScheduleJobStatus"},{name:"finishedAt",type:"string | null"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"runId",type:"string | null",optional:!0,key:"fk",ref:"runLog.runId"}]},{id:"scheduleConfig",name:"ScheduleConfig",group:"scheduler",store:{path:"~/.claude/session-manager/scheduler-machine.json",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/schedulerConfig.cjs + src/main/lib/scheduler/queueStore.cjs "},summary:"Machine-level auto-fire policy and utilization gate (scheduler-machine.json, not per-project queue.json).",fields:[{name:"enabled",type:"boolean",note:"legacy on/off, kept for v0.4 backwards compat"},{name:"offsetMinutes",type:"number"},{name:"defaultCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"firePolicy",type:"'manual' | 'when-available'"},{name:"utilizationThreshold",type:"number"},{name:"schemaVersion",type:"1"}]},{id:"runLog",name:"Run log",group:"scheduler",store:{path:"~/.claude/session-manager/scheduled-plans/runs/<runId>/",format:"directory",definedIn:"src/main/scheduler.cjs (RUNS_DIR) "},summary:"One directory per headless claude -p invocation — stdout/stderr/exit capture for a ScheduleJob's run.",fields:[{name:"runId",type:"string",key:"pk"}]},{id:"agentPersona",name:"AgentPersona",aka:"ACTOR",group:"agents",store:{path:"~/.claude/agents/<name>.md",format:"markdown",definedIn:"src/main/agentLibrary.cjs + src/main/lib/persona-macro/agentPersonaSchema.cjs "},summary:"One global persona. The action/actionLabel frontmatter keys are retired legacy fields — no longer a live concept.",fields:[{name:"name",type:"string",key:"pk"},{name:"description",type:"string | null"},{name:"tools",type:"string[]"},{name:"model",type:"string | null",note:"wins over the Settings default for this Epic"},{name:"color",type:"string | null"},{name:"tags",type:"AgentPersonaTag[]",key:"fk",ref:"tag.tag"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd",note:"'*' means every project"},{name:"effort",type:"string | null",optional:!0,note:"per-Epic carve-out like model — persona frontmatter wins over the Settings default"},{name:"title",type:"string | null",optional:!0},{name:"path",type:"string"},{name:"body",type:"string"},{name:"overridingProjects",type:"string[]"}]},{id:"tag",name:"Tag",aka:"MISSION — EpicTag",group:"agents",store:{path:"src/renderer/lib/tagLibrary.ts (TAG_LIBRARY)",format:"code",definedIn:"src/renderer/lib/tagLibrary.ts + src/renderer/lib/agentTagDefs.ts "},summary:"The closed 7-tag union — Epic creation is agentType (who) + tag (what), two independent selections.",fields:[{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",key:"pk"},{name:"label",type:"string"},{name:"description",type:"string"},{name:"developEagerness",type:"'expected-default' | 'available-not-assumed'"},{name:"developsVia",type:"string"}]},{id:"macro",name:"Macro",aka:"HOT KEY",group:"agents",store:{path:"~/.claude/session-manager/macros.json",format:"json",writer:"src/main/lib/persona-macro/macroLibrary.cjs",definedIn:"src/main/lib/persona-macro/macroLibrary.cjs "},summary:"A saved (agent, tag, prompt) hot key — machine-local library; a Sessions hot key is shown per project, a Project Home tool in every project; pressing it is the same act as New Session.",fields:[{name:"id",type:"string",key:"pk"},{name:"label",type:"string"},{name:"agentName",type:"string",key:"fk",ref:"agentPersona.name"},{name:"tag",type:"TicketTag",key:"fk",ref:"tag.tag"},{name:"prompt",type:"string"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd"},{name:"surface",type:"string"},{name:"builtin",type:"boolean",optional:!0},{name:"builtinVersion",type:"number",optional:!0},{name:"createdAt",type:"string"},{name:"updatedAt",type:"string"},{name:"inputs",type:"MacroInput[]",optional:!0},{name:"autoStartTargets",type:"string[]",optional:!0,key:"fk",ref:"project.cwd"}]},{id:"memoryEntry",name:"MemoryEntry",group:"memory",store:{path:"~/.claude/projects/<encodedCwd>/memory/<name>.md",format:"markdown",definedIn:"src/main/memoryTool.cjs "},summary:"One workspace memory file, semantically organized by topic.",fields:[{name:"name",type:"string",key:"pk"},{name:"path",type:"string"},{name:"mtimeMs",type:"number"},{name:"bytes",type:"number"},{name:"workspace",type:"string",key:"fk",ref:"project.cwd",note:"carried on MemoryListResult, denormalized here — the directory this entry lives under"}]},{id:"memoryCluster",name:"MemoryCluster",group:"memory",store:{path:"<cwd>/session-manager-operations/memory-clusters/clusters.json",format:"json",writer:"memory-clusters",definedIn:"src/main/memoryAggregate.cjs "},summary:"Derived grouping of related MemoryEntry files, computed and cached per workspace.",fields:[{name:"id",type:"string",key:"pk"},{name:"name",type:"string"},{name:"summary",type:"string"},{name:"memberSlugs",type:"string[]",key:"fk",ref:"memoryEntry.name"},{name:"links",type:"MemoryClusterLink[]",note:"{ from, to, label? }"}]},{id:"agentMemoryEntry",name:"AgentMemoryEntry",group:"memory",store:{path:"~/.claude/agent-memory/<agent>/ | .claude/agent-memory/<agent>/ | .claude/agent-memory-local/<agent>/",format:"directory",definedIn:"src/main/lib/memoryDirResolve.cjs (resolveAgentMemoryDir)"},summary:"Per-subagent memory in Claude Code's native agent-memory directories (user, project, local scope), keyed by agent name — markdown files with a MEMORY.md index.",fields:[{name:"agent",type:"string",key:"pk",ref:"agentPersona.name",note:"directory name under the scope root"},{name:"scope",type:"'user' | 'project' | 'local'",note:"selects which agent-memory root resolveAgentMemoryDir returns"},{name:"files",type:"markdown[]",note:"topic files plus MEMORY.md index, read live from disk"}]},{id:"claudeTranscript",name:"Claude transcript",group:"transcript",store:{path:"~/.claude/projects/<encodedCwd>/<sessionUuid>.jsonl",format:"jsonl",definedIn:"written by the Claude Code CLI; tailed by src/main/transcripts.cjs "},summary:"The CLI's own append-only transcript — Session Manager only tails and classifies it, never writes it.",fields:[{name:"sessionUuid",type:"string",key:"pk"},{name:"encodedCwd",type:"string",key:"fk",ref:"project.cwd"}]},{id:"transcriptEvent",name:"TranscriptEvent",group:"transcript",store:{path:"in-memory ring buffer, broadcast as transcript:event:<tabId>",format:"in-memory",definedIn:"src/main/transcripts.cjs -> src/renderer/state/live.ts "},summary:"Classified, bounded-preview view over one raw transcript line — never the source of truth.",fields:[{name:"kind",type:"TranscriptEventKind"},{name:"data",type:"unknown"},{name:"raw",type:"unknown"},{name:"previewText",type:"string"},{name:"ref",type:"TranscriptEventRef | null",note:"{ filePath, byteOffset, byteLength }"},{name:"tabId",type:"string",key:"fk",ref:"tab.id"}]},{id:"historyRollupDay",name:"History rollup day",group:"transcript",store:{path:"~/.claude/session-manager/history-rollup.jsonl",format:"jsonl",definedIn:"src/main/lib/historyRollup.cjs "},summary:"One finalized day-per-project analytics row (History tab is analytics/cost/charts only).",fields:[{name:"date",type:"string",key:"pk"},{name:"projectCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"promptCount",type:"number"},{name:"inputTokens",type:"number"},{name:"outputTokens",type:"number"},{name:"estimatedCostUsd",type:"number"}]},{id:"billingUsage",name:"UsageSnapshot",group:"transcript",store:{path:"~/.claude/session-manager/billing-cache.json",format:"json",definedIn:"src/main/usage.cjs (CACHE_PATH) "},summary:"Cached rolling-window utilization percentages from the account's billing API.",fields:[{name:"five_hour",type:"UsageWindow | null"},{name:"seven_day",type:"UsageWindow | null"},{name:"seven_day_sonnet",type:"UsageWindow | null"},{name:"seven_day_opus",type:"UsageWindow | null"},{name:"seven_day_oauth_apps",type:"UsageWindow | null"},{name:"extra_usage",type:"{ is_enabled, monthly_limit, used_credits, utilization, currency } | null"}]},{id:"projectBrief",name:"ProjectBrief",group:"brief",store:{path:"<cwd>/session-manager-operations/project-brief/brief.json",format:"json",writer:"project-home",definedIn:"src/main/projectBrief.cjs "},summary:"The synthesized project Brief — generated, with a hand-edit escape hatch.",fields:[{name:"version",type:"number"},{name:"synthesizedAt",type:"string"},{name:"editedAt",type:"string | null"},{name:"model",type:"string"},{name:"purpose",type:"string"},{name:"what",type:"string[]"},{name:"areas",type:"ProjectBriefArea[]",note:"{ name, files, note, epic, heat }"},{name:"scope",type:"ProjectBriefScopeEntry[]",note:"{ when, kind, text, src }"},{name:"conventions",type:"string[]"},{name:"pins",type:"{ what: boolean; conventions: boolean }"},{name:"pinned",type:"{ what: string[] | null; conventions: string[] | null }"}]},{id:"projectPages",name:"ProjectPagesOutput",group:"brief",store:{path:"<cwd>/session-manager-operations/project-pages/ (knowledge/<id>/, videos/<id>/, videos/_character/)",format:"directory",writer:"project-home",definedIn:"src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs (pages, videos and character routes)"},summary:"The Project Home library: Knowledge Pages and Video Pages, each a folder holding index.html + meta.json.",fields:[{name:"html",type:"string | null"},{name:"mtimeMs",type:"number | null"}]},{id:"settingsScope",name:"Settings (scoped)",group:"config",store:{path:"~/.claude/settings.json + <cwd>/.claude/settings.json + <cwd>/.claude/settings.local.json",format:"json",definedIn:"src/main/config.cjs + src/renderer/state/config.ts + src/renderer/lib/mergeScopes.ts "},summary:"Substrate, not per-Epic curation — model is the one field carved out per-Epic (persona wins over Settings).",fields:[{name:"scope",type:"'system' | 'project' | 'local'",key:"pk"},{name:"cwd",type:"string",optional:!0,key:"fk",ref:"project.cwd"},{name:"model",type:"string",optional:!0}]},{id:"layoutEnvelope",name:"LayoutEnvelope",group:"config",store:{path:"~/.claude/session-manager/workbench-layout.json",format:"json",definedIn:"src/main/layoutStore.cjs + src/renderer/state/layout.ts "},summary:"Persisted dockview panel layout, pruned against the live panel registry on hydrate.",fields:[{name:"version",type:"number"},{name:"panels",type:"string[]",key:"fk",ref:"tab.id"},{name:"dockview",type:"Record<string, unknown>",note:"opaque SerializedDockview blob"}]},{id:"opsNamespace",name:"Ops namespace ownership",aka:"the SINGLE-WRITER LAW",group:"config",store:{path:"src/main/lib/opsOwnership.cjs (OWNERS)",format:"code",definedIn:"src/main/lib/opsOwnership.cjs (assertOpsWrite) "},summary:"Fail-closed — a new top-level ops folder must land in OWNERS (or the deliberately-unowned list) in the same PR that creates it.",fields:[{name:"namespace",type:"string",key:"pk",note:"e.g. 'prompt-sessions', 'scheduler', 'project-brief'"},{name:"writer",type:"string",note:"e.g. 'epics', 'scheduler', 'project-home'"}]},{id:"mcpServerRegistry",name:"MCP server registry",aka:"mcpServers",group:"config",store:{path:"~/.claude.json -> mcpServers",format:"json",definedIn:"src/renderer/components/tabs/McpServers.tsx "},summary:"User-scope MCP server config — no single writer, since both the claude CLI and this app read/write the same file.",fields:[{name:"name",type:"string",key:"pk"},{name:"type",type:"'stdio' | 'http' | 'sse' | 'ws' | 'streamable-http'",optional:!0},{name:"command",type:"string",optional:!0},{name:"args",type:"string[]",optional:!0},{name:"url",type:"string",optional:!0},{name:"env",type:"Record<string, string>",optional:!0},{name:"headers",type:"Record<string, string>",optional:!0},{name:"alwaysLoad",type:"boolean",optional:!0},{name:"enabled",type:"boolean",optional:!0},{name:"disabledTools",type:"string[]",optional:!0}]},{id:"pluginRegistry",name:"Installed plugins manifest",aka:"installed_plugins.json",group:"config",store:{path:"~/.claude/plugins/installed_plugins.json",format:"json",definedIn:"src/renderer/components/tabs/Plugins.tsx "},summary:'Registry of installed plugin versions, keyed by "<name>@<marketplace>" — written by `claude plugin install`, read-only in the Plugins screen.',fields:[{name:"pluginKey",type:"string",key:"pk",note:"<name>@<marketplace>"},{name:"scope",type:"string"},{name:"installPath",type:"string"},{name:"version",type:"string"},{name:"installedAt",type:"string"},{name:"lastUpdated",type:"string"},{name:"gitCommitSha",type:"string",optional:!0}]},{id:"systemPrompt",name:"User CLAUDE.md",aka:"~/.claude/CLAUDE.md",group:"config",store:{path:"~/.claude/CLAUDE.md",format:"markdown",definedIn:"src/renderer/components/tabs/SystemPrompt.tsx "},summary:"The real ~/.claude/CLAUDE.md the claude CLI loads into every session it starts on this machine, in every project — edited here as plain markdown.",fields:[{name:"content",type:"string"},{name:"imports",type:"string[]",note:"@-imported files, listed in a left rail"}]},{id:"skillsAndCommands",name:"Skills & Commands",group:"config",store:{path:"~/.claude/skills/**/SKILL.md + ~/.claude/commands/*.md (and the <cwd>/.claude equivalents for project scope)",format:"directory",definedIn:"src/renderer/components/tabs/Skills.tsx "},summary:"User- and project-scope skill/command markdown files, each editable in place.",fields:[{name:"kind",type:"'skills' | 'commands'"},{name:"scope",type:"'user' | 'project'"},{name:"name",type:"string",key:"pk"},{name:"path",type:"string",note:"absolute path to the editable markdown file"},{name:"dir",type:"string | null",note:"skill directory, if applicable"},{name:"disabled",type:"boolean",note:"skills only — disable-model-invocation: true frontmatter"},{name:"description",type:"string",optional:!0}]},{id:"mcpStatusProbe",name:"MCP status probe",group:"config",store:{path:"in-memory result of `claude mcp list`, never persisted",format:"in-memory",definedIn:"src/main/mcpStatus.cjs (runProbe) "},summary:"Read-only, non-polling live connection probe — models an in-memory-only shape honestly, the same way transcriptEvent does.",fields:[{name:"ok",type:"boolean"},{name:"servers",type:"McpServerStatus[]",note:"{ name, target, transport, status }"},{name:"error",type:"string",optional:!0},{name:"checkedAt",type:"number"}]},{id:"appPrefs",name:"App preferences",aka:"app-prefs / ui-settings-prefs / ui-chrome-prefs",group:"config",store:{path:"~/.claude/session-manager/app-prefs.json + ~/.claude/session-manager/ui-settings-prefs.json + ~/.claude/session-manager/ui-chrome-prefs.json",format:"json",definedIn:"src/renderer/lib/appPrefs.ts (app-prefs.json) + src/renderer/lib/uiSettingsPrefs.ts (ui-settings-prefs.json) + src/renderer/state/uiChromePrefs.ts (ui-chrome-prefs.json) "},summary:"Three small machine-level renderer-owned pref files, read/written through window.api.config — distinct from scheduler-machine.json.",fields:[{name:"openToHomeOnLaunch",type:"boolean",optional:!0,note:"app-prefs.json — read by layout.ts at boot"},{name:"uiSettings",type:"Record<string, unknown>",optional:!0,note:"ui-settings-prefs.json — Settings page UI state"},{name:"uiChrome",type:"Record<string, unknown>",optional:!0,note:"ui-chrome-prefs.json — app chrome UI state"}]},{id:"uiPrefs",name:"UiPrefs",aka:"ui-prefs/prefs.json",group:"config",store:{path:"<cwd>/session-manager-operations/ui-prefs/prefs.json",format:"json",writer:"ui-prefs",definedIn:"src/renderer/lib/uiPrefs.ts "},summary:"Per-project UI state that used to live in scattered global/localStorage keys — one file per project keeps it scoped to the project it belongs to by construction (PRD 1398/1399).",fields:[{name:"fileTreeExpanded",type:"string[]",optional:!0,note:"FileTree.tsx — expanded folder paths in the Files sidebar"},{name:"hiddenCompletedSlugs",type:"string[]",optional:!0,note:'SchedulePanel.tsx — "Clear completed" hides, renderer-side only'},{name:"queueFilterStatus",type:"string",optional:!0,note:"SchedulePanel.tsx — the queue's status filter chip"},{name:"epicPins",type:"Record<string, boolean>",optional:!0,key:"fk",ref:"epic.id",note:"epicsPrefs.ts — pinned-to-top Epic ids, keyed by epicId (moved off the global epics-prefs.json)"},{name:"chatVerbosityPerEpic",type:"Record<string, ChatVerbosity>",optional:!0,key:"fk",ref:"epic.id",note:"chatPrefs.ts — per-Epic verbosity overrides, keyed by epicId (moved off the global chat-prefs.json)"},{name:"editorSession",type:"{ openFiles: string[]; activeFilePath: string | null; viewModeByPath: Record<string, string> }",optional:!0,note:"editor.ts — the Editor scene's structural tab strip only; buffers/baselines/dirty are never persisted (PRD 1400)"}]}];function ne(t){const n=F.find(s=>s.id===t);if(!n)throw new Error(`unknown ErdEntity id: ${t}`);return n}const je=[{from:"tab",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"epic",to:"agentPersona",cardinality:"N-1",label:"actor",optional:!0},{from:"epic",to:"epic",cardinality:"N-1",label:"resumed from",optional:!0},{from:"epic",to:"claudeTranscript",cardinality:"1-1",label:"1:1 session"},{from:"epicEvent",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicEvent",to:"epicEvent",cardinality:"N-1",label:"caused by",optional:!0},{from:"epicEvent",to:"prd",cardinality:"N-1",label:"about",optional:!0},{from:"epicTranscriptTurn",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicTranscriptTurn",to:"epicEvent",cardinality:"N-1",label:"labeled by",optional:!0},{from:"epicArchive",to:"epic",cardinality:"1-1",label:"freezes"},{from:"exchange",to:"epic",cardinality:"N-1",label:"session for",optional:!0},{from:"exchange",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"epic",cardinality:"N-1",label:"joins (directory fact)"},{from:"prd",to:"epic",cardinality:"N-1",via:"sourcePromptId",label:"authored from (frontmatter intent)",optional:!0},{from:"prd",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"scheduleJob",to:"prd",cardinality:"1-1",label:"executes"},{from:"scheduleJob",to:"prd",cardinality:"N-N",via:"dependsOn",label:"depends on",optional:!0},{from:"scheduleJob",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleJob",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleJob",to:"scheduleJob",cardinality:"N-N",via:"dependsOn",label:"depends on (self)",optional:!0},{from:"scheduleJobStatusHistory",to:"scheduleJob",cardinality:"N-1",label:"transitions of"},{from:"scheduleHistoryEntry",to:"prd",cardinality:"N-1",label:"archives"},{from:"scheduleHistoryEntry",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleHistoryEntry",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleConfig",to:"project",cardinality:"1-1",label:"configures"},{from:"agentPersona",to:"tag",cardinality:"N-N",label:"tagged with"},{from:"agentPersona",to:"project",cardinality:"N-N",label:"scoped to"},{from:"memoryEntry",to:"project",cardinality:"N-1",label:"workspace"},{from:"memoryCluster",to:"memoryEntry",cardinality:"1-N",label:"clusters"},{from:"agentMemoryEntry",to:"agentPersona",cardinality:"N-1",label:"belongs to"},{from:"transcriptEvent",to:"tab",cardinality:"N-1",label:"classified for"},{from:"transcriptEvent",to:"claudeTranscript",cardinality:"N-1",label:"classified from"},{from:"claudeTranscript",to:"project",cardinality:"N-1",label:"belongs to"},{from:"historyRollupDay",to:"project",cardinality:"N-N",label:"aggregates"},{from:"billingUsage",to:"scheduleConfig",cardinality:"1-N",label:"gates when-available firing"},{from:"projectBrief",to:"project",cardinality:"1-1",label:"describes"},{from:"projectBrief",to:"epic",cardinality:"N-1",via:"areas[].epic",label:"traces to",optional:!0},{from:"projectPages",to:"project",cardinality:"1-1",label:"generated for"},{from:"settingsScope",to:"project",cardinality:"N-1",label:"scoped to",optional:!0},{from:"layoutEnvelope",to:"tab",cardinality:"1-N",label:"panels for"},{from:"opsNamespace",to:"epic",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"prd",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"projectBrief",cardinality:"1-N",label:"governs writes"}];function ve(t){return je.filter(n=>n.from===t||n.to===t)}function Pt(t){const n=new Set;for(const s of ve(t)){const r=s.from===t?s.to:s.from;r!==t&&n.add(r)}return[...n]}function Rt(t){switch(t){case"1-1":return"1—1";case"1-N":return"1—N";case"N-1":return"N—1";case"N-N":return"N—N"}}const ge=220,ee=7,At=44,Mt=16,Lt=10,Dt=96,Ot=28,J=24;function $t(t){const n=Math.min(t,ee)+(t>ee?1:0);return At+n*Mt+Lt}function _t(t){const n=t.x+t.w,s=t.y+t.h*.35,r=t.y+t.h*.65,i=n+48;return{d:`M ${n} ${s} C ${i} ${s}, ${i} ${r}, ${n} ${r}`,mx:i,my:(s+r)/2}}function Ht(t=F,n=je){const s=Y.map(m=>m.id).filter(m=>t.some(f=>f.group===m)),r=[],i=new Map;s.forEach((m,f)=>{const u=J+f*(ge+Dt);let p=J;for(const g of t){if(g.group!==m)continue;const j=$t(g.fields.length),v={id:g.id,group:m,x:u,y:p,w:ge,h:j};r.push(v),i.set(g.id,v),p+=j+Ot}});const a=new Set(t.map(m=>m.id)),l=[];for(const m of n){if(!a.has(m.from)||!a.has(m.to))continue;const f=i.get(m.from),u=i.get(m.to);if(!f||!u)continue;if(m.from===m.to){const T=_t(f);l.push({relation:m,...T});continue}const p=f.x<u.x,g=p?f.x+f.w:f.x,j=f.y+f.h/2,v=p?u.x:u.x+u.w,N=u.y+u.h/2,S=Math.max(40,Math.abs(v-g)/2),h=g+(p?S:-S),w=v+(p?-S:S),C=`M ${g} ${j} C ${h} ${j}, ${w} ${N}, ${v} ${N}`;l.push({relation:m,d:C,mx:(g+v)/2,my:(j+N)/2})}const c=r.reduce((m,f)=>Math.max(m,f.x+f.w),0),y=r.reduce((m,f)=>Math.max(m,f.y+f.h),0);return{boxes:r,edges:l,width:c+J,height:y+J}}const Bt=[{key:"diagram",label:"Diagram"},{key:"tables",label:"Tables"}];function Ft(){const[t,n]=o.useState("diagram"),[s,r]=o.useState(null),[i,a]=o.useState(()=>new Set),l=o.useMemo(()=>F.filter(u=>!i.has(u.group)),[i]),c=o.useMemo(()=>Ht(l),[l]),y=u=>{a(p=>{const g=new Set(p);return g.has(u)?g.delete(u):g.add(u),g}),r(null)},m=s?ne(s):null,f=u=>l.some(p=>p.id===u);return e.jsx(nt,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(xe,{options:Bt,active:t,onChange:n}),e.jsx(zt,{hiddenGroups:i,onToggle:y}),e.jsxs("span",{className:"ml-auto text-fg-faint",children:[F.length," entities"]})]}),children:t==="diagram"?e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(Wt,{layout:c,selectedId:s,onSelect:u=>r(p=>p===u?null:u)})}),e.jsx("div",{className:"w-96 shrink-0 border-l border-line overflow-y-auto",children:m?e.jsx(Vt,{entity:m,onSelectRelated:u=>f(u)?r(u):void 0}):e.jsx(q,{title:"select an entity",hint:"click a box in the diagram to see its storage, fields, and relations"})})]}):e.jsx(Gt,{})})}const Ut=o.memo(Ft);function zt({hiddenGroups:t,onToggle:n}){return e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:Y.map(s=>{const r=t.has(s.id);return e.jsxs("button",{onClick:()=>n(s.id),title:`${s.blurb} (${s.realm})`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10.5px] ${r?"border-line text-fg-faint opacity-50":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${s.tone.dot}`}),s.label,e.jsx("span",{className:"text-fg-faint",children:s.realm})]},s.id)})})}function Wt({layout:t,selectedId:n,onSelect:s}){const r=o.useMemo(()=>n?new Set(Pt(n)):null,[n]),i=a=>!!n&&(a.relation.from===n||a.relation.to===n);return t.boxes.length===0?e.jsx(q,{title:"no entities in view",hint:"toggle a group in the legend to show its entities"}):e.jsxs("div",{className:"relative p-4",style:{width:t.width+32,height:t.height+32},children:[e.jsxs("svg",{width:t.width,height:t.height,className:"absolute left-4 top-4 overflow-visible",children:[t.edges.map(a=>{const l=i(a);return e.jsx("path",{"data-testid":`erd-edge-${a.relation.from}-${a.relation.to}`,d:a.d,fill:"none",className:l?"stroke-accent":"stroke-line",strokeWidth:l?2:1,opacity:n&&!l?.25:1},`${a.relation.from}-${a.relation.to}-${a.relation.label}`)}),t.edges.map(a=>i(a)?e.jsx("text",{x:a.mx,y:a.my,textAnchor:"middle",className:"fill-fg-dim text-[10px]",children:a.relation.label},`label-${a.relation.from}-${a.relation.to}-${a.relation.label}`):null)]}),t.boxes.map(a=>e.jsx(Jt,{box:a,selected:a.id===n,dimmed:!!n&&a.id!==n&&!(r!=null&&r.has(a.id)),onClick:()=>s(a.id)},a.id))]})}function Jt({box:t,selected:n,dimmed:s,onClick:r}){const i=ne(t.id),a=be(t.group),l=i.fields.slice(0,ee),c=i.fields.length-l.length;return e.jsxs("button",{type:"button","data-testid":`erd-box-${t.id}`,onClick:r,className:`absolute text-left rounded border overflow-hidden bg-bg-hi ${n?"border-accent ring-1 ring-accent":"border-line"} ${s?"opacity-30":""}`,style:{left:t.x,top:t.y,width:t.w,height:t.h},children:[e.jsxs("div",{className:"px-2 py-1 border-b border-line flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${a.tone.dot}`}),e.jsx("span",{className:"text-[11px] font-semibold text-fg truncate",children:i.name})]}),i.aka&&e.jsx("div",{className:"px-2 pt-0.5 text-[9.5px] text-fg-faint truncate",children:i.aka}),e.jsxs("div",{className:"px-2 py-0.5",children:[l.map(y=>e.jsxs("div",{className:"text-[9.5px] font-mono text-fg-dim truncate flex items-center gap-1",children:[y.key&&e.jsx("span",{className:"text-fg-faint",children:y.key}),e.jsx("span",{className:"truncate",children:y.name})]},y.name)),c>0&&e.jsxs("div",{className:"text-[9.5px] text-fg-faint italic",children:["+",c," more"]})]})]})}function we({fields:t}){return e.jsxs("table",{className:"w-full text-[11px] font-mono",children:[e.jsx("thead",{className:"text-fg-faint uppercase tracking-wide text-[9.5px]",children:e.jsxs("tr",{className:"border-b border-line",children:[e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"name"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"type"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"key"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"note"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{className:"border-b border-line/50",children:[e.jsxs("td",{className:"px-2 py-1 text-fg",children:[n.name,n.optional&&e.jsx("span",{className:"text-fg-faint",children:"?"})]}),e.jsx("td",{className:"px-2 py-1 text-fg-dim",children:n.type}),e.jsx("td",{className:"px-2 py-1",children:n.key&&e.jsxs(L,{tone:n.key==="pk"?"accent":"dim",children:[n.key,n.ref?` → ${n.ref}`:""]})}),e.jsx("td",{className:"px-2 py-1 text-fg-faint",children:n.note})]},n.name))})]})}function ke({entity:t}){return e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"path"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:t.store.path})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"format"}),e.jsx("span",{className:"font-mono text-fg-dim",children:t.store.format})]}),t.store.writer&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"writer"}),e.jsxs(L,{tone:"accent",children:["single-writer: ",t.store.writer]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"definedIn"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:t.store.definedIn})]})]})}function Vt({entity:t,onSelectRelated:n}){const s=be(t.group),r=ve(t.id);return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s.tone.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.name})]}),t.aka&&e.jsx("div",{className:"text-[10.5px] text-fg-faint",children:t.aka}),e.jsx(L,{tone:"dim",className:"mt-1",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.summary}),e.jsxs("div",{children:[e.jsx(V,{children:"storage"}),e.jsx(ke,{entity:t})]}),e.jsxs("div",{children:[e.jsx(V,{children:"fields"}),e.jsx(we,{fields:t.fields})]}),t.notes&&t.notes.length>0&&e.jsxs("div",{children:[e.jsx(V,{children:"notes"}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:t.notes.map(i=>e.jsx("li",{children:i},i))})]}),e.jsxs("div",{children:[e.jsx(V,{children:"relations"}),r.length===0?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"no relations"}):e.jsx("ul",{className:"space-y-1",children:r.map(i=>{const a=i.from===t.id?i.to:i.from,l=ne(a);return e.jsxs("li",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-mono text-fg-faint w-10 shrink-0",children:Rt(i.cardinality)}),e.jsx("span",{className:"text-fg-dim",children:i.label}),i.via&&e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:["via ",i.via]}),e.jsx("button",{type:"button",onClick:()=>n(a),className:"ml-auto text-accent hover:underline font-mono",children:l.name})]},`${i.from}-${i.to}-${i.label}`)})})]})]})}function V({children:t}){return e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1 font-mono",children:t})}function Gt(){return e.jsx("div",{className:"p-4 space-y-6",children:Y.map(t=>{const n=F.filter(s=>s.group===t.id);return n.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${t.tone.dot}`}),e.jsx("span",{className:"text-xs font-semibold text-fg",children:t.label}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:t.realm})]}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:n.map(s=>e.jsxs("div",{className:"border border-line rounded bg-bg-hi p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.name}),s.aka&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:s.aka})]}),e.jsx(L,{tone:"dim",className:"mt-1",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.summary}),e.jsx(ke,{entity:s}),e.jsx(we,{fields:s.fields}),s.notes&&s.notes.length>0&&e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:s.notes.map(r=>e.jsx("li",{children:r},r))})]},s.id))})]},t.id)})})}const he=[{key:"voice",label:"Voice"},{key:"appearance",label:"Appearance"},{key:"telemetry",label:"Telemetry"},{key:"remote",label:"Phone remote"},{key:"updates",label:"Updates & retention"},{key:"startup",label:"Startup"},{key:"storage",label:"Storage map"}],qt={compact:"Compact",roomy:"Roomy"},Yt=".claude/session-manager";function Xt({files:t}){const n=qe();return e.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3","data-testid":"app-settings-chips",children:t.map(s=>{const r=s.path.startsWith("~/")?n?n+s.path.slice(1):null:s.path;return r?e.jsx(Qe,{path:r,keyPath:s.keyPath},s.path):null})})}function Kt(){const[t,n]=o.useState(!1),[s,r]=o.useState(!1);o.useEffect(()=>{let a=!0;return Ke().then(l=>{a&&n(l.openToHomeOnLaunch===!0)}),()=>{a=!1}},[]);const i=async a=>{n(a),r(!0);try{await Ze({openToHomeOnLaunch:a})}catch{n(!a),H.error('Failed to save "Open to Home on launch" — try again.')}finally{r(!1)}};return e.jsxs("div",{className:"p-4 max-w-3xl space-y-3 text-sm",children:[e.jsx(O,{checked:t,onChange:i,disabled:s,label:"Open to Home on launch"}),e.jsx(St,{})]})}function Zt(){const{density:t,setDensity:n}=Ye();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsx(pt,{}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx(Xe,{options:["compact","roomy"],value:t,onChange:s=>n(s),labels:qt}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]})}const D=(t,n)=>({path:`~/${Yt}/${t}`,keyPath:n}),Qt={voice:[D("voice.json")],appearance:[{path:Ge,keyPath:["terminal"]},D("ui-chrome-prefs.json")],telemetry:[D("telemetry.json"),D("otel.json")],remote:[D("web-remote.json")],updates:[D("updater.json"),D("ops-retention.json")],startup:[{path:Ve,keyPath:["openToHomeOnLaunch"]}],storage:[]};function rn(){const[t,n]=o.useState("voice");return Je("app-settings",s=>{he.some(r=>r.key===s)&&n(s)}),e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"app-settings",children:[e.jsx("div",{className:"flex items-center px-4 pt-3",children:e.jsx(xe,{options:he,active:t,onChange:n})}),e.jsx(Xt,{files:Qt[t]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto","data-testid":`app-settings-${t}`,children:[t==="voice"&&e.jsx(rt,{open:!0,onClose:()=>{},variant:"page"}),t==="appearance"&&e.jsx(Zt,{}),t==="telemetry"&&e.jsx(gt,{}),t==="remote"&&e.jsx(wt,{}),t==="updates"&&e.jsxs("div",{className:"p-4 max-w-3xl space-y-5",children:[e.jsx(kt,{}),e.jsx(It,{})]}),t==="startup"&&e.jsx(Kt,{}),t==="storage"&&e.jsx(Ut,{})]})]})}export{rn as AppSettings};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{aM as me,aU as Je,bF as et,aB as e,aR as p,ba as X,aN as D,aO as H,by as Fe,bn as tt,bw as Ce,aH as st,bm as nt,m as ot}from"./index-CtxruO1L.js";import{P as at}from"./Panel-CALyU0pe.js";import{p as _e,i as B,m as Oe,t as I,u as $,f as rt}from"./historyTotals-ydfnwepc.js";import"./monaco-editor-BsIlgG7c.js";function ie(){return{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0}}function we(t,s){t.promptCount+=s.promptCount,t.inputTokens+=s.inputTokens,t.outputTokens+=s.outputTokens,t.cacheReadTokens+=s.cacheReadTokens,t.cacheCreationTokens+=s.cacheCreationTokens,t.toolCallCount+=s.toolCallCount,t.sessionCount+=s.sessionCount,t.errorCount+=s.errorCount,t.activeMinutes+=s.activeMinutes,t.estimatedCostUsd+=s.estimatedCostUsd}function ct(t){return t.promptCount>0||t.sessionCount>0||t.toolCallCount>0||t.inputTokens>0||t.outputTokens>0}function it(t,s){const n=s===null,a=[],o=ie(),c={},r={};let i=0;for(const f of t.days){const l=ie();let d=!1;for(const[m,u]of Object.entries(f.byProject)){if(!n&&!s.has(m))continue;we(l,u),we(o,u),ct(u)&&(d=!0);for(const[y,v]of Object.entries(u.byModel)){const x=c[y]??(c[y]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});x.inputTokens+=v.inputTokens,x.outputTokens+=v.outputTokens,x.cacheReadTokens+=v.cacheReadTokens,x.cacheCreationTokens+=v.cacheCreationTokens,x.costUsd+=v.costUsd,v.estimated&&(x.estimated=!0)}const g=u.byLauncher??{};for(const[y,v]of Object.entries(g)){const x=r[y]??(r[y]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0,sessionCount:0});x.inputTokens+=v.inputTokens,x.outputTokens+=v.outputTokens,x.cacheReadTokens+=v.cacheReadTokens,x.cacheCreationTokens+=v.cacheCreationTokens,x.costUsd+=v.costUsd,x.sessionCount+=v.sessionCount}}d&&(i+=1),a.push({date:f.date,totals:l})}return{days:a,totals:o,prevTotals:n?t.prevTotals:ie(),prevAvailable:n,byModelTotals:c,byLauncherTotals:r,activeDays:i}}function He(t,s){if(!s)return{pct:null,direction:"flat"};const n=(t-s)/s*100,a=n>0?"up":n<0?"down":"flat";return{pct:n,direction:a}}function lt(t,s,n){return s<=0?0:t/s*n}const dt=["promptCount","inputTokens","outputTokens","cacheReadTokens","cacheCreationTokens","toolCallCount","sessionCount","errorCount","activeMinutes","estimatedCostUsd"],ut=["inputTokens","outputTokens","cacheReadTokens","cacheCreationTokens","costUsd"];function Re(t){const s={promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0,byModel:{}},n=a=>typeof a=="number"&&Number.isFinite(a)?a:0;for(const a of t){for(const o of dt)s[o]+=n(a[o]);for(const[o,c]of Object.entries(a.byModel??{})){const r=s.byModel[o]??(s.byModel[o]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});for(const i of ut)r[i]+=n(c==null?void 0:c[i])}}return s}const Be={in:"In tokens",out:"Out tokens",total:"Total tokens",prompts:"Prompts",sessions:"Sessions",time:"Time",spend:"Spend"};function E(t,s){const n=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens;switch(s){case"in":return n;case"out":return t.outputTokens;case"total":return n+t.outputTokens;case"prompts":return t.promptCount;case"sessions":return t.sessionCount;case"time":return t.activeMinutes;case"spend":return t.estimatedCostUsd}}function ft(t,s){const n=E(t.totals,s),a=t.prevAvailable?He(n,E(t.prevTotals,s)):null,o=t.days.map(c=>E(c.totals,s));return{value:n,delta:a,series:o}}function Se(t,s){const n=new Map,a=Math.ceil(t.length/2);t.forEach((r,i)=>{for(const[f,l]of Object.entries(r.byProject)){let d=n.get(f);d||(d={totals:{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0},toolBreakdown:{},firstHalf:0,secondHalf:0},n.set(f,d)),d.totals.promptCount+=l.promptCount,d.totals.inputTokens+=l.inputTokens,d.totals.outputTokens+=l.outputTokens,d.totals.cacheReadTokens+=l.cacheReadTokens,d.totals.cacheCreationTokens+=l.cacheCreationTokens,d.totals.toolCallCount+=l.toolCallCount,d.totals.sessionCount+=l.sessionCount,d.totals.errorCount+=l.errorCount,d.totals.activeMinutes+=l.activeMinutes,d.totals.estimatedCostUsd+=l.estimatedCostUsd;for(const[u,g]of Object.entries(l.toolBreakdown))d.toolBreakdown[u]=(d.toolBreakdown[u]??0)+g;const m=E(l,s);i<a?d.firstHalf+=m:d.secondHalf+=m}});const o=Array.from(n.entries()).map(([r,i])=>{let f="",l=-1;for(const[d,m]of Object.entries(i.toolBreakdown))m>l&&(l=m,f=d);return{projectDir:r,value:E(i.totals,s),sharePct:0,trend:He(i.secondHalf,i.firstHalf),sessions:i.totals.sessionCount,topTool:f}}),c=o.reduce((r,i)=>r+i.value,0);for(const r of o)r.sharePct=c>0?r.value/c*100:0;return o.sort((r,i)=>i.value-r.value)}const xt=["date","cost_usd","input_tokens","output_tokens","cache_write_tokens","cache_read_tokens","total_tokens","cache_hit_pct","num_models","top_model"];function ht(t){return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Me(t){return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreationTokens}function pt(t){const s=t.map(n=>{const a=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens,o=n.inputTokens+n.cacheReadTokens+n.cacheCreationTokens,c=o>0?n.cacheReadTokens/o*100:0,r=Object.entries(n.byModel).filter(([,d])=>Me(d)>0);let i="",f=-1;for(const[d,m]of r){const u=Me(m);u>f&&(f=u,i=d)}return[n.date,n.costUsd.toFixed(4),String(n.inputTokens),String(n.outputTokens),String(n.cacheCreationTokens),String(n.cacheReadTokens),String(a),c.toFixed(1),String(r.length),i?me(i):""].map(ht).join(",")});return[xt.join(","),...s].join(`
|
|
2
|
+
`)}const mt=["epic","job","task","other"],xe="sm-task:";function gt(t){return t.startsWith(xe)?"task":t.includes("session-manager-epic-worktrees")?"epic":t.includes("session-manager-job-worktrees")?"job":"other"}const jt={folderCount:0,sessionCount:0,promptCount:0,estimatedCostUsd:0,totalTokens:0};function Ie(t,s,n){const a=t.byLauncher[s]??(t.byLauncher[s]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0,sessionCount:0});a.inputTokens+=n.inputTokens,a.outputTokens+=n.outputTokens,a.cacheReadTokens+=n.cacheReadTokens,a.cacheCreationTokens+=n.cacheCreationTokens,a.costUsd+=n.estimatedCostUsd,a.sessionCount+=n.sessionCount}function $e(t,s,n){t.promptCount+=s.promptCount,t.inputTokens+=s.inputTokens,t.outputTokens+=s.outputTokens,t.cacheReadTokens+=s.cacheReadTokens,t.cacheCreationTokens+=s.cacheCreationTokens,t.toolCallCount+=s.toolCallCount,t.sessionCount+=s.sessionCount,t.errorCount+=s.errorCount,t.activeMinutes+=s.activeMinutes,t.estimatedCostUsd+=s.estimatedCostUsd;for(const[a,o]of Object.entries(s.toolBreakdown??{}))t.toolBreakdown[a]=(t.toolBreakdown[a]??0)+o;for(const[a,o]of Object.entries(s.byModel??{})){const c=t.byModel[a]??(t.byModel[a]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});c.inputTokens+=o.inputTokens,c.outputTokens+=o.outputTokens,c.cacheReadTokens+=o.cacheReadTokens,c.cacheCreationTokens+=o.cacheCreationTokens,c.costUsd+=o.costUsd,o.estimated&&(c.estimated=!0)}Ie(t,n,s)}function Ee(t,s,n){const a={};for(const[c,r]of Object.entries(t.byModel??{}))a[c]={...r};const o={...t,projectDir:s,toolBreakdown:{...t.toolBreakdown??{}},byModel:a,byLauncher:{}};return Ie(o,n,t),o}function vt(t,s){const n={...jt},a=new Set,o=t.map(c=>{const r={};for(const[i,f]of Object.entries(c.byProject)){if(i.startsWith(xe)){const u=i.slice(xe.length),g=r[u];g?$e(g,f,"task"):r[u]=Ee(f,u,"task");continue}const l=s[i];if(!l){a.add(i),n.sessionCount+=f.sessionCount,n.promptCount+=f.promptCount,n.estimatedCostUsd+=f.estimatedCostUsd,n.totalTokens+=f.inputTokens+f.outputTokens;continue}const d=gt(i),m=r[l];m?$e(m,f,d):r[l]=Ee(f,l,d)}return{...c,byProject:r}});return n.folderCount=a.size,{days:o,excluded:n}}function bt(t){return t.folderCount>0}function kt(t){const s=[`${t.folderCount} transcript folder${t.folderCount===1?"":"s"} with no resolvable working directory`];return t.sessionCount&&s.push(`${t.sessionCount.toLocaleString()} sessions`),t.promptCount&&s.push(`${t.promptCount.toLocaleString()} prompts`),t.estimatedCostUsd>=.005&&s.push(`$${t.estimatedCostUsd.toFixed(2)}`),`Excluded: ${s.join(" · ")}`}async function ge(){return(await Je()).history??{}}let De=Promise.resolve();function he(t){const s=De.then(async()=>{const n=await ge();await et({history:{...n,...t}})});return De=s.catch(()=>{}),s}const yt=["in","out","total","prompts","sessions","time","spend"],Nt=[{value:30,label:"30d"},{value:60,label:"60d"},{value:90,label:"90d"},{value:0,label:"All time"}];function Pe({value:t,options:s,onChange:n}){return e.jsx("div",{className:"flex gap-0.5 p-0.5 rounded bg-bg-elev shadow-[inset_0_0_0_1px_rgba(0,0,0,0.06)] text-[11px]",children:s.map(a=>e.jsx("button",{onClick:()=>n(a.value),className:`px-2 py-1 rounded whitespace-nowrap font-mono ${t===a.value?"bg-bg-hi text-fg shadow-sm":"text-fg-faint hover:text-fg"}`,children:a.label},String(a.value)))})}function Tt({measure:t,onMeasure:s,range:n,onRange:a,projectsShown:o,projectsTotal:c,fromDate:r,toDate:i,onRefresh:f,onExport:l,exportDisabled:d}){return e.jsxs("div",{className:"sticky top-0 z-10 border-b border-line px-4 py-2.5 flex flex-wrap items-center gap-3 backdrop-blur-sm",style:{backgroundColor:"rgba(246,239,225,0.93)"},children:[e.jsx(Pe,{value:t,options:yt.map(m=>({value:m,label:Be[m]})),onChange:s}),e.jsx(Pe,{value:n,options:Nt,onChange:a}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[o," / ",c," projects"]}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[r," → ",i]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:f,className:"px-2 py-1 text-[11px] border border-line rounded hover:text-fg hover:bg-bg-hi text-fg-faint",title:"Re-fetch the rollup (no scan)",children:"↻ Refresh"}),e.jsx("button",{onClick:l,disabled:d,className:"px-2 py-1 text-[11px] border border-line rounded hover:text-fg hover:bg-bg-hi text-fg-faint disabled:opacity-40 disabled:pointer-events-none",children:"Export CSV"})]})}const C="rounded-card bg-bg-hi border border-line",Ct="#ded2bd",wt="#6f7d52";function w({kicker:t,title:s,right:n}){return e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wider text-accent font-mono",children:t}),e.jsx("h2",{className:"font-serif text-[25px] leading-tight tracking-tight text-fg",children:s})]}),n]})}function Q(t,s){switch(t){case"spend":return $(s);case"in":case"out":case"total":return I(s);case"time":return Oe(s);default:return B(s)}}function Rt({measure:t,headline:s,activeDays:n,projectsTouched:a,totalSessions:o}){const c=n>0?s.value/n:0,r=o>0?s.value/o:0,{delta:i}=s,f=i&&(t==="spend"?i.direction==="down":i.direction==="up"),l=i&&i.direction!=="flat"&&(t==="spend"?i.direction==="up":i.direction==="down"),d=f?"text-delta-good":l?"text-delta-bad":"text-fg-faint";return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"01 · overview",title:Be[t]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[52px] leading-none font-mono tracking-tight text-fg",children:Q(t,s.value)}),i?e.jsxs("div",{className:`text-xs font-mono mt-2 ${d}`,children:[i.direction==="up"?"▲":i.direction==="down"?"▼":"·"," ",_e(Math.abs(i.pct??0))," vs prior period"]}):e.jsx("div",{className:"text-xs text-fg-faint mt-2",children:"no prior window to compare"})]}),e.jsx("div",{className:"flex-1 min-w-0 self-stretch",children:e.jsx(St,{series:s.series})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-4 pt-3 border-t border-line",children:[e.jsx(Y,{label:"per active day",value:Q(t,c)}),e.jsx(Y,{label:"per session",value:Q(t,r)}),e.jsx(Y,{label:"active days",value:B(n)}),e.jsx(Y,{label:"projects touched",value:B(a)})]})]})}function Y({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider",children:t}),e.jsx("div",{className:"text-[17px] font-mono tracking-tight text-fg-dim",children:s})]})}function St({series:t}){if(t.length<2)return null;const a=Math.max(...t,0),o=Math.min(...t,0),c=a-o||1,r=160/(t.length-1),i=t.map((l,d)=>`${d*r},${48-(l-o)/c*48}`).join(" "),f=`0,48 ${i} 160,48`;return e.jsxs("svg",{viewBox:"0 0 160 48",preserveAspectRatio:"none",className:"w-full h-full min-h-[48px]",children:[e.jsx("polygon",{points:f,fill:"#b85c34",opacity:.15}),e.jsx("polyline",{points:i,fill:"none",stroke:"#b85c34",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})]})}const Mt=50;function $t({days:t}){const[s,n]=p.useState(Mt),a=p.useRef(!1);p.useEffect(()=>{let l=!1;return ge().then(d=>{l||a.current||typeof d.budgetCapUsd=="number"&&Number.isFinite(d.budgetCapUsd)&&d.budgetCapUsd>0&&n(d.budgetCapUsd)}),()=>{l=!0}},[]);const o=l=>{a.current=!0;const d=s;n(l),he({budgetCapUsd:l}).catch(()=>{n(d),X.error("Couldn't save the budget cap — reverted.")})},{mtdSpend:c,projectedSpend:r}=p.useMemo(()=>{const l=new Date,d=l.toLocaleDateString("en-CA").slice(0,7),m=new Date(l.getFullYear(),l.getMonth()+1,0).getDate(),u=l.getDate();let g=0;for(const y of t)if(y.date.startsWith(d))for(const v of Object.values(y.byProject))g+=v.estimatedCostUsd;return{mtdSpend:g,projectedSpend:lt(g,u,m)}},[t]),i=r>s,f=s>0?Math.min(100,c/s*100):0;return e.jsxs("div",{className:`${C} p-3`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-[10.5px] uppercase tracking-wider text-fg-faint font-mono",children:"Monthly budget"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-faint",children:["cap",e.jsx("span",{children:"$"}),e.jsx("input",{type:"number",min:1,step:1,value:s,onChange:l=>{const d=Number(l.target.value);Number.isFinite(d)&&d>0&&o(d)},className:"w-16 bg-bg border border-line rounded px-1.5 py-0.5 text-xs text-fg font-mono"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono mb-1.5",children:[e.jsxs("span",{className:"text-fg",children:[$(c)," ",e.jsx("span",{className:"text-fg-faint",children:"month-to-date"})]}),e.jsxs("span",{className:i?"text-delta-bad":"text-fg-dim",children:[$(r)," ",e.jsx("span",{className:"text-fg-faint",children:"projected"})]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:`h-full ${i?"bg-delta-bad":"bg-sage"}`,style:{width:`${Math.max(f,f>0?2:0)}%`}})}),e.jsx("div",{className:`text-[10px] mt-1 font-mono ${i?"text-delta-bad":"text-fg-faint"}`,children:i?`projected to exceed $${s.toFixed(0)} cap`:`${f.toFixed(0)}% of $${s.toFixed(0)} cap`})]})}function Et({chips:t,keep:s,onToggle:n,onIsolate:a,onShowAll:o}){const c=s===null;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("button",{onClick:o,className:`px-2 py-1 rounded text-[11px] font-mono border ${c?"bg-accent text-white border-accent":"border-line text-fg-faint hover:text-fg hover:bg-bg-hi"}`,children:["show all (",t.length,")"]}),t.map(r=>{const i=c||s.has(r.projectDir);return e.jsxs("button",{onClick:f=>f.shiftKey?a(r.projectDir):n(r.projectDir),title:r.projectDir,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-[11px] font-mono border ${i?"border-line text-fg-dim bg-bg-hi":"border-line text-fg-faint opacity-40 hover:opacity-70"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:D(r.projectDir)}}),H(r.projectDir)]},r.projectDir)})]})}function Dt(t,s){const n=new Map;for(const o of t)for(const[c,r]of Object.entries(o.values))n.set(c,(n.get(c)??0)+r);const a=Array.from(n.entries()).sort((o,c)=>c[1]-o[1]).map(([o])=>o);return t.map(o=>{const c=a.reduce((f,l)=>f+(o.values[l]??0),0);let r=0;const i=a.map(f=>{const l=o.values[f]??0;if(c<=0)return{projectDir:f,value:l,y0:0,y1:0};const d=s==="share"?l/c:l,m=r,u=r+d;return r=u,{projectDir:f,value:l,y0:m,y1:u}});return{date:o.date,bands:i,total:c}})}const le=720,de=220,ue=44,Pt=20;function Ut(t,s){return t==="spend"?$(s):I(s)}function At({days:t,measure:s,selected:n,onSelect:a}){const[o,c]=p.useState("absolute"),r=p.useMemo(()=>Dt(t,o),[t,o]),i=p.useMemo(()=>{if(o==="share")return 1;let x=0;for(const b of r)x=Math.max(x,b.total);return x||1},[r,o]),f=le-ue,l=de-Pt,d=r.length>1?f/(r.length-1):f,m=x=>ue+x*d,u=x=>l-x/i*l,g=Math.max(1,Math.ceil(r.length/8)),y=4,v=Array.from({length:y+1},(x,b)=>i/y*b);return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"02 · over time",title:"Trend by project",right:e.jsx("div",{className:"flex border border-line rounded overflow-hidden text-[10px] font-mono",children:["absolute","share"].map(x=>e.jsx("button",{onClick:()=>c(x),className:`px-2 py-0.5 ${o===x?"bg-accent text-white":"text-fg-faint hover:text-fg"}`,children:x},x))})}),e.jsxs("svg",{width:"100%",viewBox:`0 0 ${le} ${de}`,className:"overflow-visible",children:[v.map((x,b)=>e.jsxs("g",{children:[e.jsx("line",{x1:ue,x2:le,y1:u(x),y2:u(x),stroke:"currentColor",className:"text-line",strokeWidth:1}),e.jsx("text",{x:0,y:u(x)+3,fontSize:9,className:"fill-fg-faint",children:o==="share"?`${Math.round(x*100)}%`:Ut(s,x)})]},b)),r.map((x,b)=>{if(b===0)return null;const P=r[b-1];return x.bands.map((j,ee)=>{const q=P.bands[ee],W=n!==null&&n!==j.projectDir,te=W?Ct:D(j.projectDir),se=[`${m(b-1)},${u(q.y0)}`,`${m(b)},${u(j.y0)}`,`${m(b)},${u(j.y1)}`,`${m(b-1)},${u(q.y1)}`].join(" ");return e.jsx("polygon",{points:se,fill:te,opacity:W?.6:.75,className:"cursor-pointer",onClick:()=>a(n===j.projectDir?null:j.projectDir),children:e.jsx("title",{children:H(j.projectDir)})},`${j.projectDir}-${b}`)})}),r.map((x,b)=>b%g!==0&&b!==r.length-1?null:e.jsx("text",{x:m(b),y:de-4,fontSize:9,textAnchor:"middle",className:"fill-fg-faint",children:x.date.slice(5)},x.date))]})]})}function Lt({rows:t,measure:s,selected:n,onSelect:a}){return t.length?e.jsxs("div",{className:`${C} overflow-hidden`,children:[e.jsx("div",{className:"p-4 pb-0",children:e.jsx(w,{kicker:"03 · by project",title:"Ranking"})}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-bg-elev",children:e.jsx("tr",{children:["project","share","value","share %","trend","sessions","top tool"].map(o=>e.jsx("th",{className:"text-left px-3 py-2 text-fg-faint uppercase tracking-wider whitespace-nowrap",children:o},o))})}),e.jsx("tbody",{children:t.map(o=>{const c=D(o.projectDir),r=n===o.projectDir;return e.jsxs("tr",{onClick:()=>a(o.projectDir),className:`border-t border-line hover:bg-bg-elev cursor-pointer ${r?"bg-bg-elev":""}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono text-fg-dim",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:c}}),H(o.projectDir)]})}),e.jsx("td",{className:"px-3 py-2 w-32",children:e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(o.sharePct,o.sharePct>0?2:0)}%`,backgroundColor:c}})})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:Q(s,o.value)}),e.jsxs("td",{className:"px-3 py-2 text-fg-faint font-mono",children:[o.sharePct.toFixed(1),"%"]}),e.jsx("td",{className:"px-3 py-2 font-mono",children:o.trend.pct===null?e.jsx("span",{className:"text-fg-faint",children:"—"}):e.jsxs("span",{className:o.trend.direction==="up"?"text-delta-good":o.trend.direction==="down"?"text-delta-bad":"text-fg-faint",children:[o.trend.direction==="up"?"▲":o.trend.direction==="down"?"▼":"·"," ",_e(Math.abs(o.trend.pct))]})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:B(o.sessions)}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:o.topTool||"—"})]},o.projectDir)})})]})]}):e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"03 · by project",title:"Ranking"}),e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"})]})}function Ft({projectDir:t,totals:s,byModel:n,toolBreakdown:a,onClear:o}){var d;const c=E(s,"in"),r=E(s,"out"),i=Object.entries(n).sort((m,u)=>u[1].costUsd-m[1].costUsd),f=Object.entries(a).sort((m,u)=>u[1]-m[1]),l=((d=f[0])==null?void 0:d[1])??0;return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"04 · drill in",title:H(t),right:e.jsx("button",{onClick:o,className:"text-[11px] text-fg-faint hover:text-fg font-mono",children:"clear ✕"})}),e.jsx("div",{className:"flex items-center gap-1.5 -mt-2 mb-3",children:e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:D(t)}})}),e.jsxs("div",{className:"grid grid-cols-6 gap-3 mb-4",children:[e.jsx(O,{label:"prompts",value:B(s.promptCount)}),e.jsx(O,{label:"sessions",value:B(s.sessionCount)}),e.jsx(O,{label:"in tokens",value:I(c)}),e.jsx(O,{label:"out tokens",value:I(r)}),e.jsx(O,{label:"spend",value:$(s.estimatedCostUsd)}),e.jsx(O,{label:"time",value:Oe(s.activeMinutes)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"model mix"}),i.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data"}):e.jsx("div",{className:"space-y-1",children:i.map(([m,u])=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-fg-dim",children:[e.jsx("span",{children:me(m)}),e.jsx("span",{className:"text-fg-faint",children:$(u.costUsd)})]},m))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"tool mix"}),f.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no tool data"}):e.jsx("div",{className:"space-y-1",children:f.slice(0,6).map(([m,u])=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"w-20 shrink-0 truncate text-fg-dim font-mono",children:m}),e.jsx("div",{className:"flex-1 h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full bg-hive-teal",style:{width:`${l>0?u/l*100:0}%`}})}),e.jsx("span",{className:"text-fg-faint font-mono w-8 text-right",children:u})]},m))})]})]})]})}function O({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider",children:t}),e.jsx("div",{className:"text-[17px] font-mono tracking-tight text-fg",children:s})]})}function _t({byModelTotals:t}){const s=Object.entries(t).sort((a,o)=>o[1].costUsd-a[1].costUsd),n=s.reduce((a,[,o])=>a+o.costUsd,0);return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"05 · composition",title:"Model mix",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:[$(n)," total"]})}),s.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data in range"}):e.jsx("div",{className:"space-y-2",children:s.map(([a,o])=>{const c=n>0?o.costUsd/n*100:0,r=D(a);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-fg-dim truncate",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{backgroundColor:r}}),me(a),o.estimated&&e.jsx("span",{className:"text-fg-faint",children:"(est.)"})]}),e.jsxs("span",{className:"text-fg-faint whitespace-nowrap ml-2",children:[$(o.costUsd)," · ",c.toFixed(0),"%"]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(c,c>0?2:0)}%`,backgroundColor:r}})})]},a)})})]})}const Ot={epic:"Epic sessions",job:"Scheduler jobs",task:"Tasks",other:"Other sessions"};function Ht({byLauncherTotals:t}){const s=mt.map(a=>{var o;return[a,((o=t[a])==null?void 0:o.costUsd)??0]}),n=s.reduce((a,[,o])=>a+o,0);return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"05 · composition",title:"Launcher mix",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:[$(n)," total"]})}),n<=0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no usage in range"}):e.jsx("div",{className:"space-y-2",children:s.map(([a,o])=>{const c=o/n*100,r=D(a);return e.jsxs("div",{"data-testid":`history-launcher-${a}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-fg-dim truncate",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{backgroundColor:r}}),Ot[a]]}),e.jsxs("span",{className:"text-fg-faint whitespace-nowrap ml-2",children:[$(o)," · ",c.toFixed(0),"%"]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(c,c>0?2:0)}%`,backgroundColor:r}})})]},a)})})]})}function Bt({rows:t}){const s=t.slice(0,3),n=s.reduce((c,r)=>c+r.sharePct,0),a=t.slice(3),o=a.reduce((c,r)=>c+r.sharePct,0);return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"05 · composition",title:"Concentration",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["top 3 = ",n.toFixed(0),"%"]})}),t.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-3 rounded overflow-hidden mb-2",children:t.map(c=>e.jsx("div",{style:{width:`${Math.max(c.sharePct,.5)}%`,backgroundColor:D(c.projectDir)},title:`${H(c.projectDir)} · ${c.sharePct.toFixed(1)}%`},c.projectDir))}),e.jsx("div",{className:"space-y-1 mb-2",children:s.map(c=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim truncate",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:D(c.projectDir)}}),H(c.projectDir)]}),e.jsxs("span",{className:"text-fg-faint",children:[c.sharePct.toFixed(1),"%"]})]},c.projectDir))}),a.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-faint",children:[a.length," more project",a.length===1?"":"s"," account for ",o.toFixed(1),"% (long tail)."]})]})]})}const Z=30,pe=9,A=(Z+pe)*2;function It({totals:t}){const s=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,n=s>0?t.cacheReadTokens/s*100:0,a=2*Math.PI*Z,o=A/2;return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"05 · composition",title:"Cache"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative shrink-0",style:{width:A,height:A},children:[e.jsxs("svg",{width:A,height:A,viewBox:`0 0 ${A} ${A}`,className:"-rotate-90",children:[e.jsx("circle",{cx:o,cy:o,r:Z,fill:"none",stroke:"currentColor",className:"text-bg-hi",strokeWidth:pe}),e.jsx("circle",{cx:o,cy:o,r:Z,fill:"none",stroke:wt,strokeWidth:pe,strokeDasharray:a,strokeDashoffset:a*(1-n/100),strokeLinecap:"round"})]}),e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-[13px] font-mono text-fg",children:[n.toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-[11px] space-y-1 font-mono",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-fg-faint",children:"reused (cache read)"}),e.jsx("span",{className:"text-fg-dim",children:I(t.cacheReadTokens)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-fg-faint",children:"written to cache"}),e.jsx("span",{className:"text-fg-dim",children:I(t.cacheCreationTokens)})]})]})]})]})}const Wt=.05,qt="—",Ue=t=>`$${t.toFixed(2)}`;function Kt(){const[t,s]=p.useState(null),[n,a]=p.useState(null),o=Fe(r=>r.show);p.useEffect(()=>{let r=!0;const i=()=>{window.api.history.loopEfficiency().then(l=>{r&&(s(l),a(null))}).catch(l=>{if(!r)return;const d=l instanceof Error?l.message:String(l);a(d),o("error",`Loop efficiency failed to load: ${d}`)})};i();const f=window.api.history.onUpdated(i);return()=>{r=!1,f()}},[o]);let c;if(n&&!t)c=e.jsxs("div",{"data-testid":"loop-eff-error",className:"text-[11px] font-mono text-fg-faint",children:["Failed to load: ",n]});else if(!t)c=e.jsx("div",{"data-testid":"loop-eff-loading",className:"text-[11px] font-mono text-fg-faint",children:"Loading…"});else if(t.rows.length===0)c=e.jsx("div",{"data-testid":"loop-eff-empty",className:"text-[11px] font-mono text-fg-faint",children:"No runs this week."});else{const r=t.totals.wastedRunRate>Wt;c=e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-[11px] font-mono","data-testid":"loop-eff-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-fg-faint text-left",children:[e.jsx("th",{className:"font-normal",children:"Project"}),e.jsx("th",{className:"font-normal text-right",children:"Runs"}),e.jsx("th",{className:"font-normal text-right",children:"Wasted"}),e.jsx("th",{className:"font-normal text-right",children:"Verified"}),e.jsx("th",{className:"font-normal text-right",children:"Refuted"}),e.jsx("th",{className:"font-normal text-right",children:"List-price $"}),e.jsx("th",{className:"font-normal text-right",children:"$ / verified"})]})}),e.jsx("tbody",{className:"text-fg-dim",children:t.rows.map(i=>e.jsxs("tr",{"data-testid":"loop-eff-row",children:[e.jsx("td",{children:i.project}),e.jsx("td",{className:"text-right",children:i.runs}),e.jsx("td",{className:"text-right",children:i.wastedRuns}),e.jsx("td",{className:"text-right",children:i.verified}),e.jsx("td",{className:"text-right",children:i.refuted}),e.jsx("td",{className:"text-right",children:Ue(i.executorUsd)}),e.jsx("td",{className:"text-right","data-testid":"loop-eff-per-verified",children:i.usdPerVerified==null?qt:Ue(i.usdPerVerified)})]},i.cwd))})]}),e.jsxs("div",{"data-testid":"loop-eff-totals","data-warning":r?"true":"false",className:`mt-2 text-[11px] font-mono ${r?"text-amber-300":"text-fg-dim"}`,children:["wasted runs ",(t.totals.wastedRunRate*100).toFixed(1),"% (",t.totals.wastedRuns,"/",t.totals.runs,") · target ≤ 5%"]}),e.jsx("div",{"data-testid":"loop-eff-usage",className:"mt-1 text-[11px] font-mono text-fg-faint",children:t.verifiedPerUsagePct!=null?`${t.verifiedPerUsagePct} verified PRDs per 1% of weekly usage`:"weekly usage unavailable"})]})}return e.jsxs("div",{className:`${C} p-4`,"data-testid":"loop-efficiency",children:[e.jsx(w,{kicker:"06 · reliability",title:"Loop efficiency"}),c]})}const J="—",Vt=Object.freeze({"not-landed":"nothing or the wrong thing was committed","gate-red":"a gate command fails","behavior-wrong":"runs but does not do what a criterion says","not-checked-live":"passes tests, wrong against real data or the real UI","missing-test":"a criterion or change has no test that checks it",regression:"breaks something that worked","spec-gap":"every criterion met but the goal is not",security:"introduces a security problem","docs-drift":"docs no longer match the code",other:"none of the above"}),Gt="Proposed for a human to approve: add it to standards.md or the validator persona through /develop.",Ae=t=>t==null?J:`${t}%`;function zt(t,s){switch(s){case"firstPass":return Ae(t.firstPass.pct);case"refuted":return Ae(t.refuted.pct);case"fixWaves":return t.fixWaves.perPlan==null?J:String(t.fixWaves.perPlan);case"escapes":return String(t.escapes.length)}}function Yt(t,s){switch(s){case"firstPass":return t.firstPass.prds;case"refuted":return t.refuted.prds;case"fixWaves":return t.fixWaves.plans.filter(n=>n.fixWaves.length>0).map(n=>`${n.plan}: ${n.fixWaves.join(", ")}`);case"escapes":return t.escapes.map(n=>`${n.fixPrd} fixes ${n.escapedPrd} — ${n.reason??J}`)}}const fe=[{key:"firstPass",label:"First-pass verified"},{key:"refuted",label:"Refuted"},{key:"fixWaves",label:"Fix waves / plan"},{key:"escapes",label:"Escapes"}];function Xt(){var f;const[t,s]=p.useState(null),[n,a]=p.useState(null),[o,c]=p.useState(null),r=Fe(l=>l.show);p.useEffect(()=>{let l=!0;const d=g=>{l&&(a(g),r("error",`Validation quality failed to load: ${g}`))},m=()=>{window.api.history.validationQuality().then(g=>{if(l){if(!g.ok)return d(g.error);s(g.projects),a(null)}}).catch(g=>d(g instanceof Error?g.message:String(g)))};m();const u=window.api.history.onUpdated(m);return()=>{l=!1,u()}},[r]);let i;if(n&&!t)i=e.jsxs("div",{"data-testid":"val-q-error",className:"text-[11px] font-mono text-fg-faint",children:["Failed to load: ",n]});else if(!t)i=e.jsx("div",{"data-testid":"val-q-loading",className:"text-[11px] font-mono text-fg-faint",children:"Loading…"});else if(t.length===0)i=e.jsx("div",{"data-testid":"val-q-empty",className:"text-[11px] font-mono text-fg-faint",children:"No validated PRDs yet."});else{const l=o?t.find(u=>u.cwd===o.cwd):void 0,d=o&&l?Yt(l,o.metric):null,m=t.filter(u=>u.week.topMiss||u.week.unclassified.count>0);i=e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-[11px] font-mono","data-testid":"val-q-table",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-fg-faint text-left",children:[e.jsx("th",{className:"font-normal",children:"Project"}),fe.map(u=>e.jsx("th",{className:"font-normal text-right",children:u.label},u.key))]})}),e.jsx("tbody",{className:"text-fg-dim",children:t.map(u=>e.jsxs("tr",{"data-testid":"val-q-row",children:[e.jsx("td",{children:u.project}),fe.map(g=>{const y=(o==null?void 0:o.cwd)===u.cwd&&o.metric===g.key;return e.jsx("td",{className:"text-right",children:e.jsx("button",{type:"button","data-testid":`val-q-${g.key}`,"aria-expanded":y,className:"underline decoration-dotted hover:text-fg",onClick:()=>c(y?null:{cwd:u.cwd,metric:g.key}),children:zt(u,g.key)})},g.key)})]},u.cwd))})]}),o&&l&&d&&e.jsxs("div",{"data-testid":"val-q-detail",className:"mt-2 text-[11px] font-mono text-fg-dim",children:[e.jsxs("div",{className:"text-fg-faint",children:[l.project," · ",(f=fe.find(u=>u.key===o.metric))==null?void 0:f.label]}),d.length===0?e.jsx("div",{className:"text-fg-faint",children:"No PRDs."}):e.jsx("ul",{children:d.map(u=>e.jsx("li",{"data-testid":"val-q-detail-item",children:u},u))})]}),e.jsxs("div",{"data-testid":"val-q-week",className:"mt-3 text-[11px] font-mono text-fg-dim",children:[e.jsx("div",{className:"text-fg-faint",children:"This week"}),m.length===0?e.jsx("div",{"data-testid":"val-q-week-empty",children:"No validator misses this week."}):m.map(u=>{const g=u.week.topMiss,y=u.week.unclassified;return e.jsxs("div",{children:[g&&e.jsxs("div",{"data-testid":"val-q-top-miss",className:"mt-1",children:[e.jsxs("div",{children:[u.project,": ",e.jsx("span",{className:"text-fg",children:g.missKind})," — ",Vt[g.missKind]??J," ·"," ",g.count,"×"]}),e.jsxs("div",{children:["PRDs: ",g.prds.join(", ")]}),g.reasons.length>0&&e.jsx("ul",{className:"list-disc pl-4",children:g.reasons.slice(0,5).map(v=>e.jsx("li",{"data-testid":"val-q-reason",children:v},v))}),e.jsxs("div",{"data-testid":"val-q-proposal",children:["Proposed check: ",g.proposal]}),e.jsx("div",{className:"text-fg-faint",children:Gt})]}),y.count>0&&e.jsxs("div",{"data-testid":"val-q-unclassified",className:"mt-1",children:[e.jsxs("div",{children:[u.project,": Not classified (recorded before checked verdicts): ",y.count]}),e.jsxs("div",{children:["PRDs: ",y.prds.join(", ")]}),y.reasons.length>0&&e.jsx("ul",{className:"list-disc pl-4",children:y.reasons.slice(0,5).map(v=>e.jsx("li",{"data-testid":"val-q-unclassified-reason",children:v},v))})]})]},u.cwd)})]})]})}return e.jsxs("div",{className:`${C} p-4`,"data-testid":"validation-quality",children:[e.jsx(w,{kicker:"07 · reliability",title:"Validation quality"}),i]})}const Qt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Zt({days:t,measure:s}){const{buckets:n,weekendShare:a,peakIdx:o}=p.useMemo(()=>{const r=new Array(7).fill(0);for(const d of t){const[m,u,g]=d.date.split("-").map(Number),y=new Date(m,u-1,g).getDay();r[y]+=E(d.totals,s)}const i=r.reduce((d,m)=>d+m,0),f=r[0]+r[6];let l=0;for(let d=1;d<7;d++)r[d]>r[l]&&(l=d);return{buckets:r,weekendShare:i>0?f/i*100:0,peakIdx:l}},[t,s]),c=Math.max(...n,1);return e.jsxs("div",{className:`${C} p-4`,children:[e.jsx(w,{kicker:"05 · composition",title:"Rhythm",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["weekend ",a.toFixed(0),"%"]})}),e.jsx("div",{className:"flex items-end gap-2 h-24",children:n.map((r,i)=>e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end gap-1 h-full",children:[e.jsx("div",{className:`w-full rounded-t ${i===o?"bg-accent":"bg-rhythm"}`,style:{height:`${c>0?r/c*100:0}%`,minHeight:r>0?2:0}}),e.jsx("span",{className:"text-[9px] text-fg-faint font-mono",children:Qt[i]})]},i))})]})}const Jt=["in","out","total","prompts","sessions","time","spend"],es=[30,60,90,0],ts="spend",ss=30,ns=3e4,os=[];function as(){var Te;const[t,s]=p.useState(ts),[n,a]=p.useState(ss),o=p.useRef(!1),c=p.useRef(!1),r=h=>{o.current=!0;const k=t;s(h),he({measure:h}).catch(()=>{s(k),X.error("Couldn't save the measure preference — reverted.")})},i=h=>{c.current=!0;const k=n;a(h),he({range:h}).catch(()=>{a(k),X.error("Couldn't save the range preference — reverted.")})};p.useEffect(()=>{let h=!1;return ge().then(k=>{h||(!o.current&&k.measure&&Jt.includes(k.measure)&&s(k.measure),!c.current&&k.range!==void 0&&es.includes(k.range)&&a(k.range))}),()=>{h=!0}},[]);const f=tt(h=>h.navFace),l=Ce(h=>h.tabs),d=Ce(h=>h.activeTabId),m=((Te=l.find(h=>h.id===d))==null?void 0:Te.cwd)??null,u=p.useRef(f),g=m?st(m):null,[y,v]=p.useState(null),x=p.useMemo(()=>f==="project"&&g?new Set([g]):y,[f,g,y]),[b,P]=p.useState(null),[j,ee]=p.useState(null),[q,W]=p.useState(!0),[te,se]=p.useState(0),ne=p.useRef(n);ne.current=n;const K=p.useRef(!0),oe=p.useRef(0),je=p.useRef(0),L=p.useRef(null),V=p.useCallback(h=>{const k=ne.current;oe.current+=1,je.current=Date.now(),rt(k).then(N=>{if(oe.current-=1,!(!K.current||k!==ne.current)){if(W(!1),N.ok){ee(N.data);return}h||X.error(`History analytics failed to load: ${N.error}`)}})},[]);p.useEffect(()=>{K.current=!0,W(!0),V(!1)},[n,te,V]),p.useEffect(()=>{const h=()=>{if(!K.current)return;const R=je.current+ns-Date.now();if(oe.current===0&&R<=0){V(!0);return}L.current||(L.current=setTimeout(()=>{L.current=null,h()},Math.max(R,1e3)))},k=()=>{document.visibilityState==="visible"&&h()},N=window.api.history.onUpdated(h);return window.addEventListener("focus",h),document.addEventListener("visibilitychange",k),()=>{K.current=!1,N(),window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",k),L.current&&(clearTimeout(L.current),L.current=null)}},[V]);const ve=p.useRef(!1);p.useEffect(()=>{if(!ve.current){ve.current=!0;return}v(null),P(null)},[n]),p.useEffect(()=>{u.current!==f&&(u.current=f,f==="home"&&v(null))},[f]);const{projects:be,resolving:ke}=nt(),ye=p.useMemo(()=>{const h={};for(const k of be)for(const N of k.encodedIds)h[N]=k.cwd;return h},[be]),F=p.useMemo(()=>j&&!ke?vt(j.days,ye):null,[j,ye,ke]),S=(F==null?void 0:F.days)??(j==null?void 0:j.days)??os,ae=(F==null?void 0:F.excluded)??null,M=p.useMemo(()=>j?it({days:S,totals:j.totals,prevTotals:j.prevTotals},x):null,[j,S,x]),_=p.useMemo(()=>x===null?S:S.map(h=>({date:h.date,byProject:Object.fromEntries(Object.entries(h.byProject).filter(([k])=>x.has(k)))})),[S,x]),G=p.useMemo(()=>Se(S,t),[S,t]),re=p.useMemo(()=>Se(_,t),[_,t]),We=p.useMemo(()=>_.map(h=>({date:h.date,values:Object.fromEntries(Object.entries(h.byProject).map(([k,N])=>[k,E(N,t)]))})),[_,t]),Ne=p.useMemo(()=>M?ft(M,t):null,[M,t]),z=p.useMemo(()=>{if(!j||!b)return null;const h=S.flatMap(T=>T.byProject[b]?[T.byProject[b]]:[]),{byModel:k,...N}=Re(h),R={};for(const T of h)for(const[U,ce]of Object.entries(T.toolBreakdown))R[U]=(R[U]??0)+ce;return{totals:N,byModel:k,toolBreakdown:R}},[j,S,b]);p.useEffect(()=>{b&&x!==null&&!x.has(b)&&P(null)},[b,x]);function qe(h){v(k=>{const N=new Set(G.map(U=>U.projectDir)),R=k??new Set(N),T=new Set(R);return T.has(h)?T.delete(h):T.add(h),T.size>=N.size?null:T})}function Ke(h){v(new Set([h]))}function Ve(){v(null)}function Ge(){if(!j)return;const h=_.map(U=>{const{byModel:ce,estimatedCostUsd:ze,inputTokens:Ye,outputTokens:Xe,cacheCreationTokens:Qe,cacheReadTokens:Ze}=Re(Object.values(U.byProject));return{date:U.date,costUsd:ze,inputTokens:Ye,outputTokens:Xe,cacheCreationTokens:Qe,cacheReadTokens:Ze,byModel:ce}}),k=pt(h),N=new Blob([k],{type:"text/csv"}),R=URL.createObjectURL(N),T=document.createElement("a");T.href=R,T.download=`usage-history-${j.from}-${j.to}.csv`,T.click(),URL.revokeObjectURL(R)}return q&&!j?e.jsx(Le,{}):j&&j.days.length===0?e.jsx(ot,{title:"no sessions in range",hint:"Widen the range or check back after your next session."}):!j||!M||!Ne?e.jsx(Le,{}):e.jsxs("div",{"data-testid":"history-dashboard",className:"flex flex-col h-full",children:[e.jsxs("h1",{className:"font-serif text-[42px] leading-tight tracking-tight text-fg px-4 pt-4",children:["Where your ",e.jsx("em",{className:"italic text-accent",children:"Claude time"})," goes"]}),e.jsx(Tt,{measure:t,onMeasure:r,range:n,onRange:i,projectsShown:x===null?G.length:x.size,projectsTotal:G.length,fromDate:j.from,toDate:j.to,onRefresh:()=>se(h=>h+1),onExport:Ge,exportDisabled:_.length===0}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-4 space-y-4",children:[e.jsx(Rt,{measure:t,headline:Ne,activeDays:M.activeDays,projectsTouched:re.length,totalSessions:M.totals.sessionCount}),e.jsx($t,{days:S}),ae&&bt(ae)&&e.jsx("div",{"data-testid":"history-excluded-note",className:"rounded-[10px] border border-line bg-bg-hi px-3 py-2 text-[11.5px] font-mono text-fg-faint",title:"A project is a working directory. ~/.claude/projects holds one folder per path the CLI was ever launched from — throwaway /tmp dirs and test fixtures included — and a folder whose cwd can't be recovered from its transcripts is not a project. Their totals are stated here rather than silently folded into the charts.",children:kt(ae)}),j.legacyDates&&j.legacyDates.length>0&&e.jsx("div",{"data-testid":"history-legacy-note",className:"rounded-[10px] border border-line bg-bg-hi px-3 py-2 text-[11.5px] font-mono text-fg-faint",children:rs(j.legacyDates)}),f==="home"&&e.jsx(Et,{chips:G.map(h=>({projectDir:h.projectDir,value:h.value})),keep:x,onToggle:qe,onIsolate:Ke,onShowAll:Ve}),e.jsx(At,{days:We,measure:t,selected:b,onSelect:P}),e.jsx(Lt,{rows:re,measure:t,selected:b,onSelect:P}),b&&z&&e.jsx(Ft,{projectDir:b,totals:z.totals,byModel:z.byModel,toolBreakdown:z.toolBreakdown,onClear:()=>P(null)}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(_t,{byModelTotals:M.byModelTotals}),e.jsx(Ht,{byLauncherTotals:M.byLauncherTotals}),e.jsx(Bt,{rows:re}),e.jsx(It,{totals:M.totals}),e.jsx(Zt,{days:M.days,measure:t})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(Kt,{}),e.jsx(Xt,{})]})]})]})}function rs(t){const s=t.reduce((a,o)=>o>a?o:a),n=t.length;return`${n} ${n===1?"day":"days"} in this range (last: ${s}) were counted with the older method and read about two to three times too high; they cannot be recounted because their transcripts are gone.`}function Le(){return e.jsxs("div",{className:"p-4 space-y-4 animate-pulse",children:[e.jsx("div",{className:"h-24 bg-bg-elev rounded"}),e.jsx("div",{className:"h-16 bg-bg-elev rounded"}),e.jsx("div",{className:"h-8 bg-bg-elev rounded"}),e.jsx("div",{className:"h-56 bg-bg-elev rounded"}),e.jsx("div",{className:"h-40 bg-bg-elev rounded"})]})}function cs(){return e.jsx(at,{children:e.jsx(as,{})})}const fs=p.memo(cs);export{fs as History};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-CxAuwhNN.js","./index-CtxruO1L.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-DKXdXfka.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bl as oe,aR as r,bg as ae,aC as et,C as tt,aB as e,m as Y,F as nt,P as st,ai as at,a9 as Be,aZ as Ne,ag as lt,ba as H,by as ot,bn as ye,a0 as se,bd as Se,b9 as Ee,aa as it,aG as Q,bo as ue,bc as Ue,ae as me,M as He,E as Ge,A as rt,c as We,e as we,bw as ct,aH as dt,aO as ut,b7 as ft,az as Pe,H as mt,L as pt,r as gt,p as xt}from"./index-CtxruO1L.js";import{C as ht,I as bt,p as vt,L as Ve,t as jt,z as yt,A as wt,B as kt,u as Ct,y as Te,c as Ke,b as pe,g as Nt,s as St,r as Et,H as le,d as Je,f as ze,e as ke,i as Ce,F as $t,x as Lt,D as Mt,J as Pt,E as Tt,w as At,G as Dt,m as Rt,a as It,h as Ot,S as Ft,j as _t,k as Bt,l as Ut,M as Ht,P as Gt,n as Wt,o as Vt,v as Kt}from"./Skills-DtRzghn5.js";import{s as Jt,S as zt}from"./ViewTabs-B7qLXRAH.js";import{_ as qt}from"./monaco-editor-BsIlgG7c.js";import{P as Yt}from"./Panel-CALyU0pe.js";import"./TiptapBody-DApeu7x8.js";const Xt={skills:null,mcp:null,plugins:null},Zt={fileId:"claudeJson",scope:"user"};function Qt(t){return{skillsDir:`${t}/.claude/skills`,commandsDir:`${t}/.claude/commands`,claudeJson:`${t}/.claude.json`,pluginsManifest:`${t}/.claude/plugins/installed_plugins.json`}}async function en(t,n){const[s,l]=await Promise.all([et(t),window.api.config.listDir(n,{filesOnly:!0})]),o=s.errors[0];if(o)throw new Error(`${o.path}: ${o.error}`);if(!l.ok)throw new Error(`${n}: ${l.error??"failed to list directory"}`);return s.entries.length+l.entries.filter(i=>i.name.endsWith(".md")).length}async function tn(){const{data:t}=await window.api.claudeConfig.read(Zt),n=t==null?void 0:t.mcpServers;return n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n).length:0}async function nn(){return(await window.api.plugins.list()).length}function sn(){const t=oe(),[n,s]=r.useState(Xt),l=r.useRef({skills:0,mcp:0,plugins:0}),o=r.useCallback((f,x)=>{const u=l.current,y=++u[f],h=w=>{u[f]===y&&s(S=>S[f]===w?S:{...S,[f]:w})};x().then(h,()=>h(null))},[]),i=r.useMemo(()=>t?Qt(t):null,[t]),a=r.useCallback(()=>{i&&o("skills",()=>en(i.skillsDir,i.commandsDir))},[i,o]),m=r.useCallback(()=>o("mcp",tn),[o]),g=r.useCallback(()=>o("plugins",nn),[o]);return r.useEffect(()=>{const f=l.current;return a(),()=>{f.skills++}},[a]),r.useEffect(()=>{const f=l.current;return m(),g(),()=>{f.mcp++,f.plugins++}},[m,g]),ae(i?[i.skillsDir,i.commandsDir]:[],a),ae(i?[i.claudeJson]:[],m),ae(i?[i.pluginsManifest]:[],g),n}const an="User · every project on this machine",ln={title:"Nothing tells Claude how you like to work yet.",body:"Claude loads this file into every session it starts on this machine, in every project."};function on(){const t=oe(),n=r.useMemo(()=>t?tt.resolve("user",t,null):null,[t]),s=r.useMemo(()=>n?[{path:n,label:an,eyebrow:"YOUR INSTRUCTIONS FOR EVERY PROJECT"}]:[],[n]);return!t||!n?e.jsx(Y,{title:"loading…"}):e.jsx("div",{className:"flex flex-col h-full min-h-0","data-testid":"system-prompt",children:e.jsx(ht,{home:t,scope:"user",roots:s,activeRoot:n,empty:ln,testIdPrefix:"system-prompt",moreMenu:({importSelected:l})=>e.jsx(bt,{path:n,disabled:l})})})}const rn=r.memo(on);function cn({value:t,onChange:n,path:s,readOnly:l,theme:o="dark"}){const i=o==="paper";return e.jsx(nt,{path:`file://${s}`,defaultLanguage:"markdown",value:t,onChange:a=>n(a??""),beforeMount:i?at:void 0,theme:i?st:"vs-dark",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,wordWrap:"on",readOnly:l,automaticLayout:!0}})}const dn=r.lazy(()=>qt(()=>import("./SkillReferenceGraph-CxAuwhNN.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function un({pluginName:t,skills:n,onBack:s,initialSelectedId:l}){var x;const[o,i]=r.useState(l??((x=n[0])==null?void 0:x.id)??null),a=o?n.find(u=>u.id===o)??null:null,m=r.useMemo(()=>vt(n),[n]),[g,f]=r.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:s,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(a==null?void 0:a.name)??(a==null?void 0:a.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>f("list"),className:`px-2 py-0.5 text-xs ${g==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>f("graph"),className:`px-2 py-0.5 text-xs ${g==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[a!=null&&a.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:a.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",m.length," ",m.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(Y,{title:"no skills in this plugin"}):g==="graph"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(dn,{skills:n,edges:m,selectedId:o,onSelect:i})}):e.jsx(Ve,{sidebar:e.jsx("div",{className:"py-1",children:n.map(u=>e.jsxs("button",{onClick:()=>i(u.id),className:`w-full px-3 py-1 text-xs text-left ${o===u.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:u.name??u.id}),u.description?e.jsx("div",{className:"truncate text-fg-faint",children:u.description}):null]},u.id))}),detail:a?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(cn,{path:a.path,value:a.body,onChange:()=>{},readOnly:!0})}):e.jsx(Y,{title:"select a skill"})})})]})}function fn({row:t,busy:n,onUninstall:s}){const[l,o]=r.useState(!1),[i,a]=r.useState(!1),m=r.useRef(null),g=r.useId(),f=r.useCallback(()=>{o(!1),a(!1)},[]);r.useEffect(()=>{if(!l)return;const w=P=>{var E;(E=m.current)!=null&&E.contains(P.target)||f()},S=P=>{P.key==="Escape"&&f()};return window.addEventListener("mousedown",w),window.addEventListener("keydown",S),()=>{window.removeEventListener("mousedown",w),window.removeEventListener("keydown",S)}},[l,f]);const x=()=>{f(),Ne(t.path)},u=async()=>{f(),await lt(t.path)||H.error(`Could not copy ${t.path} to the clipboard`)},y=()=>{f(),s(t)},h="px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev";return e.jsxs("div",{ref:m,className:"relative self-start",children:[e.jsx("button",{type:"button","data-testid":"plugin-menu","aria-label":`Actions for ${t.name}`,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?g:void 0,onClick:()=>l?f():o(!0),className:"w-[30px] h-7 inline-flex items-center justify-center bg-bg border border-line rounded-md text-fg-dim hover:border-rule",children:e.jsxs("svg",{"aria-hidden":"true",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}),l&&e.jsx("div",{id:g,role:"menu","aria-label":`Actions for ${t.name}`,className:`absolute ${Be.dialog} right-0 top-[34px] w-[210px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[12.5px] text-fg`,children:i?e.jsxs("div",{className:"flex flex-col gap-2 px-2.5 py-[7px]",children:[e.jsxs("span",{className:"font-medium",children:["Uninstall ",t.name,"?"]}),e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx("button",{type:"button",role:"menuitem","data-testid":"plugin-uninstall",disabled:n,onClick:y,className:"h-6 px-2.5 rounded-[5px] bg-delta-bad text-bg-hi font-medium hover:bg-delta-bad/90 disabled:opacity-40",children:"Confirm"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(!1),className:"h-6 px-2.5 rounded-[5px] border border-line text-fg-dim hover:bg-bg-elev",children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",role:"menuitem",onClick:x,className:h,children:"Reveal in File Explorer"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>void u(),className:h,children:"Copy path"}),e.jsx("div",{role:"separator",className:"h-px mx-1.5 my-1 bg-line"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:!t.marketplace||n,title:t.marketplace?void 0:"No marketplace is recorded for this install",onClick:()=>a(!0),className:`${h} font-medium text-delta-bad hover:bg-delta-bad/10 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent`,children:["Uninstall ",t.name]})]})})]})}function qe({name:t,enabled:n,disabled:s,onToggle:l,testId:o="plugin-enabled-switch"}){return e.jsx("button",{type:"button",role:"switch","aria-checked":n,"aria-label":`${n?"Disable":"Enable"} ${t}`,"data-testid":o,disabled:s,onClick:i=>{i.stopPropagation(),l()},onKeyDown:i=>i.stopPropagation(),className:`relative shrink-0 w-[30px] h-[18px] rounded-full transition-colors align-middle disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent ${n?"bg-accent":"bg-rule"}`,children:e.jsx("span",{"aria-hidden":"true",className:`absolute top-0.5 w-3.5 h-3.5 rounded-full bg-bg-hi shadow transition-[left] ${n?"left-[14px]":"left-0.5"}`})})}const mn="Saved — matches settings.json › enabledPlugins",pn=250,gn=["hooks/hooks.json",".mcp.json","agents","skills","commands",".claude-plugin/plugin.json"],xn=(t,n,s)=>`${t} ${t===1?n:s}`;function hn(t){var s;const n=["PLUGIN"];return t.marketplace&&n.push(t.marketplace.toUpperCase()),(s=t.manifest)!=null&&s.version&&n.push(`V${t.manifest.version.toUpperCase()}`),n.push(`${(t.scope??"user").toUpperCase()} SCOPE`),n.join(" · ")}function bn(t,n){const s=i=>{const m=i.trim().replace(/^v/i,"").split(/[-+]/)[0].split(".");return m.every(g=>/^\d+$/.test(g))?m.map(Number):null},l=s(t),o=s(n);if(!l||!o)return null;for(let i=0;i<Math.max(l.length,o.length);i++){const a=(l[i]??0)-(o[i]??0);if(a!==0)return Math.sign(a)}return 0}function vn(t,n){if(!t||!n)return null;const s=bn(n,t);return s===null?n.trim()===t.trim()?"up-to-date":"update-available":s>0?"update-available":"up-to-date"}const jn=t=>t.key&&t.key.includes("@")?t.key.slice(0,t.key.lastIndexOf("@")):t.name,de=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function Ae(t,n){if(!de(t))return[];const s=de(t.hooks)?t.hooks:t,l=[];for(const[o,i]of Object.entries(s))Array.isArray(i)&&i.forEach((a,m)=>{if(!de(a)||!Array.isArray(a.hooks))return;const g=typeof a.matcher=="string"&&a.matcher?` · ${a.matcher}`:"";a.hooks.forEach((f,x)=>{const u=de(f)?typeof f.command=="string"?f.command:typeof f.prompt=="string"?f.prompt:null:null;l.push({id:`${n}:${o}:${m}:${x}`,name:`${o}${g}`,description:u})})});return l}async function yn(t,n){const s=n==null?void 0:n.hooks,l=typeof s=="string"?[s]:Array.isArray(s)?s.filter(a=>typeof a=="string"):[],o=new Set;for(const a of l)a.startsWith("/")||a.split("/").includes("..")||o.add(`${t}/${a.replace(/^\.\//,"")}`);o.add(`${t}/hooks/hooks.json`);const i=await Promise.all([...o].map(async a=>{const m=await window.api.config.readJson(a);return{p:a,data:m.exists&&!m.parseError?m.data:null}}));return[...de(s)?Ae(s,"manifest"):[],...i.flatMap(({p:a,data:m})=>Ae(m,a))]}function wn({row:t,home:n,busy:s,onToggle:l,onUninstall:o,onJump:i}){var Z,p,W;const[a,m]=r.useState([]),[g,f]=r.useState([]),[x,u]=r.useState(null),[y,h]=r.useState(!0),[w,S]=r.useState([]),P=r.useRef(0),[E,O]=r.useState(null),A=t.marketplace,j=jn(t);r.useEffect(()=>{if(O(null),!n||!A)return;let c=!0;return jt(n,{quiet:!0}).then(b=>{if(!c)return;const R=b.find(U=>U.marketplace===A&&U.name===j);O((R==null?void 0:R.version)??null)}),()=>{c=!1}},[n,A,j]);const D=r.useCallback(async()=>{const c=++P.current;try{const{manifest:b}=await yt(t.path),[R,U,ee]=await Promise.all([wt(t.path),kt(t.path,b),yn(t.path,b)]),te=R?await Ct(R):[],[B,ne]=await Promise.all([Te(U.agentFiles),Te(U.commandFiles)]),d=await Promise.all([...new Set([...gn.map(v=>`${t.path}/${v}`),...U.sourcePaths])].map(async v=>await window.api.config.exists(v)?v:null));if(c!==P.current)return;const T=(v,V)=>({kind:v,id:V.id,name:v==="command"?`/${V.name??V.id}`:V.name??V.id,description:V.description});m([...ne.map(v=>T("command",v)),...te.map(v=>({kind:"skill",id:v.id,name:v.name??v.id,description:v.description,skill:v})),...B.map(v=>T("agent",v)),...ee.map(v=>({kind:"hook",...v})),...U.mcpServers.map(v=>({kind:"mcp",id:v.id,name:v.name,description:v.description}))]),f(te);const I=d.filter(v=>v!==null);S(v=>v.join("\0")===I.join("\0")?v:I)}catch(b){if(c!==P.current)return;H.error(`Failed to load plugin contents: ${b instanceof Error?b.message:String(b)}`)}finally{c===P.current&&h(!1)}},[t.path]);r.useEffect(()=>(h(!0),D(),()=>{P.current+=1}),[D]);const L=r.useRef(null),_=r.useRef(!1),M=r.useRef(!1),N=r.useCallback(async()=>{if(_.current){M.current=!0;return}_.current=!0;try{do M.current=!1,await D();while(M.current)}finally{_.current=!1}},[D]),F=r.useCallback(()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{L.current=null,N()},pn)},[N]);if(r.useEffect(()=>()=>{L.current&&clearTimeout(L.current)},[]),ae(w,F,{depth:0}),x)return e.jsx(un,{pluginName:((Z=t.manifest)==null?void 0:Z.name)??t.name,skills:g,initialSelectedId:x.id,onBack:()=>u(null)},x.id);const q=t.enabled===!0,$=((p=t.manifest)==null?void 0:p.version)??null,G=vn($,E),J=(W=t.manifest)==null?void 0:W.description,k=c=>a.filter(b=>b.kind===c).length,X=[["command","COMMAND","COMMANDS"],["skill","SKILL","SKILLS"],["agent","AGENT","AGENTS"],["hook","HOOK","HOOKS"],["mcp","MCP SERVER","MCP SERVERS"]].filter(([c])=>k(c)>0).map(([c,b,R])=>xn(k(c),b,R)).join(" · "),z=k("skill")+k("command")>0;return e.jsxs("div",{"data-testid":"plugin-detail",className:"flex flex-col min-h-0",children:[e.jsx(Ke,{eyebrow:hn(t),title:t.name,actions:e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 text-[13.5px] text-fg-dim",children:[e.jsx(qe,{name:t.name,enabled:q,disabled:!t.key||s,onToggle:()=>l(t),testId:"plugin-detail-switch"}),"Enabled"]}),G&&e.jsx("span",{"data-testid":"plugin-update-state","data-state":G,title:`Installed v${$} · ${t.marketplace} lists v${E}`,className:`h-7 inline-flex items-center px-3 bg-bg border rounded-md text-[13px] font-semibold ${G==="update-available"?"border-accent text-accent":"border-line text-fg-dim"}`,children:G==="update-available"?"Update available":"Up to date"}),e.jsx(fn,{row:t,busy:s,onUninstall:o})]})}),e.jsxs("div",{className:"px-9 py-6 flex flex-col gap-4 max-w-[1100px]",children:[e.jsx(pe,{label:"DESCRIPTION",labelNote:"FROM THE PLUGIN'S MANIFEST",children:e.jsx("span",{"data-testid":"plugin-description",className:J?void 0:"text-fg-faint",children:J??(t.hasManifest?"The manifest has no description.":"This plugin has no manifest.")})}),e.jsx(pe,{label:"WHAT IT ADDS",labelNote:y?void 0:X||"NOTHING",action:z?e.jsx("button",{type:"button","data-testid":"plugin-open-in-skills",onClick:()=>i("skills"),className:"shrink-0 text-[13px] font-semibold text-accent hover:underline",children:"Open in Skills →"}):void 0,children:y?e.jsx(Y,{title:"scanning…"}):a.length===0?e.jsx("span",{className:"text-fg-faint",children:t.error?`Inspection failed: ${t.error}`:"No commands, skills, agents or hooks."}):e.jsx("ul",{"data-testid":"plugin-adds",className:"-mx-[18px] mt-2 border-t border-line",children:a.map(c=>{const b=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-[200px] shrink-0 truncate font-mono text-[14px] font-semibold text-fg",title:c.name,children:c.name}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-[13.5px] text-fg-dim",title:c.description??void 0,children:c.description??""})]}),R="w-full flex items-baseline gap-4 px-[18px] py-3 text-left";return e.jsx("li",{"data-testid":`plugin-adds-${c.kind}`,className:"border-b border-line last:border-b-0",children:c.skill?e.jsx("button",{type:"button",onClick:()=>u(c.skill),className:`${R} hover:bg-bg-elev`,children:b}):e.jsx("div",{className:R,children:b})},`${c.kind}:${c.id}`)})})}),e.jsx(pe,{label:"INSTALLED AT",action:e.jsx("button",{type:"button","data-testid":"plugin-reveal",onClick:()=>Ne(t.path),className:"shrink-0 text-[13px] text-fg-dim hover:text-fg",children:"Reveal"}),children:e.jsx("span",{"data-testid":"plugin-install-path",title:t.path,className:"block truncate font-mono text-[14px]",children:Jt(t.path,n)})}),e.jsx(Nt,{text:mn})]})]})}const kn="~/.claude/plugins/installed_plugins.json",Cn="On/off is saved in settings.json › enabledPlugins",Nn=t=>ye.getState().openPanel("extensions",t);function Sn(t,n){var s,l;return[t.name,(s=t.manifest)==null?void 0:s.name,t.marketplace,(l=t.manifest)==null?void 0:l.description].some(o=>typeof o=="string"&&o.toLowerCase().includes(n))}const ie=(t,n,s)=>`${t} ${t===1?n:s}`;function En(t){const n=$t(t),s=[];if(t.marketplace&&s.push(t.marketplace),t.error)s.push("inspection failed");else{const l=[n.commands>0?ie(n.commands,"command","commands"):null,n.skills>0?ie(n.skills,"skill","skills"):null,n.agents>0?ie(n.agents,"agent","agents"):null,n.hooks>0?ie(n.hooks,"hook","hooks"):null,n.mcpServers>0?ie(n.mcpServers,"MCP server","MCP servers"):null].filter(o=>o!==null);s.push(...l.length>0?l:["empty"])}return t.scope&&t.scope!=="user"&&s.push(`${t.scope} scope`),s.join(" · ")}function $n({onAdd:t,onJump:n}){const s=oe(),[l,o]=r.useState([]),[i,a]=r.useState(!0),[m,g]=r.useState(null),[f,x]=r.useState(null),[u,y]=r.useState(""),[h,w]=r.useState(null),[S,P]=r.useState(new Set),E=ot(c=>c.show),[O,A]=r.useState(null);r.useEffect(()=>{var b,R;let c=!1;return(R=(b=window.api.app).seedStatus)==null||R.call(b).then(U=>{c||w(U)}).catch(()=>{}),()=>{c=!0}},[]);const j=r.useRef(0),D=r.useRef(!1),L=r.useCallback(async()=>{var ee,te;const c=++j.current;if(!s)return;D.current||a(!0);const b=`${s}/.claude/plugins/installed_plugins.json`;let R=[],U=null;try{const B=await window.api.config.readJson(b);if(B.exists&&B.parseError)U=`could not parse installed_plugins.json${B.error?`: ${B.error}`:""}`;else if(B.exists&&B.data&&typeof B.data=="object"){const ne=B.data,d=[];for(const[I,v]of Object.entries(ne.plugins??{})){if(!Array.isArray(v))continue;const[V,fe]=I.split("@");for(const K of v)K!=null&&K.installPath&&d.push({name:V,marketplace:fe,entry:K})}let T=new Map;try{const I=await((te=(ee=window.api.plugins)==null?void 0:ee.list)==null?void 0:te.call(ee))??[];T=new Map(I.map(v=>[v.key,v.enabled]))}catch{}R=await Tn(d,Pn,async({name:I,marketplace:v,entry:V})=>{var Me;const fe={name:I,path:V.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0};let K;try{K=await St(fe)}catch(xe){K=Et(fe,xe instanceof Error?xe.message:String(xe))}return(Me=K.manifest)!=null&&Me.version||(K.manifest={...K.manifest??{},version:V.version}),K.marketplace=v,K.scope=V.scope,K.key=v?`${I}@${v}`:I,K.enabled=T.get(K.key)===!0,K})}}catch(B){U=`could not read installed_plugins.json: ${B instanceof Error?B.message:String(B)}`}j.current===c&&(g(U),U?H.error(`Plugins: ${U}`):(R.sort((B,ne)=>B.name.localeCompare(ne.name)),D.current=R.length>0,o(R)),a(!1))},[s]);r.useEffect(()=>{L()},[L]);const _=le(c=>c.tab),M=le(c=>c.id),N=le(c=>c.clear);r.useEffect(()=>{if(_!=="plugins"||!M||i)return;const c=M.startsWith("plugins:")?M.slice(8):null,b=c?l.find(R=>R.key===c):void 0;b&&(y(""),x(b.path)),N()},[_,M,i,l,N]),r.useEffect(()=>()=>{j.current+=1},[]),ae(s?[`${s}/.claude/plugins/installed_plugins.json`]:[],L);const F=async c=>{if(c.key){A(c.key);try{const b=await window.api.plugins.setEnabled({key:c.key,enabled:!c.enabled});b.ok||E("error",`Could not ${c.enabled?"disable":"enable"} ${c.name}: ${b.error??"unknown error"}`)}catch(b){E("error",`Could not update ${c.name}: ${b instanceof Error?b.message:String(b)}`)}finally{A(null),await L()}}},q=async c=>{if(c.marketplace){A(c.key??c.name);try{const b=await window.api.plugins.uninstall({slug:c.name,marketplaceName:c.marketplace});b.ok||E("error",`Uninstall ${c.name} failed: ${b.error??`exit ${b.exitCode}`}`)}catch(b){E("error",`Uninstall ${c.name} failed: ${b instanceof Error?b.message:String(b)}`)}finally{A(null),await L()}}},$=r.useMemo(()=>h?Object.keys(h).filter(c=>(h[c].status==="exhausted"||h[c].status==="failed")&&!S.has(c)):[],[h,S]),G=r.useMemo(()=>l.filter(c=>c.enabled===!0).length,[l]),J=u.trim().toLowerCase(),k=r.useMemo(()=>J?l.filter(c=>Sn(c,J)):l,[l,J]),C=k.find(c=>c.path===f)??k[0]??null,X=r.useCallback(()=>t==null?void 0:t(),[t]),z=n??Nn,Z=c=>O!==null&&O===(c.key??c.name),p=e.jsxs(e.Fragment,{children:[e.jsx(Je,{eyebrow:"PLUGINS",badge:`${G} on`,path:kn,note:Cn}),e.jsx(ze,{filter:u,onFilterChange:y,placeholder:"Filter",primaryLabel:"+ Add",onPrimary:X}),i&&l.length===0||m&&l.length===0?null:l.length===0?e.jsxs("div",{"data-testid":"plugins-empty",className:"flex flex-col gap-1 px-3 py-3 border border-dashed border-rule rounded-xl text-[13px] text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg",children:"No plugins installed"}),e.jsxs("span",{children:["Use + Add, or run ",e.jsx("code",{className:"font-mono text-xs",children:"claude plugin install"}),"."]})]}):k.length===0?e.jsxs("p",{className:"px-1 text-[13px] text-fg-dim",children:["No plugins match “",u.trim(),"”."]}):e.jsx("div",{role:"listbox","aria-label":"Installed plugins",className:"flex flex-col gap-1",children:k.map(c=>e.jsx(ke,{title:c.name,meta:En(c),muted:c.enabled!==!0,selected:(C==null?void 0:C.path)===c.path,onSelect:()=>x(c.path),trailing:e.jsx(qe,{name:c.name,enabled:c.enabled===!0,disabled:!c.key||Z(c),onToggle:()=>void F(c)})},c.path))})]}),W=C?e.jsx(wn,{row:C,home:s,busy:Z(C),onToggle:c=>void F(c),onUninstall:c=>void q(c),onJump:z},C.path):i?e.jsx(Y,{title:"scanning plugins…"}):m?null:l.length===0?e.jsx(Y,{title:"No plugins installed",hint:"+ Add browses the plugin catalog."}):e.jsx(Y,{title:"No plugin matches the filter"});return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[$.length>0?e.jsx(Mn,{seeders:$,seedStatus:h,onDismiss:c=>P(b=>new Set(b).add(c)),onOpenLibrary:X}):null,m?e.jsxs("div",{role:"alert",className:"shrink-0 px-3 py-2 border-b border-line bg-red-950/20 text-xs text-red-300",children:[m,l.length>0?" — showing the last known list":null]}):null,e.jsx(Ce,{list:p,detail:W})]})}const Ln=r.memo($n),he={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function Mn({seeders:t,seedStatus:n,onDismiss:s,onOpenLibrary:l}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(o=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:n[o].status==="failed"?`${he[o]} setup failed — it will retry on next launch. To fix it now:`:`${he[o]} setup failed after retrying — manual fix needed`}),o==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:l,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[o].fix})]}),e.jsx("button",{onClick:()=>s(o),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${he[o]} warning`,children:"✕"})]},o))})}const Pn=4;async function Tn(t,n,s){const l=new Array(t.length);let o=0;const i=Array.from({length:Math.min(n,t.length)},async()=>{for(;o<t.length;){const a=o++;l[a]=await s(t[a])}});return await Promise.all(i),l}function Ye(t,n){const s=oe();ae([s?`${s}/.claude/agents`:null,...t.map(l=>`${l}/.claude/agents`)],n)}function An({onOpenPersona:t}){const[n,s]=r.useState(se[0].tag),{personas:l,refresh:o}=Se(a=>H.error(a.message||"failed to load agent personas"));Ye([],()=>{o()});const i=se.find(a=>a.tag===n)??null;return e.jsx(Yt,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[se.length," tag",se.length===1?"":"s"]}),children:e.jsx(Ve,{sidebar:e.jsx("div",{className:"py-1",children:se.map(a=>{const m=Ee(a.tag),g=n===a.tag,f=(l==null?void 0:l.filter(x=>x.tags.includes(a.tag)).length)??0;return e.jsxs("button",{onClick:()=>{s(a.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${g?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${m.bg} ${m.text} ${m.border?"border border-current/30":""}`,children:["#",a.tag]}),e.jsx("span",{className:"truncate",children:a.label}),f>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:f})]},a.tag)})}),detail:i?e.jsx(Rn,{entry:i,personas:l,onOpenPersona:t}):e.jsx(Y,{title:"select a tag"})})})}const Dn=r.memo(An);function Rn({entry:t,personas:n,onOpenPersona:s}){const l=Ee(t.tag),o=it(t.tag),i=(n==null?void 0:n.filter(a=>a.tags.includes(t.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${l.bg} ${l.text} ${l.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:t.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),n===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.map(a=>e.jsx("button",{onClick:()=>s==null?void 0:s(a.name),title:`Open ${a.name} in Personas`,className:"inline-flex items-center bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim hover:text-fg hover:bg-bg-hi",children:a.name},a.name)),i.length===0&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:o.initialPromptTemplate})]})]})}const In=t=>{const[n,s]=t.split(".");return Number(n)+(s?Number(s)/100:0)};function On(t){const n=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!n)return[];const s=[];for(const l of n[1].split(/,\s*|\s+and\s+/)){const o=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(l.trim());o&&s.push({family:o[1].toLowerCase(),version:In(o[2])})}return s}var Fe,_e;const Fn=On(String(((_e=(Fe=Lt.properties)==null?void 0:Fe.effortLevel)==null?void 0:_e.description)??""));function _n(t,n){const s=new RegExp(`${n}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(s)return Number(s[1])+(s[2]?Number(s[2])/100:0);const l=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${n}`,"i").exec(t);return l?Number(l[1])+(l[2]?Number(l[2])/100:0):null}function Xe(t,n=Fn){if(!t||t==="inherit"||n.length===0)return null;const s=Q(t);if(!s)return null;const l=n.filter(i=>i.family===s);if(l.length===0)return!1;const o=_n(t,s);return o===null?null:o>=Math.min(...l.map(i=>i.version))}const be=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Bn=["","red","orange","yellow","green","cyan","blue","purple","pink"],De={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function ve(t){return{name:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??"inherit",color:t.color??"",tags:t.tags,body:t.body,agentCli:t.agentCli??"claude",agentCliModel:t.agentCliModel??""}}const Re={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:"",agentCli:"claude",agentCliModel:""};function $e(t){return[...t.fields.filter(n=>n!=="name"),...t.bodyOverridden?["full body"]:[]]}function Un(t){var s,l;const n=[(s=t.values)==null?void 0:s.model,(l=t.values)==null?void 0:l.effort].filter(o=>!!o);return t.bodyOverridden&&n.push("full body"),n.length?n.join(" · "):$e(t).join(", ")||"overlay"}function Hn({items:t}){const[n,s]=r.useState(!1),l=r.useRef(null),o=r.useRef(null),i=r.useId();return r.useEffect(()=>{if(!n)return;const a=g=>{var x,u;const f=g.target;(x=l.current)!=null&&x.contains(f)||(u=o.current)!=null&&u.contains(f)||s(!1)},m=g=>{g.key==="Escape"&&s(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",m)}},[n]),e.jsxs("div",{className:"relative",children:[e.jsx("button",{ref:l,type:"button","data-testid":"agent-detail-more","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?i:void 0,onClick:()=>s(a=>!a),className:"h-9 w-9 inline-flex items-center justify-center rounded-[10px] bg-bg-hi border border-line text-fg-dim hover:text-fg hover:border-rule",children:"⋯"}),n&&e.jsx("div",{ref:o,id:i,role:"menu","aria-label":"More actions","data-testid":"agent-detail-more-menu",className:`absolute ${Be.dialog} right-0 top-[42px] min-w-[200px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[13px] text-fg`,children:t.map(a=>a.info?e.jsx("div",{role:"note","data-testid":a.testId,className:"px-2.5 pb-[7px] pt-0.5 text-[11px] text-fg-faint whitespace-nowrap border-b border-line mb-1",children:a.label},a.testId):e.jsx("button",{type:"button",role:"menuitem","data-testid":a.testId,disabled:a.disabled,onClick:()=>{s(!1),a.onSelect()},className:`px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev disabled:opacity-40 ${a.danger?"text-red-400":""}`,children:a.label},a.testId))})]})}function re({children:t}){return e.jsx("span",{className:"shrink-0 w-[150px] text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint pt-1",children:t})}function Gn({obj:t,set:n,saved:s,dirty:l,isNew:o,busy:i,confirmDelete:a,setConfirmDelete:m,onDuplicate:g,onRevert:f,onSave:x,onDelete:u,onDropOverride:y,projects:h,selected:w,onSelect:S,onSaveOverride:P}){const E=oe(),{catalog:O,loading:A,degraded:j,refresh:D}=ue(null),{checking:L,recheck:_}=Ue(),[M,N]=r.useState(!1),F=!o&&s?s.path:`${E??"~"}/.claude/agents/${t.name}.md`,q=l||o,$=s&&!o?s.overrideDetails??[]:[],G=!o&&!!s&&(M||w!==null),J=t.tools.length===0,k=O?`Models live-read from claude${O.claudeVersion?` ${O.claudeVersion}`:""}${j?" (cached — CLI probe unavailable)":""}`:A?"Loading model catalog…":"Model catalog unavailable — showing the standard list",C=[{label:A||L?"Re-checking…":"Re-check models & CLIs",testId:"agent-detail-recheck",disabled:A||L,onSelect:()=>{D(),_()}},{label:k,testId:"agent-detail-catalog-info",disabled:!0,info:!0,onSelect:()=>{}},{label:"Reveal in File Explorer",testId:"agent-detail-reveal",disabled:o,onSelect:()=>Ne(F)},...o?[]:[{label:"Delete agent…",testId:"agent-detail-delete",danger:!0,disabled:i,onSelect:()=>m(!0)}]],X=p=>{if(J){n({tools:be.filter(W=>W!==p)});return}n({tools:t.tools.includes(p)?t.tools.filter(W=>W!==p):[...t.tools,p]})},z=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:g,disabled:i,className:"h-9 px-4 rounded-[10px] bg-bg-hi border border-line text-[13.5px] font-medium text-fg hover:border-rule disabled:opacity-40",children:"Duplicate"}),e.jsx(Hn,{items:C})]}),Z=$.length===0?o?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere.":$.length===1?`a local copy in ${me($[0].cwd,E)}/.claude/agents/ wins there`:"each project's local copy in its .claude/agents/ wins there";return e.jsxs("div",{"data-testid":"agent-detail",className:"flex-1 shrink-0 min-h-full flex flex-col",children:[e.jsx(Ke,{eyebrow:`AGENT · USER · ${me(F,E)}`,title:t.name,pill:o?"unsaved draft":l?"edited":void 0,actions:z}),a&&e.jsxs("div",{"data-testid":"agent-detail-delete-confirm",role:"alert",className:"shrink-0 mx-9 mt-4 px-4 py-2.5 rounded-[10px] border border-red-400/40 bg-red-400/10 flex items-center gap-3 text-[13px] text-fg",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx("button",{type:"button",onClick:u,disabled:i,className:"font-semibold text-red-400 hover:text-red-300",children:"Delete"}),e.jsx("button",{type:"button",onClick:()=>m(!1),className:"text-fg-faint hover:text-fg",children:"Keep"})]}),e.jsxs("div",{"data-testid":"agent-detail-body",className:"flex-1 shrink-0 flex flex-col gap-4 px-9 py-6",children:[e.jsx(pe,{label:"DESCRIPTION",labelNote:"CLAUDE READS THIS TO PICK THE AGENT",children:e.jsx("textarea",{"data-testid":"agent-detail-description","aria-label":"Description",rows:2,value:t.description,onKeyDown:p=>{p.key==="Enter"&&p.preventDefault()},onChange:p=>n({description:p.target.value.replace(/\r?\n/g," ")}),placeholder:"What this agent does — Claude reads it to decide when to use it",className:"w-full resize-none bg-transparent outline-none text-fg placeholder:text-fg-faint"})}),e.jsxs("section",{"data-testid":"agent-runtime-card",className:"px-[18px] py-4 rounded-[14px] bg-bg-hi border border-line flex flex-col gap-4",children:[e.jsxs("div",{"data-testid":"agent-runtime-row",className:"grid grid-cols-3 gap-4",children:[e.jsx(Vn,{value:t.model,onChange:p=>n({model:p})}),e.jsx(Kn,{value:t.effort,model:t.model,onChange:p=>n({effort:p})}),e.jsxs("div",{className:"min-w-0 flex flex-col gap-1.5",children:[e.jsx(zn,{value:t.agentCli,onChange:p=>n({agentCli:p,agentCliModel:""})}),t.agentCli!=="claude"&&e.jsx("input",{"data-testid":"agent-persona-cli-model","aria-label":"CLI model",value:t.agentCliModel,maxLength:128,placeholder:"Blank = the CLI's own default",onChange:p=>n({agentCliModel:p.target.value}),className:"w-full bg-bg border border-line rounded-md px-2 py-1 text-xs text-fg font-mono"})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"agent-tools-row",children:[e.jsx(re,{children:"tools"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:be.map(p=>{const W=J||t.tools.includes(p);return e.jsx("button",{type:"button","aria-pressed":W,"data-tool":p,onClick:()=>X(p),className:`px-2 py-0.5 rounded-md text-[12px] font-mono border ${W?"bg-honey/20 text-honey-dark border-honey/40":"bg-transparent text-fg-faint border-dashed border-rule"}`,children:p},p)})}),e.jsx("div",{"data-testid":"agent-tools-note",className:"text-[11px] text-fg-faint mt-1 leading-snug",children:J?"All tools — no tools: line, so every tool (MCP included) is granted. Click one to restrict.":e.jsxs(e.Fragment,{children:[t.tools.length," of ",be.length," granted. Anything not filled is refused at call time."," ",e.jsx("button",{type:"button","data-testid":"agent-tools-all",onClick:()=>n({tools:[]}),className:"underline text-fg-dim hover:text-fg",children:"Grant all tools"})]})})]})]}),e.jsxs("div",{className:"flex items-start gap-3","data-testid":"agent-overrides-row",children:[e.jsx(re,{children:"project overrides"}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2 pt-0.5",children:[$.map(p=>e.jsxs("span",{"data-testid":"agent-override-chip",title:`${me(p.cwd,E)}/.claude/agents/${s.name}.md`,className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded-md px-2 py-0.5 text-[12px] font-mono text-fg-dim",children:[e.jsx("strong",{className:"font-sans font-semibold text-fg",children:p.project}),Un(p),e.jsx("button",{onClick:()=>y(p.cwd,p.project),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},p.cwd)),e.jsx("span",{className:`text-[12px] text-fg-faint ${$.length===0?"italic":""}`,children:Z}),!o&&s&&!G&&e.jsx("button",{type:"button","data-testid":"agent-override-add",onClick:()=>N(!0),className:"text-[12px] font-medium text-accent hover:underline",children:"+ Add override"})]})]}),G&&s&&e.jsx(Xn,{saved:s,projects:h,selected:w,onSelect:S,busy:i,onSave:P,onClose:()=>{N(!1),S(null)}}),e.jsxs("details",{"data-testid":"agent-details",open:o||void 0,className:"group border-t border-line pt-3",children:[e.jsxs("summary",{className:"cursor-pointer select-none flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint",children:[e.jsx("span",{children:"details"}),e.jsxs("span",{className:"normal-case tracking-normal font-normal font-mono text-fg-dim flex items-center gap-1.5",children:[t.color&&e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{background:De[t.color]}}),t.color||"no colour"," · ",t.tags.length?t.tags.map(p=>`#${p}`).join(" "):"no tags"]})]}),e.jsxs("div",{className:"flex flex-col gap-3 pt-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"name"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("input",{"data-testid":"agent-detail-name","aria-label":"Name",value:t.name,onChange:p=>n({name:p.target.value.toLowerCase()}),className:"w-full max-w-sm bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:"Filename on disk — lowercase, hyphenated."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"color"}),e.jsx("div",{className:"flex gap-1.5 pt-0.5",children:Bn.map(p=>e.jsx("button",{type:"button",title:p||"none",onClick:()=>n({color:p}),className:"w-5 h-5 rounded",style:{background:p?De[p]:"transparent",border:t.color===p?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},p||"none"))})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{children:"tags"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:se.map(p=>{const W=t.tags.includes(p.tag),c=Ee(p.tag);return e.jsxs("button",{type:"button",onClick:()=>n({tags:W?t.tags.filter(b=>b!==p.tag):[...t.tags,p.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${W?`${c.bg} ${c.text} ${c.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",p.tag]},p.tag)})}),e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab."})]})]})]})]})]}),e.jsx("div",{"data-testid":"agent-detail-editor","data-busy":i?"true":void 0,className:"flex-1 shrink-0 min-h-[320px] grid rounded-[14px] border border-line bg-bg-hi overflow-hidden",children:e.jsx(Mt,{path:F,value:t.body,defaultMode:"document",dirty:q,isNew:o,onChange:p=>n({body:p}),onSave:()=>{i||x()},onRevert:f})})]})]})}const Wn="w-full h-9 appearance-none pl-3 pr-8 rounded border border-line bg-bg-hi font-mono text-[13px] text-fg focus:outline-none focus:border-fg-faint disabled:opacity-60";function Le({label:t,hint:n,testId:s,value:l,onChange:o,children:i}){return e.jsxs("label",{className:"min-w-0 flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint",children:t}),e.jsxs("span",{className:"relative block",children:[e.jsx("select",{"data-testid":s,"aria-label":t,title:n,value:l,onChange:a=>o(a.target.value),className:Wn,children:i}),e.jsx("svg",{"aria-hidden":!0,"data-testid":`${s}-chevron`,viewBox:"0 0 16 16",className:"pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-faint",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M4 6l4 4 4-4"})})]})]})}const Ie=t=>{var n;return((n=/\[[^\]]*\]$/.exec(t))==null?void 0:n[0])??""};function Vn({value:t,onChange:n}){const{catalog:s}=ue(null),l=s?["inherit",...s.aliases]:[...He],o=(s==null?void 0:s.availableModels)??null,i=[];if(s){const u=new Set,y=h=>{!u.has(h)&&!l.includes(h)&&(u.add(h),i.push(h))};for(const h of s.models)y(h);for(const h of s.aliases){const w=Q(h),S=Ie(h);if(w&&S)for(const P of s.models)Q(P)===w&&y(P+S)}}const a=u=>!!o&&u!=="inherit"&&!o.includes(u),m=u=>{const y=Q(u);return!!o&&!o.includes(u)&&!(y&&o.includes(y+Ie(u)))&&!(y&&o.includes(y))},g=t||"inherit",f=l.includes(g)||i.includes(g);return e.jsxs(Le,{label:"model",hint:"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls. Pinned versions fix a concrete id; an alias floats to the latest.",testId:"model-select",value:g,onChange:n,children:[!f&&e.jsxs("option",{value:g,children:[g," (current)"]}),e.jsx("optgroup",{label:"Aliases",children:l.map(u=>e.jsx("option",{value:u,disabled:!!s&&a(u),title:a(u)?ge:void 0,children:u},u))}),i.length>0&&e.jsx("optgroup",{label:"Pinned versions",children:i.map(u=>e.jsx("option",{value:u,disabled:m(u),title:m(u)?ge:void 0,children:u},u))})]})}function Kn({value:t,model:n,onChange:s}){const{catalog:l}=ue(null),o=l&&l.effortLevels.length?["inherit",...l.effortLevels]:[...Ge],i=(l==null?void 0:l.settingsEffortLevels)??[],a=l?o.filter(x=>x!=="inherit"&&!i.includes(x)):[],m=t||"inherit",g=m!=="inherit"&&Xe(n)===!1,f=l?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${a.length?`${a.join(", ")} ${a.length>1?"are":"is"} session-only — settings.json accepts ${i.join(", ")}. `:""}'inherit' writes no effort: line.`:"Catalog unavailable — showing the standard list. 'inherit' writes no effort: line.";return e.jsxs("div",{className:"min-w-0 flex flex-col gap-1",children:[e.jsxs(Le,{label:"effort",hint:f,testId:"effort-select",value:m,onChange:s,children:[!o.includes(m)&&e.jsxs("option",{value:m,children:[m," (current)"]}),o.map(x=>e.jsx("option",{value:x,children:a.includes(x)?`${x} (session-only)`:x},x))]}),g&&e.jsx("div",{className:"text-[11px] text-amber-400 leading-snug","data-testid":"effort-unsupported-note",children:"This model ignores effort."})]})}const Jn=["codex","gemini","antigravity","cursor","opencode"];function zn({value:t,onChange:n}){const{rows:s}=Ue(),l=new Map((s??[]).map(i=>[i.id,i]));return e.jsxs(Le,{label:"runs on",hint:"Which coding-agent CLI New Session starts this persona on — override per session in New Session → advanced. On a non-Claude CLI the session has no develop loop, no Restore, and this persona's model/effort are not used. Macros, phone launches and scheduled PRDs always run Claude Code.",testId:"agent-persona-cli-select",value:t,onChange:i=>n(i),children:[e.jsx("option",{value:"claude",children:"Claude Code"}),Jn.map(i=>{const a=l.get(i),m=(a==null?void 0:a.label)||rt[i],g=!!(a!=null&&a.installed),f=a?g?"":" (not installed)":s===null?" (checking…)":" (not detected)",x=a?g?[a.version,a.path].filter(Boolean).join(" · ")||void 0:a.install??"Not installed":void 0;return e.jsxs("option",{value:i,disabled:!g&&t!==i,title:x,children:[m,f]},i)})]})}function Ze({label:t,hint:n,children:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.1em] text-fg-faint mb-1.5",children:t}),s,n&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:n})]})}const je="latest",ge="Blocked by the availableModels allowlist in your Claude settings";function qn({value:t,onChange:n,label:s="model",hint:l,testIdPrefix:o="",inheritLabel:i}){var F,q;const{catalog:a,loading:m,degraded:g,refresh:f}=ue(null),x=a?["inherit",...a.aliases]:[...He],u=(a==null?void 0:a.availableModels)??null,y=$=>!!u&&$!=="inherit"&&!u.includes($),h=($,G)=>!!u&&!u.includes($)&&!(G&&u.includes(G)),w=t||"inherit",S=((F=/\[[^\]]*\]$/.exec(w))==null?void 0:F[0])??"",P=x.includes(w),E=!P&&a&&Q(w)&&x.includes(Q(w)+S)?Q(w)+S:null,O=P?w:E??w,A=Q(O),j=((q=/\[[^\]]*\]$/.exec(O))==null?void 0:q[0])??"",D=!!a&&w!=="inherit"&&!!A&&x.includes(O),L=D?a.models.filter($=>Q($)===A).map($=>$+j):[],_=P?je:w,M={};if(a)for(const $ of x)y($)&&(M[$]=ge);const N={};for(const $ of L)h($,A)&&(N[$]=ge);return e.jsxs(Ze,{label:s,hint:l??"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls.",children:[e.jsx("div",{"data-testid":`${o}model-row`,children:e.jsx(we,{options:x,value:O,onChange:n,mono:!0,blocked:M,labels:i?{inherit:i}:void 0})}),D&&e.jsxs("div",{className:"mt-2","data-testid":`${o}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(we,{options:[je,...L],value:_,onChange:$=>n($===je?O:$),mono:!0,blocked:N})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:a?`Models are live-read from the installed claude CLI${g?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:m?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${o}model-catalog-refresh`,onClick:()=>{f()},disabled:m,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function Yn({value:t,model:n,onChange:s,label:l="effort",testIdPrefix:o="",inheritLabel:i}){const{catalog:a}=ue(null),m=a&&a.effortLevels.length?["inherit",...a.effortLevels]:[...Ge],g=(a==null?void 0:a.settingsEffortLevels)??[],f=a?m.filter(y=>y!=="inherit"&&!g.includes(y)):[],x=t||"inherit",u=x!=="inherit"&&Xe(n)===!1;return e.jsxs(Ze,{label:l,hint:a?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${f.length?`${f.join(", ")} ${f.length>1?"are":"is"} session-only — settings.json accepts ${g.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${o}effort-row`,children:e.jsx(we,{options:m,value:x,onChange:s,mono:!0,labels:i?{inherit:i}:void 0})}),f.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${o}effort-session-only`,children:f.map(y=>`${y} (session-only)`).join(" · ")}),u&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${o}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Xn({saved:t,projects:n,selected:s,onSelect:l,busy:o,onSave:i,onClose:a}){var E,O,A;const m=oe(),g=r.useId(),f=new Map;for(const j of n)f.set(j.name,(f.get(j.name)??0)+1);const x=j=>{var M;const D=(f.get(j.name)??0)>1?me(j.cwd,m):j.name,L=(M=t.overrideDetails)==null?void 0:M.find(N=>N.cwd===j.cwd);if(!L)return D;const _=$e(L);return`${D} — ${_.length?`overrides ${_.join(", ")}`:"overlay"}`},u=s?(E=t.overrideDetails)==null?void 0:E.find(j=>j.cwd===s.cwd):void 0,y=!!(u!=null&&u.bodyOverridden),h=((O=u==null?void 0:u.values)==null?void 0:O.model)??"inherit",w=((A=u==null?void 0:u.values)==null?void 0:A.effort)??"inherit",S=t.model??"inherit",P=t.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override-block",className:s?"border border-accent/40 rounded p-3 space-y-3 bg-accent/5":"border border-dashed border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:g,className:`flex-1 text-[10.5px] font-semibold uppercase tracking-wide font-mono ${s?"text-accent":"text-fg-faint"}`,children:"project override"}),e.jsx("button",{type:"button","data-testid":"override-close",onClick:a,className:"text-[11px] text-fg-faint hover:text-fg",children:"Done"})]}),e.jsx("div",{className:"flex flex-col gap-1",children:e.jsxs("select",{id:g,"data-testid":"override-project-select",value:(s==null?void 0:s.cwd)??"",onChange:j=>l(j.target.value||null),disabled:o||n.length===0,className:"rounded-md border border-line bg-bg px-2 py-1.5 font-mono text-[12.5px] text-fg disabled:opacity-60",children:[e.jsx("option",{value:"",children:"Choose a project…"}),n.map(j=>e.jsx("option",{value:j.cwd,children:x(j)},j.cwd))]})}),n.length===0?e.jsx("div",{"data-testid":"project-override-none",className:"text-[11px] text-fg-faint leading-snug",children:"No open project tabs — open a project tab to override this persona's model or effort for it."}):s?e.jsxs("div",{"data-testid":"project-override",className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(We,{tone:"accent",children:[s.name," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(zt,{path:`${s.cwd}/.claude/agents/${t.name}.md`})})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint leading-snug",children:["Changes what the SCHEDULER (and new Epics) spawn for ",e.jsx("strong",{children:s.name})," only — a frontmatter-only overlay with just the keys you set; the persona's body stays the global one. The global model/effort rows edit the machine-wide persona and are never touched here."]}),y&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s.name,' already has a FULL-BODY override of this persona (its own definition text). It is shown as-is and not converted to a frontmatter-only overlay — edit that file directly, or drop it with its × in the "project overrides" row above.']}),e.jsxs("fieldset",{disabled:o||y,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(qn,{value:h,onChange:j=>{y||i({model:j,effort:w})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(Yn,{value:w,model:h!=="inherit"?h:S,onChange:j=>{y||i({model:h,effort:j})},label:"project effort",testIdPrefix:"override-",inheritLabel:"use global"})]}),e.jsx("div",{"data-testid":"override-provenance",className:"text-[11px] font-mono text-fg-dim space-y-0.5",children:[["model",S,h],["effort",P,w]].map(([j,D,L])=>e.jsxs("div",{"data-testid":`override-provenance-${j}`,children:[j,": ",L!=="inherit"?e.jsxs(e.Fragment,{children:[D," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:L})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[D," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},j))})]}):e.jsx("div",{"data-testid":"project-override-unselected",className:"text-[11px] text-fg-faint leading-snug",children:"Pick an open project to see or set this persona's model and effort for that project only. A project that already overrides this persona says what it overrides."})]})}const Zn=new Set(se.map(t=>t.tag));function Qe(t){return t.filter(n=>Zn.has(n))}function Qn(t,n={}){return{name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??void 0,color:t.color??"",tags:Qe(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...t.agentCli?{agentCli:t.agentCli}:{},...t.agentCliModel?{agentCliModel:t.agentCliModel}:{},...n}}function es(t){const n=new Map;for(const s of t){const l=typeof s.cwd=="string"?dt(s.cwd):"";l&&!n.has(l)&&n.set(l,{cwd:l,name:ut(l)})}return[...n.values()].sort((s,l)=>s.name.localeCompare(l.name)||s.cwd.localeCompare(l.cwd))}function ts(t){return(t.overrideDetails??[]).map(n=>`${n.project}: ${$e(n).join(", ")||"overlay"}`).join(`
|
|
3
|
+
`)}const ns=[{key:"personas",label:"Personas"},{key:"tags",label:"Tags"}];function ss(){const[t,n]=r.useState("personas"),{personas:s,refresh:l}=Se(d=>H.error(d.message||"failed to load agent personas")),[o,i]=r.useState(null),[a,m]=r.useState(""),[g,f]=r.useState(null),[x,u]=r.useState(!1),[y,h]=r.useState(!1),[w,S]=r.useState(null),[P,E]=r.useState(!1),O=r.useRef(!0);r.useEffect(()=>()=>{O.current=!1},[]);const A=ct(d=>d.tabs),j=r.useMemo(()=>es(A),[A]),[D,L]=r.useState(null),_=j.find(d=>d.cwd===D)??null,M=async d=>{await l()&&d&&i(d)};Ye(j.map(d=>d.cwd),()=>M()),r.useEffect(()=>{const d=ft();d&&i(d);const T=I=>i(I.detail);return window.addEventListener("sm:select-persona",T),()=>window.removeEventListener("sm:select-persona",T)},[]);const N=le(d=>d.tab),F=le(d=>d.id),q=le(d=>d.clear);r.useEffect(()=>{if(N!=="agents"||!F||s===null)return;const d=F.startsWith("agents:")?F.slice(7):null;d&&s.some(T=>T.name===d)&&(n("personas"),m(""),f(null),u(!1),h(!1),S(null),i(d)),q()},[N,F,s,q]);const $=e.jsx(Je,{eyebrow:"AGENTS FOLDER",badge:s==null?void 0:s.length,path:"~/.claude/agents/",note:"The actor a session opens with — “you are acting as …”",children:e.jsx("div",{role:"group","aria-label":"Agents view","data-testid":"agent-view-switch",className:"mt-1 self-start inline-flex items-center p-0.5 rounded bg-bg-hi border border-line",children:ns.map(d=>e.jsx("button",{type:"button",onClick:()=>n(d.key),"aria-pressed":t===d.key,className:`px-2.5 py-0.5 text-[11px] rounded transition-colors ${t===d.key?"bg-bg text-fg font-medium shadow-sm":"text-fg-dim hover:text-fg"}`,children:d.label},d.key))})});if(t==="tags")return e.jsx("div",{className:"flex flex-col h-full min-h-0",children:e.jsx(Ce,{list:$,detail:e.jsx(Dn,{onOpenPersona:d=>{i(d),f(null),u(!1),n("personas")}})})});if(s===null)return e.jsx(Y,{title:"loading…"});const G=a.toLowerCase(),J=s.filter(d=>!G||d.name.toLowerCase().includes(G)||(d.description??"").toLowerCase().includes(G)),k=s.find(d=>d.name===o)??s[0]??null,C=g??(k?ve(k):null),X=!!g&&!!k&&JSON.stringify(g)!==JSON.stringify(ve(k)),z=x,Z=d=>{f(null),u(!1),h(!1),S(null),i(d)},p=d=>f(T=>({...T??(k?ve(k):Re),...d})),W=()=>{f({...Re}),u(!0),h(!1)},c=()=>{C&&(f({...C,name:C.name+"-copy"}),u(!0))},b=()=>{f(null),u(!1)},R=async()=>{if(C){if(!/^[a-z][a-z0-9-]*$/.test(C.name)){H.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}E(!0);try{const d=z?null:k,T={name:C.name,originalName:d==null?void 0:d.name,description:C.description,tools:C.tools,model:C.model,effort:C.effort,color:C.color,tags:Qe(C.tags),body:C.body,agentCli:C.agentCli,...C.agentCli!=="claude"&&C.agentCliModel.trim()?{agentCliModel:C.agentCliModel.trim()}:{}},I=d?Qn(d,T):T;"agentCliModel"in T||delete I.agentCliModel,await window.api.agents.savePersona(I),H.info(z?`created ${C.name}`:`saved ${C.name}`),f(null),u(!1),await M(C.name)}catch(d){H.error(d.message||"failed to save agent persona")}finally{E(!1)}}},U=async()=>{if(k){E(!0);try{await window.api.agents.deletePersona({name:k.name}),H.info(`deleted ${k.name}`),h(!1),f(null),u(!1),await M()}catch(d){H.error(d.message||"failed to delete agent persona")}finally{E(!1)}}},ee=async d=>{E(!0);try{await window.api.agents.deletePersona({name:d}),H.info(`deleted ${d}`),S(null),o===d&&(f(null),u(!1)),await M()}catch(T){H.error(T.message||"failed to delete agent persona")}finally{E(!1)}},te=async(d,T)=>{if(k)try{await window.api.agents.removeOverride({name:k.name,projectCwd:d}),H.info(`removed ${T}'s override of ${k.name}`),await M(k.name)}catch(I){H.error(I.message||"failed to remove override")}},B=async d=>{if(!k||!_)return;const{cwd:T,name:I}=_;E(!0);try{d.model==="inherit"&&d.effort==="inherit"?(await window.api.agents.removeOverride({name:k.name,projectCwd:T}),H.info(`cleared ${I}'s override of ${k.name}`)):(await window.api.agents.savePersona({name:k.name,projectCwd:T,description:"",tools:[],color:"",tags:[],body:"",model:d.model,effort:d.effort}),H.info(`saved ${I}'s override of ${k.name}`)),await M(k.name)}catch(v){H.error(v.message||"failed to save project override")}finally{E(!1)}},ne=e.jsxs(e.Fragment,{children:[$,e.jsx(ze,{filter:a,onFilterChange:m,placeholder:"Filter",primaryLabel:"+ New",onPrimary:W}),e.jsxs("div",{role:"listbox","aria-label":"Agents",className:"flex flex-col gap-0.5",children:[z&&C&&e.jsx("div",{"data-agent-row-new":"",children:e.jsx(ke,{title:C.name,trailing:e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"new"}),meta:C.description||void 0,selected:!0,onSelect:()=>{}})}),J.length===0&&!z?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):J.map(d=>{const T=!z&&d.name===(k==null?void 0:k.name),I=T&&X,v=w===d.name;return e.jsx("div",{"data-agent-row":d.name,className:"group",children:e.jsx(ke,{title:d.name,selected:T,onSelect:()=>Z(d.name),meta:d.description||void 0,trailing:e.jsxs("span",{className:"flex items-center gap-1.5",children:[I&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!I&&d.overridingProjects.length>0&&e.jsx("span",{title:ts(d),children:e.jsxs(We,{tone:"dim",children:[d.overridingProjects.length," override",d.overridingProjects.length>1?"s":""]})}),e.jsx("span",{"data-testid":"agent-row-model",className:"font-mono",children:d.model??"inherit"}),v?e.jsxs("span",{className:"flex items-center gap-1",onClick:V=>V.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:()=>ee(d.name),disabled:P,title:`Delete ${d.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{type:"button",onClick:()=>S(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),S(d.name)},title:`Delete ${d.name}`,"aria-label":`Delete ${d.name}`,className:"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})})},d.name)})]})]});return e.jsx("div",{className:"flex flex-col h-full min-h-0",children:e.jsx(Ce,{list:ne,detail:C?e.jsx(Gn,{obj:C,set:p,saved:k,dirty:X,isNew:z,busy:P,confirmDelete:y,setConfirmDelete:h,onDuplicate:c,onRevert:b,onSave:R,onDelete:U,onDropOverride:te,projects:j,selected:_,onSelect:L,onSaveOverride:B}):e.jsx(Y,{title:"select an agent"})})})}const as=r.memo(ss),ls={"claude-md":"system-prompt",settings:"settings",mcp:"extensions",skills:"extensions",plugins:"extensions",agents:"agent-library"},os={skills:"Add skill",mcp:"Add MCP server",plugins:"Add plugin"},ce=t=>t??void 0;async function Oe(t){try{return await t()}catch{return null}}function is(){const t=oe(),[n,s]=r.useState({claudeMd:null,settings:null}),l=r.useRef(0),o=t?`${t}/.claude/CLAUDE.md`:null,i=t?`${t}/.claude/settings.json`:null,a=r.useCallback(()=>{if(!o||!i)return;const m=++l.current;Promise.all([Oe(()=>Wt(o)),Oe(()=>Vt(i))]).then(([g,f])=>{m===l.current&&s({claudeMd:g,settings:f})})},[o,i]);return r.useEffect(()=>(a(),()=>{l.current++}),[a]),ae([o,i],a),n}const rs=()=>Kt({scope:"home",cwd:null,api:window.api});function cs({initialTab:t="claude-md"}){const[n,s]=r.useState(t),[l,o]=r.useState(!1),[i,a]=r.useState(!1),[m,g]=r.useState({scope:"user",cwd:null}),f=sn(),{personas:x}=Se(),u=is(),y=Pt(Tt),h=r.useMemo(()=>At(y),[y]),w=ye(N=>N.panelTabHint);r.useEffect(()=>{if(!w||w.id!=="claude-config")return;const[N,F]=w.tab.split(":");Pe(N)&&(s(N),o(!1)),ye.setState({panelTabHint:N==="settings"&&F?{id:"settings",tab:F}:null})},[w]);const S=r.useCallback(N=>{s(N),o(!1)},[]),P=r.useCallback(()=>o(!1),[]),E=r.useCallback(()=>o(!0),[]),O=r.useCallback(N=>{g(N),o(!0)},[]),A=r.useCallback(()=>a(N=>!N),[]),j=r.useCallback(N=>{Pe(N.tab)&&(S(N.tab),le.getState().set(N.tab,N.id))},[S]),D=Dt({load:rs,loadKey:"home",onChoose:j}),L=r.useMemo(()=>{const N={"claude-md":Rt(u.claudeMd),settings:{count:ce(u.settings)},mcp:{count:ce(f.mcp),attention:h},skills:{count:ce(f.skills)},plugins:{count:ce(f.plugins)},agents:{count:ce(x==null?void 0:x.length)}};return mt.map(F=>({...F,...N[F.key]}))},[u.claudeMd,u.settings,f.mcp,f.skills,f.plugins,x,h]),_=pt[ls[n]],M=n==="skills"||n==="mcp"||n==="plugins"?n:null;return e.jsxs("div",{className:"h-full w-full flex flex-col bg-bg text-fg","data-testid":"home-claude-config",children:[e.jsx(It,{eyebrow:"CLAUDE CODE · GLOBAL",title:"Claude config",scopePath:"~/.claude",tabs:L,activeKey:n,onSelect:S,onLearn:A,...D.bandProps,searchPanel:e.jsx(Ot,{...D.panelProps,tabs:L})}),i&&_&&e.jsx("div",{className:"shrink-0 border-b border-line bg-bg-elev px-7 py-4 max-h-[40vh] overflow-y-auto","data-testid":"home-claude-config-learn",children:e.jsx(gt,{content:_})}),e.jsxs("div",{className:"flex-1 min-h-0 px-8 py-6","data-testid":`home-claude-config-panel-${n}`,children:[n==="claude-md"&&e.jsx(rn,{}),n==="settings"&&e.jsx(Ft,{scope:"user"}),n==="mcp"&&e.jsx(_t,{onAdd:O,scope:"user"}),n==="skills"&&e.jsx(Bt,{onAdd:E,scope:"user"}),n==="plugins"&&e.jsx(Ln,{onAdd:E,onJump:S}),n==="agents"&&e.jsx(as,{})]}),M&&e.jsxs(xt,{open:l,onClose:P,title:os[M],keyVals:[],children:[M==="skills"&&e.jsx(Ut,{}),M==="mcp"&&e.jsx(Ht,{scope:m.scope,cwd:m.cwd}),M==="plugins"&&e.jsx(Gt,{})]})]})}const xs=r.memo(cs);export{xs as HomeClaudeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aB as e}from"./index-CtxruO1L.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};
|