claude-code-session-manager 0.131.0 → 0.133.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +3 -3
  2. package/dist/assets/{AgentLibrary-CYXre0J-.js → AgentLibrary-DOAG-mcG.js} +1 -1
  3. package/dist/assets/{AppSettings-xNSfCj8e.js → AppSettings-BHKM_AKh.js} +2 -2
  4. package/dist/assets/{Button-BWljh5IK.js → Button-CmO1wmPw.js} +1 -1
  5. package/dist/assets/{DocumentEditorPane-FUC2hZlp.js → DocumentEditorPane-8QMNrNRt.js} +1 -1
  6. package/dist/assets/{Extensions-CsyUoklz.js → Extensions-Boo21B3b.js} +2 -2
  7. package/dist/assets/{History-BvNmY9OQ.js → History-C4epd1hp.js} +1 -1
  8. package/dist/assets/{Library-DVXk77zA.js → Library-CrgzRQzL.js} +1 -1
  9. package/dist/assets/{ListDetail-DAAx__24.js → ListDetail-DA7y1DQ-.js} +1 -1
  10. package/dist/assets/{Panel-g2D-e-RM.js → Panel-D-WMBhKH.js} +1 -1
  11. package/dist/assets/{ProjectClaudeConfig-BDuHJwaO.js → ProjectClaudeConfig-CuUADpIu.js} +1 -1
  12. package/dist/assets/{ProvenanceBadge-wew4_nf3.js → ProvenanceBadge-B7AsoRk6.js} +1 -1
  13. package/dist/assets/{Scheduler-CbeUIqD-.js → Scheduler-C86gRh51.js} +1 -1
  14. package/dist/assets/{Settings-B23RsRfm.js → Settings-B4Q9DwVS.js} +1 -1
  15. package/dist/assets/{SkillReferenceGraph-BxQPCfsg.js → SkillReferenceGraph-DX4ZgvlY.js} +1 -1
  16. package/dist/assets/{Skills-4AR2FQrI.js → Skills-DqKI37yi.js} +1 -1
  17. package/dist/assets/{SourceChip-jrC0vjfw.js → SourceChip-C974LROr.js} +1 -1
  18. package/dist/assets/{SystemPrompt-hHoBEnYb.js → SystemPrompt-C502jIwO.js} +1 -1
  19. package/dist/assets/{TiptapBody-FkUqxO9u.js → TiptapBody-DwNXN6Ki.js} +1 -1
  20. package/dist/assets/{Toggle-DQMNWZKT.js → Toggle-C2OsxnPK.js} +1 -1
  21. package/dist/assets/{ViewTabs-DGU0ZuxB.js → ViewTabs-DBxKGbAK.js} +1 -1
  22. package/dist/assets/{VoiceButton-BPPvDllh.js → VoiceButton-C680wpmX.js} +1 -1
  23. package/dist/assets/{historyTotals-D8Oc3wUK.js → historyTotals-Cz-VYPEc.js} +1 -1
  24. package/dist/assets/{index-oXqzajWV.css → index-CMwAikUb.css} +1 -1
  25. package/dist/assets/index-Dh5geJe3.js +3111 -0
  26. package/dist/index.html +2 -2
  27. package/dist-web/app.css +1 -1
  28. package/dist-web/app.js +428 -414
  29. package/package.json +1 -1
  30. package/scripts/scheduler-mcp-server.cjs +12 -4
  31. package/src/main/build-info.json +4 -4
  32. package/src/main/chatRunner.cjs +77 -14
  33. package/src/main/index.cjs +15 -0
  34. package/src/main/ipcSchemas.cjs +54 -0
  35. package/src/main/lib/CLAUDE.md +2 -0
  36. package/src/main/lib/agent-cli/adapters/antigravity.cjs +147 -0
  37. package/src/main/lib/agent-cli/adapters/codex.cjs +170 -0
  38. package/src/main/lib/agent-cli/adapters/cursor.cjs +138 -0
  39. package/src/main/lib/agent-cli/adapters/gemini.cjs +119 -0
  40. package/src/main/lib/agent-cli/adapters/opencode.cjs +117 -0
  41. package/src/main/lib/agent-cli/agentCliEvents.cjs +94 -0
  42. package/src/main/lib/agent-cli/agentCliIpc.cjs +109 -0
  43. package/src/main/lib/agent-cli/agentCliRegistry.cjs +213 -0
  44. package/src/main/lib/agent-cli/agentCliSessionStore.cjs +152 -0
  45. package/src/main/lib/agent-cli/agentCliTurn.cjs +99 -0
  46. package/src/main/lib/app-preview/appPreviewIpc.cjs +125 -0
  47. package/src/main/lib/app-preview/appPreviewManager.cjs +317 -0
  48. package/src/main/lib/app-preview/appPreviewScripts.cjs +106 -0
  49. package/src/main/lib/app-preview/appPreviewSweep.cjs +92 -0
  50. package/src/main/lib/chatBootRecovery.cjs +41 -1
  51. package/src/main/lib/claude/agentEffortResolve.cjs +11 -3
  52. package/src/main/lib/epic/activeIndexMerge.cjs +25 -2
  53. package/src/main/lib/epic/archivedTranscript.cjs +39 -6
  54. package/src/main/lib/epic/epicChanges.cjs +466 -0
  55. package/src/main/lib/epic/epicMint.cjs +45 -1
  56. package/src/main/lib/epic/epicReopen.cjs +8 -2
  57. package/src/main/lib/epic/epicSpawnPlan.cjs +12 -0
  58. package/src/main/lib/epic/epicWorktreeMerge.cjs +39 -4
  59. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +9 -4
  60. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +36 -13
  61. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
  62. package/src/main/lib/git/gitExec.cjs +9 -1
  63. package/src/main/lib/git/gitWorktree.cjs +94 -0
  64. package/src/main/lib/git/unifiedDiff.cjs +207 -0
  65. package/src/main/lib/mcpToolCatalog.cjs +15 -6
  66. package/src/main/lib/mdDocCensus.cjs +364 -0
  67. package/src/main/lib/mdDocRefs.cjs +249 -0
  68. package/src/main/lib/mdNetworkScan.cjs +158 -15
  69. package/src/main/lib/persona-macro/builtinMacros.cjs +17 -0
  70. package/src/main/lib/persona-macro/macroJobDispatch.cjs +4 -1
  71. package/src/main/lib/persona-macro/macroJobIpc.cjs +57 -11
  72. package/src/main/lib/persona-macro/macroLibrary.cjs +40 -10
  73. package/src/main/lib/prd/prdCreate.cjs +7 -2
  74. package/src/main/lib/prd/prdFrontmatter.cjs +10 -3
  75. package/src/main/lib/promptSessionSchema.cjs +6 -0
  76. package/src/main/lib/remoteTranscriptTail.cjs +23 -4
  77. package/src/main/lib/scheduler/landedSinceRun.cjs +2 -1
  78. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  79. package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
  80. package/src/main/projectPages.cjs +19 -4
  81. package/src/main/promptSessionEvents.cjs +10 -6
  82. package/src/main/scheduler/gitTreeGuard.cjs +2 -1
  83. package/src/main/scheduler/prdParser.cjs +2 -1
  84. package/src/main/scheduler.cjs +7 -2
  85. package/src/main/transcripts.cjs +18 -4
  86. package/src/main/webRemote.cjs +10 -5
  87. package/src/preload/api.d.ts +150 -3
  88. package/src/preload/apiSurface.json +56 -0
  89. package/src/preload/index.cjs +22 -0
  90. package/dist/assets/index-9ajPMXBg.js +0 -3097
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # claude-code-session-manager
2
2
 
3
- Local cockpit for the Claude Code CLI — multi-tab terminal, configuration surface, scheduler, voice dictation, and live observability, all in one Electron desktop app.
3
+ Local cockpit for the Claude Code CLI (the default; sessions can also run Codex, Gemini CLI, Antigravity CLI, Cursor Agent or OpenCode) — multi-tab terminal, configuration surface, scheduler, voice dictation, and live observability, all in one Electron desktop app.
4
4
 
5
5
  ## The 30-second pitch
6
6
 
7
- You already use the `claude` CLI. This wraps it in a cockpit so you can run multiple sessions at once, edit every config file Claude Code reads, queue overnight work as PRDs, talk to it with your microphone, and watch transcripts in real time — without ever leaving the window.
7
+ You already use the `claude` CLI. This wraps it in a cockpit so you can run multiple sessions at once, edit every config file Claude Code reads, queue overnight work as PRDs, talk to it with your microphone, and watch transcripts in real time — without ever leaving the window. Claude Code is the default. A session can also run Codex, Gemini CLI, Antigravity CLI, Cursor Agent or OpenCode instead, in Chat and Terminal; macros, phone launches and scheduled PRDs stay on Claude Code.
8
8
 
9
9
  New tabs open as a lightweight **chat box** and stay dormant — no PTY, no `claude` process — until you actually send a message, so a window full of tabs costs almost nothing. Prefer a single bare terminal? Launch with `--simple`.
10
10
 
@@ -59,7 +59,7 @@ Linux needs `build-essential` and `python3` in that case.
59
59
  **Anonymous product telemetry is on by default.** It posts event, log, error, and crash records to bilko.run. Opt out with `SM_TELEMETRY=0` or Settings → Telemetry. Details: [telemetry.md](session-manager-operations/architecture/telemetry.md).
60
60
 
61
61
  - The Content-Security-Policy restricts `connect-src` to four hosts: `api.anthropic.com` (so the in-app `/usage` panel can read the billing endpoint), `registry.npmjs.org`, `json.schemastore.org`, and `www.schemastore.org`.
62
- - All settings, skills, hooks, scheduler PRDs, transcripts, and voice configuration stay on disk under `~/.claude/`. The `claude` CLI itself is the only network egress for AI work — the cockpit never proxies your prompts.
62
+ - All settings, skills, hooks, scheduler PRDs, transcripts, and voice configuration stay on disk under `~/.claude/`. The agent CLI you choose (`claude` by default) is the only network egress for AI work — the cockpit never proxies your prompts.
63
63
  - The recording-status pill is always mounted at the top of the window whenever the microphone is hot, above every other UI layer. There is no way to record without seeing the indicator.
64
64
 
65
65
  ## Voice setup
@@ -1,2 +1,2 @@
1
- import{be as J,b9 as Ne,aN as v,Z as A,b6 as ne,b4 as C,ax as e,l as H,b3 as Y,a7 as Ce,aC as M,bp as $e,b as I,aD as ke,aK as Se,b1 as Le,bh as se,M as De,d as U,E as Ee,a9 as Te}from"./index-9ajPMXBg.js";import{P as ae}from"./Panel-g2D-e-RM.js";import{L as oe}from"./ListDetail-DAAx__24.js";import{V as Oe}from"./ViewTabs-DGU0ZuxB.js";import{S as re}from"./SourceChip-jrC0vjfw.js";import{B as R}from"./Button-BWljh5IK.js";import{r as Pe}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";function ie(t,a){const s=J();Ne([s?`${s}/.claude/agents`:null,...t.map(i=>`${i}/.claude/agents`)],a)}function Re({onOpenPersona:t}){const[a,s]=v.useState(A[0].tag),{personas:i,refresh:d}=ne(r=>C.error(r.message||"failed to load agent personas"));ie([],()=>{d()});const f=A.find(r=>r.tag===a)??null;return e.jsx(ae,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[A.length," tag",A.length===1?"":"s"]}),children:e.jsx(oe,{sidebar:e.jsx("div",{className:"py-1",children:A.map(r=>{const p=Y(r.tag),y=a===r.tag,m=(i==null?void 0:i.filter(h=>h.tags.includes(r.tag)).length)??0;return e.jsxs("button",{onClick:()=>{s(r.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${y?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${p.bg} ${p.text} ${p.border?"border border-current/30":""}`,children:["#",r.tag]}),e.jsx("span",{className:"truncate",children:r.label}),m>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:m})]},r.tag)})}),detail:f?e.jsx(Fe,{entry:f,personas:i,onOpenPersona:t}):e.jsx(H,{title:"select a tag"})})})}const Ae=v.memo(Re);function Fe({entry:t,personas:a,onOpenPersona:s}){const i=Y(t.tag),d=Ce(t.tag),f=(a==null?void 0:a.filter(r=>r.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 ${i.bg} ${i.text} ${i.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"}),a===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:[f.map(r=>e.jsx("button",{onClick:()=>s==null?void 0:s(r.name),title:`Open ${r.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:r.name},r.name)),f.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:d.initialPromptTemplate})]})]})}const Be=new Set(A.map(t=>t.tag));function le(t){return t.filter(a=>Be.has(a))}function Me(t,a={}){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:le(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...a}}const Ve=t=>{const[a,s]=t.split(".");return Number(a)+(s?Number(s)/100:0)};function We(t){const a=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!a)return[];const s=[];for(const i of a[1].split(/,\s*|\s+and\s+/)){const d=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(i.trim());d&&s.push({family:d[1].toLowerCase(),version:Ve(d[2])})}return s}var ee,te;const Ie=We(String(((te=(ee=Pe.properties)==null?void 0:ee.effortLevel)==null?void 0:te.description)??""));function Ke(t,a){const s=new RegExp(`${a}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(s)return Number(s[1])+(s[2]?Number(s[2])/100:0);const i=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${a}`,"i").exec(t);return i?Number(i[1])+(i[2]?Number(i[2])/100:0):null}function _e(t,a=Ie){if(!t||t==="inherit"||a.length===0)return null;const s=M(t);if(!s)return null;const i=a.filter(f=>f.family===s);if(i.length===0)return!1;const d=Ke(t,s);return d===null?null:d>=Math.min(...i.map(f=>f.version))}const q=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Ge=["","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 G(t){return{name:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??"inherit",color:t.color??"",tags:t.tags,body:t.body}}const Q={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""};function ze(t){const a=new Map;for(const s of t){const i=typeof s.cwd=="string"?ke(s.cwd):"";i&&!a.has(i)&&a.set(i,{cwd:i,name:Se(i)})}return[...a.values()].sort((s,i)=>s.name.localeCompare(i.name)||s.cwd.localeCompare(i.cwd))}function ce(t){return[...t.fields.filter(a=>a!=="name"),...t.bodyOverridden?["full body"]:[]]}function He(t){return(t.overrideDetails??[]).map(a=>`${a.project}: ${ce(a).join(", ")||"overlay"}`).join(`
1
+ import{be as J,b9 as Ne,aN as v,Z as A,b6 as ne,b4 as C,ax as e,l as H,b3 as Y,a7 as Ce,aC as M,bp as $e,b as I,aD as ke,aK as Se,b1 as Le,bh as se,M as De,d as U,E as Ee,a9 as Te}from"./index-Dh5geJe3.js";import{P as ae}from"./Panel-D-WMBhKH.js";import{L as oe}from"./ListDetail-DA7y1DQ-.js";import{V as Oe}from"./ViewTabs-DBxKGbAK.js";import{S as re}from"./SourceChip-C974LROr.js";import{B as R}from"./Button-CmO1wmPw.js";import{r as Pe}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";function ie(t,a){const s=J();Ne([s?`${s}/.claude/agents`:null,...t.map(i=>`${i}/.claude/agents`)],a)}function Re({onOpenPersona:t}){const[a,s]=v.useState(A[0].tag),{personas:i,refresh:d}=ne(r=>C.error(r.message||"failed to load agent personas"));ie([],()=>{d()});const f=A.find(r=>r.tag===a)??null;return e.jsx(ae,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[A.length," tag",A.length===1?"":"s"]}),children:e.jsx(oe,{sidebar:e.jsx("div",{className:"py-1",children:A.map(r=>{const p=Y(r.tag),y=a===r.tag,m=(i==null?void 0:i.filter(h=>h.tags.includes(r.tag)).length)??0;return e.jsxs("button",{onClick:()=>{s(r.tag)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${y?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${p.bg} ${p.text} ${p.border?"border border-current/30":""}`,children:["#",r.tag]}),e.jsx("span",{className:"truncate",children:r.label}),m>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:m})]},r.tag)})}),detail:f?e.jsx(Fe,{entry:f,personas:i,onOpenPersona:t}):e.jsx(H,{title:"select a tag"})})})}const Ae=v.memo(Re);function Fe({entry:t,personas:a,onOpenPersona:s}){const i=Y(t.tag),d=Ce(t.tag),f=(a==null?void 0:a.filter(r=>r.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 ${i.bg} ${i.text} ${i.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"}),a===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:[f.map(r=>e.jsx("button",{onClick:()=>s==null?void 0:s(r.name),title:`Open ${r.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:r.name},r.name)),f.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:d.initialPromptTemplate})]})]})}const Be=new Set(A.map(t=>t.tag));function le(t){return t.filter(a=>Be.has(a))}function Me(t,a={}){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:le(t.tags),projects:t.projects,action:t.action??void 0,actionLabel:t.actionLabel??void 0,title:t.title??void 0,body:t.body,...a}}const Ve=t=>{const[a,s]=t.split(".");return Number(a)+(s?Number(s)/100:0)};function We(t){const a=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(t);if(!a)return[];const s=[];for(const i of a[1].split(/,\s*|\s+and\s+/)){const d=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(i.trim());d&&s.push({family:d[1].toLowerCase(),version:Ve(d[2])})}return s}var ee,te;const Ie=We(String(((te=(ee=Pe.properties)==null?void 0:ee.effortLevel)==null?void 0:te.description)??""));function Ke(t,a){const s=new RegExp(`${a}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(t);if(s)return Number(s[1])+(s[2]?Number(s[2])/100:0);const i=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${a}`,"i").exec(t);return i?Number(i[1])+(i[2]?Number(i[2])/100:0):null}function _e(t,a=Ie){if(!t||t==="inherit"||a.length===0)return null;const s=M(t);if(!s)return null;const i=a.filter(f=>f.family===s);if(i.length===0)return!1;const d=Ke(t,s);return d===null?null:d>=Math.min(...i.map(f=>f.version))}const q=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Ge=["","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 G(t){return{name:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",effort:t.effort??"inherit",color:t.color??"",tags:t.tags,body:t.body}}const Q={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""};function ze(t){const a=new Map;for(const s of t){const i=typeof s.cwd=="string"?ke(s.cwd):"";i&&!a.has(i)&&a.set(i,{cwd:i,name:Se(i)})}return[...a.values()].sort((s,i)=>s.name.localeCompare(i.name)||s.cwd.localeCompare(i.cwd))}function ce(t){return[...t.fields.filter(a=>a!=="name"),...t.bodyOverridden?["full body"]:[]]}function He(t){return(t.overrideDetails??[]).map(a=>`${a.project}: ${ce(a).join(", ")||"overlay"}`).join(`
2
2
  `)}function Ue(){const[t,a]=v.useState("personas"),{personas:s,refresh:i}=ne(n=>C.error(n.message||"failed to load agent personas")),[d,f]=v.useState(null),[r,p]=v.useState(""),[y,m]=v.useState(null),[h,x]=v.useState(!1),[N,L]=v.useState(!1),[j,S]=v.useState(null),[D,w]=v.useState(!1),c=v.useRef(!0);v.useEffect(()=>()=>{c.current=!1},[]);const b=$e(n=>n.tabs),o=v.useMemo(()=>ze(b),[b]),[$,k]=v.useState(null),T=o.find(n=>n.cwd===$)??null,O=async n=>{await i()&&n&&f(n)};ie(o.map(n=>n.cwd),()=>O()),v.useEffect(()=>{const n=Le();n&&f(n);const u=E=>f(E.detail);return window.addEventListener("sm:select-persona",u),()=>window.removeEventListener("sm:select-persona",u)},[]);const V=e.jsx(Oe,{options:[{key:"personas",label:"Personas"},{key:"tags",label:"Tags"}],active:t,onChange:a});if(t==="tags")return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-line",children:V}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ae,{onOpenPersona:n=>{f(n),m(null),x(!1),a("personas")}})})]});if(s===null)return e.jsx(H,{title:"loading…"});const F=r.toLowerCase(),W=s.filter(n=>!F||n.name.toLowerCase().includes(F)||(n.description??"").toLowerCase().includes(F)),l=s.find(n=>n.name===d)??s[0]??null,g=y??(l?G(l):null),Z=!!y&&!!l&&JSON.stringify(y)!==JSON.stringify(G(l)),B=h,xe=n=>{m(null),x(!1),L(!1),S(null),f(n)},ge=n=>m(u=>({...u??(l?G(l):Q),...n})),he=()=>{m({...Q}),x(!0),L(!1)},pe=()=>{g&&(m({...g,name:g.name+"-copy"}),x(!0))},ue=()=>{m(null),x(!1)},be=async()=>{if(g){if(!/^[a-z][a-z0-9-]*$/.test(g.name)){C.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}w(!0);try{const n=B?null:l,u={name:g.name,originalName:n==null?void 0:n.name,description:g.description,tools:g.tools,model:g.model,effort:g.effort,color:g.color,tags:le(g.tags),body:g.body},E=n?Me(n,u):u;await window.api.agents.savePersona(E),C.info(B?`created ${g.name}`:`saved ${g.name}`),m(null),x(!1),await O(g.name)}catch(n){C.error(n.message||"failed to save agent persona")}finally{w(!1)}}},ve=async()=>{if(l){w(!0);try{await window.api.agents.deletePersona({name:l.name}),C.info(`deleted ${l.name}`),L(!1),m(null),x(!1),await O()}catch(n){C.error(n.message||"failed to delete agent persona")}finally{w(!1)}}},je=async n=>{w(!0);try{await window.api.agents.deletePersona({name:n}),C.info(`deleted ${n}`),S(null),d===n&&(m(null),x(!1)),await O()}catch(u){C.error(u.message||"failed to delete agent persona")}finally{w(!1)}},we=async(n,u)=>{if(l)try{await window.api.agents.removeOverride({name:l.name,projectCwd:n}),C.info(`removed ${u}'s override of ${l.name}`),await O(l.name)}catch(E){C.error(E.message||"failed to remove override")}},ye=async n=>{if(!l||!T)return;const{cwd:u,name:E}=T;w(!0);try{n.model==="inherit"&&n.effort==="inherit"?(await window.api.agents.removeOverride({name:l.name,projectCwd:u}),C.info(`cleared ${E}'s override of ${l.name}`)):(await window.api.agents.savePersona({name:l.name,projectCwd:u,description:"",tools:[],color:"",tags:[],body:"",model:n.model,effort:n.effort}),C.info(`saved ${E}'s override of ${l.name}`)),await O(l.name)}catch(K){C.error(K.message||"failed to save project override")}finally{w(!1)}};return e.jsx(ae,{toolbar:e.jsxs(e.Fragment,{children:[V,e.jsxs("span",{className:"text-fg-faint",children:[s.length," persona",s.length===1?"":"s"]}),e.jsx("input",{value:r,onChange:n=>p(n.target.value),placeholder:"filter…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-40"}),e.jsx("div",{className:"flex-1"}),e.jsx(R,{variant:"primary",onClick:he,children:"+ New agent"})]}),children:e.jsx(oe,{sidebar:e.jsxs("div",{className:"py-1",children:[B&&e.jsx("div",{className:"w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 bg-bg-hi text-fg border-l-2 border-accent",children:e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsx("span",{className:"truncate font-mono",children:g==null?void 0:g.name}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-accent",children:"new"})]})}),W.length===0&&!B?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):W.map(n=>{const u=!B&&n.name===d,E=u&&Z,K=j===n.name;return e.jsxs("div",{"data-agent-row":n.name,className:`group w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 border-l-2 cursor-pointer ${u?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,onClick:()=>xe(n.name),children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:n.color?de[n.color]??n.color:"var(--fg-faint, #999)",opacity:n.color?1:.35}}),e.jsx("span",{className:"truncate font-mono",children:n.name})]}),e.jsxs("span",{className:"shrink-0 flex items-center gap-1.5",children:[E&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!E&&n.overridingProjects.length>0&&e.jsx("span",{title:He(n),children:e.jsxs(I,{tone:"dim",children:[n.overridingProjects.length," override",n.overridingProjects.length>1?"s":""]})}),K?e.jsxs("span",{className:"flex items-center gap-1",onClick:_=>_.stopPropagation(),children:[e.jsx("button",{onClick:()=>je(n.name),disabled:D,title:`Delete ${n.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>S(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{onClick:_=>{_.stopPropagation(),S(n.name)},title:`Delete ${n.name}`,className:"opacity-0 group-hover:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})]}),n.description&&e.jsx("span",{className:"truncate text-fg-faint",children:n.description})]},n.name)})]}),detail:g?e.jsx(Je,{obj:g,set:ge,saved:l,dirty:Z,isNew:B,busy:D,confirmDelete:N,setConfirmDelete:L,onDuplicate:pe,onRevert:ue,onSave:be,onDelete:ve,onDropOverride:we,projects:o,selected:T,onSelect:k,onSaveOverride:ye}):e.jsx(H,{title:"select an agent"})})})}const at=v.memo(Ue);function Je({obj:t,set:a,saved:s,dirty:i,isNew:d,busy:f,confirmDelete:r,setConfirmDelete:p,onDuplicate:y,onRevert:m,onSave:h,onDelete:x,onDropOverride:N,projects:L,selected:j,onSelect:S,onSaveOverride:D}){const w=J(),c=!d&&s?s.path:`${w??"~"}/.claude/agents/${t.name}.md`,b=i||d;return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-line flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-fg font-mono",children:t.name}),d?e.jsx(I,{tone:"accent",children:"unsaved draft"}):i?e.jsx(I,{tone:"warn",children:"edited"}):e.jsx(I,{tone:"good",children:"saved"}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(re,{path:c})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(P,{label:"name",hint:"Filename on disk — lowercase, hyphenated.",children:e.jsx("input",{value:t.name,onChange:o=>a({name:o.target.value.toLowerCase()}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})}),e.jsx(P,{label:"description",hint:"Shown in the list and in agent pickers.",children:e.jsx("input",{value:t.description,onChange:o=>a({description:o.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})}),e.jsx(fe,{value:t.model,onChange:o=>a({model:o})}),e.jsx(me,{value:t.effort,model:t.model,onChange:o=>a({effort:o})}),!d&&s&&e.jsx(Ye,{saved:s,projects:L,selected:j,onSelect:S,busy:f,onSave:D}),e.jsx(P,{label:"tools",hint:`${t.tools.length} of ${q.length} granted. Anything not ticked is refused at call time.`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:q.map(o=>{const $=t.tools.includes(o);return e.jsx("button",{onClick:()=>a({tools:$?t.tools.filter(k=>k!==o):[...t.tools,o]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${$?"bg-sage/15 text-sage-dark border-sage/30":"bg-bg-hi text-fg-faint border-line"}`,children:o},o)})})}),e.jsx(P,{label:"color",children:e.jsx("div",{className:"flex gap-1.5",children:Ge.map(o=>e.jsx("button",{title:o||"none",onClick:()=>a({color:o}),className:"w-5 h-5 rounded",style:{background:o?de[o]:"transparent",border:t.color===o?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},o||"none"))})}),e.jsx(P,{label:"tags",hint:"Session mission tags this persona is associated with — shown as the default agent on the Tags tab.",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:A.map(o=>{const $=t.tags.includes(o.tag),k=Y(o.tag);return e.jsxs("button",{onClick:()=>a({tags:$?t.tags.filter(T=>T!==o.tag):[...t.tags,o.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${$?`${k.bg} ${k.text} ${k.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",o.tag]},o.tag)})})}),e.jsx(P,{label:"definition",hint:"The system prompt this persona runs under.",children:e.jsx("textarea",{rows:9,value:t.body,onChange:o=>a({body:o.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono leading-relaxed resize-y"})}),e.jsx(P,{label:"project overrides",hint:"Open projects that shadow this definition with a local copy.",children:s&&(s.overrideDetails??[]).length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:(s.overrideDetails??[]).map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[o.project,e.jsx("button",{onClick:()=>N(o.cwd,o.project),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},o.cwd))}):e.jsx("div",{className:"text-xs text-fg-faint italic",children:d?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere."})})]}),e.jsx("div",{className:"px-4 py-2.5 border-t border-line flex items-center gap-2 flex-wrap",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:["Delete ",e.jsx("strong",{className:"font-mono",children:t.name})," and its file?"]}),e.jsx(R,{variant:"danger",onClick:x,disabled:f,children:"Delete"}),e.jsx(R,{onClick:()=>p(!1),children:"Keep"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:y,disabled:f,children:"Duplicate"}),!d&&e.jsx(R,{variant:"danger",onClick:()=>p(!0),disabled:f,children:"Delete"}),e.jsx("div",{className:"flex-1"}),b&&e.jsx("span",{className:"text-[11px] text-fg-faint",children:"unsaved changes"}),e.jsx(R,{onClick:m,disabled:!b||f,children:"Revert"}),e.jsx(R,{variant:"primary",onClick:h,disabled:!b||f,children:f?"Saving…":d?"Create":"Save"})]})})]})}function P({label:t,hint:a,children:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:t}),s,a&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:a})]})}const z="latest",X="Blocked by the availableModels allowlist in your Claude settings";function fe({value:t,onChange:a,label:s="default model",hint:i,testIdPrefix:d="",inheritLabel:f}){var F,W;const{catalog:r,loading:p,degraded:y,refresh:m}=se(null),h=r?["inherit",...r.aliases]:[...De],x=(r==null?void 0:r.availableModels)??null,N=l=>!!x&&l!=="inherit"&&!x.includes(l),L=(l,g)=>!!x&&!x.includes(l)&&!(g&&x.includes(g)),j=t||"inherit",S=((F=/\[[^\]]*\]$/.exec(j))==null?void 0:F[0])??"",D=h.includes(j),w=!D&&r&&M(j)&&h.includes(M(j)+S)?M(j)+S:null,c=D?j:w??j,b=M(c),o=((W=/\[[^\]]*\]$/.exec(c))==null?void 0:W[0])??"",$=!!r&&j!=="inherit"&&!!b&&h.includes(c),k=$?r.models.filter(l=>M(l)===b).map(l=>l+o):[],T=D?z:j,O={};if(r)for(const l of h)N(l)&&(O[l]=X);const V={};for(const l of k)L(l,b)&&(V[l]=X);return e.jsxs(P,{label:s,hint:i??"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":`${d}model-row`,children:e.jsx(U,{options:h,value:c,onChange:a,mono:!0,blocked:O,labels:f?{inherit:f}:void 0})}),$&&e.jsxs("div",{className:"mt-2","data-testid":`${d}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(U,{options:[z,...k],value:T,onChange:l=>a(l===z?c:l),mono:!0,blocked:V})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:r?`Models are live-read from the installed claude CLI${y?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:p?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${d}model-catalog-refresh`,onClick:()=>{m()},disabled:p,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function me({value:t,model:a,onChange:s,label:i="effort",testIdPrefix:d="",inheritLabel:f}){const{catalog:r}=se(null),p=r&&r.effortLevels.length?["inherit",...r.effortLevels]:[...Ee],y=(r==null?void 0:r.settingsEffortLevels)??[],m=r?p.filter(N=>N!=="inherit"&&!y.includes(N)):[],h=t||"inherit",x=h!=="inherit"&&_e(a)===!1;return e.jsxs(P,{label:i,hint:r?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${m.length?`${m.join(", ")} ${m.length>1?"are":"is"} session-only — settings.json accepts ${y.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${d}effort-row`,children:e.jsx(U,{options:p,value:h,onChange:s,mono:!0,labels:f?{inherit:f}:void 0})}),m.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${d}effort-session-only`,children:m.map(N=>`${N} (session-only)`).join(" · ")}),x&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${d}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Ye({saved:t,projects:a,selected:s,onSelect:i,busy:d,onSave:f}){var S,D,w;const r=J(),p=new Map;for(const c of a)p.set(c.name,(p.get(c.name)??0)+1);const y=c=>{var k;const b=(p.get(c.name)??0)>1?Te(c.cwd,r):c.name,o=(k=t.overrideDetails)==null?void 0:k.find(T=>T.cwd===c.cwd);if(!o)return b;const $=ce(o);return`${b} — ${$.length?`overrides ${$.join(", ")}`:"overlay"}`},m=s?(S=t.overrideDetails)==null?void 0:S.find(c=>c.cwd===s.cwd):void 0,h=!!(m!=null&&m.bodyOverridden),x=((D=m==null?void 0:m.values)==null?void 0:D.model)??"inherit",N=((w=m==null?void 0:m.values)==null?void 0:w.effort)??"inherit",L=t.model??"inherit",j=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("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:`text-[10.5px] font-semibold uppercase tracking-wide font-mono ${s?"text-accent":"text-fg-faint"}`,children:"project override"}),e.jsxs("select",{"data-testid":"override-project-select",value:(s==null?void 0:s.cwd)??"",onChange:c=>i(c.target.value||null),disabled:d||a.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…"}),a.map(c=>e.jsx("option",{value:c.cwd,children:y(c)},c.cwd))]})]}),a.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(I,{tone:"accent",children:[s.name," only"]}),e.jsx("span",{className:"ml-auto min-w-0",children:e.jsx(re,{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."]}),h&&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 × under "project overrides" below.']}),e.jsxs("fieldset",{disabled:d||h,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(fe,{value:x,onChange:c=>{h||f({model:c,effort:N})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(me,{value:N,model:x!=="inherit"?x:L,onChange:c=>{h||f({model:x,effort:c})},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",L,x],["effort",j,N]].map(([c,b,o])=>e.jsxs("div",{"data-testid":`override-provenance-${c}`,children:[c,": ",o!=="inherit"?e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:o})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},c))})]}):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."})]})}export{at as AgentLibrary};