claude-code-session-manager 0.107.0 → 0.109.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/dist/assets/AgentLibrary-Br4Ispr4.js +2 -0
- package/dist/assets/{Button-CRLhoI2K.js → Button-C8Mc6MEP.js} +1 -1
- package/dist/assets/DataModel-Bz0MypYO.js +1 -0
- package/dist/assets/History-DT26Iy38.js +2 -0
- package/dist/assets/Hooks-e4xUGEf-.js +3 -0
- package/dist/assets/{Library-rqaJJJ1b.js → Library-B3rzEhvN.js} +24 -24
- package/dist/assets/{ListDetail-qI27OYfy.js → ListDetail-BAvci_aP.js} +1 -1
- package/dist/assets/{MarkdownEditor-BEFuHVNz.js → MarkdownEditor-DBWTGgRz.js} +1 -1
- package/dist/assets/{McpServers-Bz9O79rz.js → McpServers-C-grBN21.js} +2 -2
- package/dist/assets/{Memory-DobxIoZ-.js → Memory-BmM0Fz-C.js} +5 -5
- package/dist/assets/{Panel-Cyt1wpUf.js → Panel-Dc6F8wb4.js} +1 -1
- package/dist/assets/Permissions-m_NnldFh.js +3 -0
- package/dist/assets/Plugins-BB0TLUC9.js +2 -0
- package/dist/assets/ProvenanceBadge-k9PH0S2n.js +1 -0
- package/dist/assets/{SaveBar-BuYrg5E9.js → SaveBar-DSMnbUVI.js} +1 -1
- package/dist/assets/Scheduler-CbIcJEfM.js +16 -0
- package/dist/assets/{ScopeSwitcher-BM0gLPhd.js → ScopeSwitcher-tHtloWbN.js} +1 -1
- package/dist/assets/Settings-CW3w7knp.js +6 -0
- package/dist/assets/{SkillReferenceGraph-D0Hgdfxq.js → SkillReferenceGraph-Dndl1tzr.js} +14 -14
- package/dist/assets/Skills-CGnxroik.js +2 -0
- package/dist/assets/SystemPrompt-B3A3rHNp.js +1 -0
- package/dist/assets/TagLibrary-k4CTiAYo.js +1 -0
- package/dist/assets/{TiptapBody-CP_F_mwb.js → TiptapBody-C2LfNQXw.js} +1 -1
- package/dist/assets/{Toggle-haRPHS5N.js → Toggle-CTXTU1q5.js} +1 -1
- package/dist/assets/{ViewTabs-BHV3MA5u.js → ViewTabs-CfEfOSE1.js} +1 -1
- package/dist/assets/historyTotals-Db0xy2Fg.js +1 -0
- package/dist/assets/{index-tr1w3hHB.css → index-C8Smiz7z.css} +1 -1
- package/dist/assets/{index-v_3LvhMx.js → index-fJxuoRvi.js} +697 -697
- package/dist/assets/listSkills-C1aWKf0T.js +1 -0
- package/dist/assets/{settingsSchema-CE46TA3V.js → settingsSchema-xxO9p4yF.js} +1 -1
- package/dist/assets/useAgentsDirWatch-DLS1_moj.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +5 -2
- package/plugins/session-manager-dev/skills/develop/standards.md +5 -0
- package/scripts/README.md +7 -0
- package/scripts/scheduler-mcp-server.cjs +38 -5
- package/src/main/agentLibrary.cjs +20 -9
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +20 -10
- package/src/main/historyAggregator.cjs +46 -3
- package/src/main/index.cjs +2 -0
- package/src/main/ipcSchemas.cjs +2 -0
- package/src/main/lib/builtinMacros.cjs +2 -2
- package/src/main/lib/mcpToolCatalog.cjs +3 -1
- package/src/main/lib/remoteE2eCrypto.cjs +109 -0
- package/src/main/lib/shippedPersonaSeeds.cjs +11 -0
- package/src/main/pty.cjs +53 -0
- package/src/main/remoteClient.cjs +305 -0
- package/src/main/remoteClientIpc.cjs +101 -0
- package/src/main/webRemote.cjs +90 -108
- package/src/preload/api.d.ts +42 -5
- package/src/preload/index.cjs +27 -2
- package/src/seed/agents/demo-video-builder.md +69 -48
- package/dist/assets/AgentLibrary-Bjeq2-kp.js +0 -2
- package/dist/assets/DataModel-iPJw5jcG.js +0 -1
- package/dist/assets/History-DfPR3_6N.js +0 -2
- package/dist/assets/Hooks-Bw7H_DmC.js +0 -3
- package/dist/assets/Permissions-ChSNRUJJ.js +0 -3
- package/dist/assets/Plugins-CII221R2.js +0 -2
- package/dist/assets/ProvenanceBadge-C_sk5-v3.js +0 -1
- package/dist/assets/Scheduler-eixbMGEk.js +0 -16
- package/dist/assets/Settings-qD-0W-Ut.js +0 -4
- package/dist/assets/Skills-C3T_2_2o.js +0 -3
- package/dist/assets/SystemPrompt-B-xTy9Qn.js +0 -1
- package/dist/assets/TagLibrary-BH67tR5z.js +0 -1
- package/dist/assets/listSkills-QORduPIk.js +0 -1
- package/dist/assets/useAgentsDirWatch-BZTi2K2e.js +0 -1
- package/dist/assets/useConfigDirWatch-CjcswsWR.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ar as xe,az as Le,b7 as Ie,ah as e,aw as m,aL as q,as as A,at as W,aU as We,b0 as Ne,am as ze,aT as Ke,m as Ge}from"./index-v_3LvhMx.js";import{P as Ye}from"./Panel-Cyt1wpUf.js";import"./monaco-editor-BsIlgG7c.js";function re(){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 Ve(t){return t.promptCount>0||t.sessionCount>0||t.toolCallCount>0||t.inputTokens>0||t.outputTokens>0}function Xe(t,s){const n=s===null,c=[],o=re(),r={};let a=0;for(const l of t.days){const u=re();let d=!1;for(const[i,x]of Object.entries(l.byProject))if(!(!n&&!s.has(i))){we(u,x),we(o,x),Ve(x)&&(d=!0);for(const[f,v]of Object.entries(x.byModel)){const C=r[f]??(r[f]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});C.inputTokens+=v.inputTokens,C.outputTokens+=v.outputTokens,C.cacheReadTokens+=v.cacheReadTokens,C.cacheCreationTokens+=v.cacheCreationTokens,C.costUsd+=v.costUsd,v.estimated&&(C.estimated=!0)}}d&&(a+=1),c.push({date:l.date,totals:u})}return{days:c,totals:o,prevTotals:n?t.prevTotals:re(),prevAvailable:n,byModelTotals:r,activeDays:a}}function Ue(t,s){if(!s)return{pct:null,direction:"flat"};const n=(t-s)/s*100,c=n>0?"up":n<0?"down":"flat";return{pct:n,direction:c}}function Qe(t,s,n){return s<=0?0:t/s*n}const Ee={in:"In tokens",out:"Out tokens",total:"Total tokens",prompts:"Prompts",sessions:"Sessions",time:"Time",spend:"Spend"};function R(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 Ze(t,s){const n=R(t.totals,s),c=t.prevAvailable?Ue(n,R(t.prevTotals,s)):null,o=t.days.map(r=>R(r.totals,s));return{value:n,delta:c,series:o}}function Me(t,s){const n=new Map,c=Math.ceil(t.length/2);t.forEach((a,l)=>{for(const[u,d]of Object.entries(a.byProject)){let i=n.get(u);i||(i={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(u,i)),i.totals.promptCount+=d.promptCount,i.totals.inputTokens+=d.inputTokens,i.totals.outputTokens+=d.outputTokens,i.totals.cacheReadTokens+=d.cacheReadTokens,i.totals.cacheCreationTokens+=d.cacheCreationTokens,i.totals.toolCallCount+=d.toolCallCount,i.totals.sessionCount+=d.sessionCount,i.totals.errorCount+=d.errorCount,i.totals.activeMinutes+=d.activeMinutes,i.totals.estimatedCostUsd+=d.estimatedCostUsd;for(const[f,v]of Object.entries(d.toolBreakdown))i.toolBreakdown[f]=(i.toolBreakdown[f]??0)+v;const x=R(d,s);l<c?i.firstHalf+=x:i.secondHalf+=x}});const o=Array.from(n.entries()).map(([a,l])=>{let u="",d=-1;for(const[i,x]of Object.entries(l.toolBreakdown))x>d&&(d=x,u=i);return{projectDir:a,value:R(l.totals,s),sharePct:0,trend:Ue(l.secondHalf,l.firstHalf),sessions:l.totals.sessionCount,topTool:u}}),r=o.reduce((a,l)=>a+l.value,0);for(const a of o)a.sharePct=r>0?a.value/r*100:0;return o.sort((a,l)=>l.value-a.value)}const qe=["date","cost_usd","input_tokens","output_tokens","cache_write_tokens","cache_read_tokens","total_tokens","cache_hit_pct","num_models","top_model"];function Je(t){return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Se(t){return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreationTokens}function et(t){const s=t.map(n=>{const c=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens,o=n.inputTokens+n.cacheReadTokens+n.cacheCreationTokens,r=o>0?n.cacheReadTokens/o*100:0,a=Object.entries(n.byModel).filter(([,i])=>Se(i)>0);let l="",u=-1;for(const[i,x]of a){const f=Se(x);f>u&&(u=f,l=i)}return[n.date,n.costUsd.toFixed(4),String(n.inputTokens),String(n.outputTokens),String(n.cacheCreationTokens),String(n.cacheReadTokens),String(c),r.toFixed(1),String(a.length),l?xe(l):""].map(Je).join(",")});return[qe.join(","),...s].join(`
|
|
2
|
-
`)}const tt={folderCount:0,sessionCount:0,promptCount:0,estimatedCostUsd:0,totalTokens:0};function st(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;for(const[n,c]of Object.entries(s.toolBreakdown??{}))t.toolBreakdown[n]=(t.toolBreakdown[n]??0)+c;for(const[n,c]of Object.entries(s.byModel??{})){const o=t.byModel[n]??(t.byModel[n]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});o.inputTokens+=c.inputTokens,o.outputTokens+=c.outputTokens,o.cacheReadTokens+=c.cacheReadTokens,o.cacheCreationTokens+=c.cacheCreationTokens,o.costUsd+=c.costUsd,c.estimated&&(o.estimated=!0)}}function nt(t,s){const n={};for(const[c,o]of Object.entries(t.byModel??{}))n[c]={...o};return{...t,projectDir:s,toolBreakdown:{...t.toolBreakdown??{}},byModel:n}}function ot(t,s){const n={...tt},c=new Set,o=t.map(r=>{const a={};for(const[l,u]of Object.entries(r.byProject)){const d=s[l];if(!d){c.add(l),n.sessionCount+=u.sessionCount,n.promptCount+=u.promptCount,n.estimatedCostUsd+=u.estimatedCostUsd,n.totalTokens+=u.inputTokens+u.outputTokens;continue}const i=a[d];i?st(i,u):a[d]=nt(u,d)}return{...r,byProject:a}});return n.folderCount=c.size,{days:o,excluded:n}}function at(t){return t.folderCount>0}function ct(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 he(){return(await Le()).history??{}}let $e=Promise.resolve();function ue(t){const s=$e.then(async()=>{const n=await he();await Ie({history:{...n,...t}})});return $e=s.catch(()=>{}),s}const rt=["in","out","total","prompts","sessions","time","spend"],it=[{value:30,label:"30d"},{value:60,label:"60d"},{value:90,label:"90d"},{value:0,label:"All time"}];function Re({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(c=>e.jsx("button",{onClick:()=>n(c.value),className:`px-2 py-1 rounded whitespace-nowrap font-mono ${t===c.value?"bg-bg-hi text-fg shadow-sm":"text-fg-faint hover:text-fg"}`,children:c.label},String(c.value)))})}function lt({measure:t,onMeasure:s,range:n,onRange:c,projectsShown:o,projectsTotal:r,fromDate:a,toDate:l,onRefresh:u,onExport:d,exportDisabled:i}){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(Re,{value:t,options:rt.map(x=>({value:x,label:Ee[x]})),onChange:s}),e.jsx(Re,{value:n,options:it,onChange:c}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[o," / ",r," projects"]}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[a," → ",l]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:u,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:d,disabled:i,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"})]})}function E(t){const s=Number.isFinite(t)?t:0,n=Math.abs(s)<1?4:2;return`$${s.toFixed(n)}`}function z(t){const s=Number.isFinite(t)?t:0,n=Math.abs(s);return n>=1e9?`${(s/1e9).toFixed(1)}B`:n>=1e6?`${(s/1e6).toFixed(1)}M`:n>=1e3?`${(s/1e3).toFixed(1)}K`:`${Math.round(s)}`}function K(t){const s=Number.isFinite(t)?t:0;return Math.round(s).toLocaleString("en-US")}function Pe(t){const s=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(s<60)return`${s}m`;const n=Math.floor(s/60),c=s%60;return c===0?`${n}h`:`${n}h ${c}m`}function Fe(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}const M="rounded-card bg-bg-hi border border-line",dt="#ded2bd",ut="#6f7d52";function D({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 J(t,s){switch(t){case"spend":return E(s);case"in":case"out":case"total":return z(s);case"time":return Pe(s);default:return K(s)}}function pt({measure:t,headline:s,activeDays:n,projectsTouched:c,totalSessions:o}){const r=n>0?s.value/n:0,a=o>0?s.value/o:0,{delta:l}=s,u=l&&(t==="spend"?l.direction==="down":l.direction==="up"),d=l&&l.direction!=="flat"&&(t==="spend"?l.direction==="up":l.direction==="down"),i=u?"text-delta-good":d?"text-delta-bad":"text-fg-faint";return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"01 · overview",title:Ee[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:J(t,s.value)}),l?e.jsxs("div",{className:`text-xs font-mono mt-2 ${i}`,children:[l.direction==="up"?"▲":l.direction==="down"?"▼":"·"," ",Fe(Math.abs(l.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(xt,{series:s.series})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-4 pt-3 border-t border-line",children:[e.jsx(Z,{label:"per active day",value:J(t,r)}),e.jsx(Z,{label:"per session",value:J(t,a)}),e.jsx(Z,{label:"active days",value:K(n)}),e.jsx(Z,{label:"projects touched",value:K(c)})]})]})}function Z({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 xt({series:t}){if(t.length<2)return null;const c=Math.max(...t,0),o=Math.min(...t,0),r=c-o||1,a=160/(t.length-1),l=t.map((d,i)=>`${i*a},${48-(d-o)/r*48}`).join(" "),u=`0,48 ${l} 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:u,fill:"#b85c34",opacity:.15}),e.jsx("polyline",{points:l,fill:"none",stroke:"#b85c34",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})]})}const ht=50;function ft({days:t}){const[s,n]=m.useState(ht),c=m.useRef(!1);m.useEffect(()=>{let d=!1;return he().then(i=>{d||c.current||typeof i.budgetCapUsd=="number"&&Number.isFinite(i.budgetCapUsd)&&i.budgetCapUsd>0&&n(i.budgetCapUsd)}),()=>{d=!0}},[]);const o=d=>{c.current=!0;const i=s;n(d),ue({budgetCapUsd:d}).catch(()=>{n(i),q.error("Couldn't save the budget cap — reverted.")})},{mtdSpend:r,projectedSpend:a}=m.useMemo(()=>{const d=new Date,i=d.toLocaleDateString("en-CA").slice(0,7),x=new Date(d.getFullYear(),d.getMonth()+1,0).getDate(),f=d.getDate();let v=0;for(const C of t)if(C.date.startsWith(i))for(const S of Object.values(C.byProject))v+=S.estimatedCostUsd;return{mtdSpend:v,projectedSpend:Qe(v,f,x)}},[t]),l=a>s,u=s>0?Math.min(100,r/s*100):0;return e.jsxs("div",{className:`${M} 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:d=>{const i=Number(d.target.value);Number.isFinite(i)&&i>0&&o(i)},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:[E(r)," ",e.jsx("span",{className:"text-fg-faint",children:"month-to-date"})]}),e.jsxs("span",{className:l?"text-delta-bad":"text-fg-dim",children:[E(a)," ",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 ${l?"bg-delta-bad":"bg-sage"}`,style:{width:`${Math.max(u,u>0?2:0)}%`}})}),e.jsx("div",{className:`text-[10px] mt-1 font-mono ${l?"text-delta-bad":"text-fg-faint"}`,children:l?`projected to exceed $${s.toFixed(0)} cap`:`${u.toFixed(0)}% of $${s.toFixed(0)} cap`})]})}function mt({chips:t,keep:s,onToggle:n,onIsolate:c,onShowAll:o}){const r=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 ${r?"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(a=>{const l=r||s.has(a.projectDir);return e.jsxs("button",{onClick:u=>u.shiftKey?c(a.projectDir):n(a.projectDir),title:a.projectDir,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-[11px] font-mono border ${l?"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:A(a.projectDir)}}),W(a.projectDir)??a.projectDir]},a.projectDir)})]})}function jt(t,s){const n=new Map;for(const o of t)for(const[r,a]of Object.entries(o.values))n.set(r,(n.get(r)??0)+a);const c=Array.from(n.entries()).sort((o,r)=>r[1]-o[1]).map(([o])=>o);return t.map(o=>{const r=c.reduce((u,d)=>u+(o.values[d]??0),0);let a=0;const l=c.map(u=>{const d=o.values[u]??0;if(r<=0)return{projectDir:u,value:d,y0:0,y1:0};const i=s==="share"?d/r:d,x=a,f=a+i;return a=f,{projectDir:u,value:d,y0:x,y1:f}});return{date:o.date,bands:l,total:r}})}const ie=720,le=220,de=44,gt=20;function kt(t,s){return t==="spend"?E(s):z(s)}function bt({days:t,measure:s,selected:n,onSelect:c}){const[o,r]=m.useState("absolute"),a=m.useMemo(()=>jt(t,o),[t,o]),l=m.useMemo(()=>{if(o==="share")return 1;let h=0;for(const k of a)h=Math.max(h,k.total);return h||1},[a,o]),u=ie-de,d=le-gt,i=a.length>1?u/(a.length-1):u,x=h=>de+h*i,f=h=>d-h/l*d,v=Math.max(1,Math.ceil(a.length/8)),C=4,S=Array.from({length:C+1},(h,k)=>l/C*k);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{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(h=>e.jsx("button",{onClick:()=>r(h),className:`px-2 py-0.5 ${o===h?"bg-accent text-white":"text-fg-faint hover:text-fg"}`,children:h},h))})}),e.jsxs("svg",{width:"100%",viewBox:`0 0 ${ie} ${le}`,className:"overflow-visible",children:[S.map((h,k)=>e.jsxs("g",{children:[e.jsx("line",{x1:de,x2:ie,y1:f(h),y2:f(h),stroke:"currentColor",className:"text-line",strokeWidth:1}),e.jsx("text",{x:0,y:f(h)+3,fontSize:9,className:"fill-fg-faint",children:o==="share"?`${Math.round(h*100)}%`:kt(s,h)})]},k)),a.map((h,k)=>{if(k===0)return null;const P=a[k-1];return h.bands.map((j,te)=>{const G=P.bands[te],B=n!==null&&n!==j.projectDir,se=B?dt:A(j.projectDir),ne=[`${x(k-1)},${f(G.y0)}`,`${x(k)},${f(j.y0)}`,`${x(k)},${f(j.y1)}`,`${x(k-1)},${f(G.y1)}`].join(" ");return e.jsx("polygon",{points:ne,fill:se,opacity:B?.6:.75,className:"cursor-pointer",onClick:()=>c(n===j.projectDir?null:j.projectDir),children:e.jsx("title",{children:W(j.projectDir)??j.projectDir})},`${j.projectDir}-${k}`)})}),a.map((h,k)=>k%v!==0&&k!==a.length-1?null:e.jsx("text",{x:x(k),y:le-4,fontSize:9,textAnchor:"middle",className:"fill-fg-faint",children:h.date.slice(5)},h.date))]})]})}function vt({rows:t,measure:s,selected:n,onSelect:c}){return t.length?e.jsxs("div",{className:`${M} overflow-hidden`,children:[e.jsx("div",{className:"p-4 pb-0",children:e.jsx(D,{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 r=A(o.projectDir),a=n===o.projectDir;return e.jsxs("tr",{onClick:()=>c(o.projectDir),className:`border-t border-line hover:bg-bg-elev cursor-pointer ${a?"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:r}}),W(o.projectDir)??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:r}})})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:J(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"?"▼":"·"," ",Fe(Math.abs(o.trend.pct))]})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:K(o.sessions)}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:o.topTool||"—"})]},o.projectDir)})})]})]}):e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"03 · by project",title:"Ranking"}),e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"})]})}function Ct({projectDir:t,totals:s,byModel:n,toolBreakdown:c,onClear:o}){var i;const r=R(s,"in"),a=R(s,"out"),l=Object.entries(n).sort((x,f)=>f[1].costUsd-x[1].costUsd),u=Object.entries(c).sort((x,f)=>f[1]-x[1]),d=((i=u[0])==null?void 0:i[1])??0;return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"04 · drill in",title:W(t)??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:A(t)}})}),e.jsxs("div",{className:"grid grid-cols-6 gap-3 mb-4",children:[e.jsx(I,{label:"prompts",value:K(s.promptCount)}),e.jsx(I,{label:"sessions",value:K(s.sessionCount)}),e.jsx(I,{label:"in tokens",value:z(r)}),e.jsx(I,{label:"out tokens",value:z(a)}),e.jsx(I,{label:"spend",value:E(s.estimatedCostUsd)}),e.jsx(I,{label:"time",value:Pe(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"}),l.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data"}):e.jsx("div",{className:"space-y-1",children:l.map(([x,f])=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-fg-dim",children:[e.jsx("span",{children:xe(x)}),e.jsx("span",{className:"text-fg-faint",children:E(f.costUsd)})]},x))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"tool mix"}),u.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no tool data"}):e.jsx("div",{className:"space-y-1",children:u.slice(0,6).map(([x,f])=>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:x}),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:`${d>0?f/d*100:0}%`}})}),e.jsx("span",{className:"text-fg-faint font-mono w-8 text-right",children:f})]},x))})]})]})]})}function I({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 Tt({byModelTotals:t}){const s=Object.entries(t).sort((c,o)=>o[1].costUsd-c[1].costUsd),n=s.reduce((c,[,o])=>c+o.costUsd,0);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Model mix",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:[E(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(([c,o])=>{const r=n>0?o.costUsd/n*100:0,a=A(c);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:a}}),xe(c),o.estimated&&e.jsx("span",{className:"text-fg-faint",children:"(est.)"})]}),e.jsxs("span",{className:"text-fg-faint whitespace-nowrap ml-2",children:[E(o.costUsd)," · ",r.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(r,r>0?2:0)}%`,backgroundColor:a}})})]},c)})})]})}function yt({rows:t}){const s=t.slice(0,3),n=s.reduce((r,a)=>r+a.sharePct,0),c=t.slice(3),o=c.reduce((r,a)=>r+a.sharePct,0);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{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(r=>e.jsx("div",{style:{width:`${Math.max(r.sharePct,.5)}%`,backgroundColor:A(r.projectDir)},title:`${W(r.projectDir)??r.projectDir} · ${r.sharePct.toFixed(1)}%`},r.projectDir))}),e.jsx("div",{className:"space-y-1 mb-2",children:s.map(r=>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:A(r.projectDir)}}),W(r.projectDir)??r.projectDir]}),e.jsxs("span",{className:"text-fg-faint",children:[r.sharePct.toFixed(1),"%"]})]},r.projectDir))}),c.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-faint",children:[c.length," more project",c.length===1?"":"s"," account for ",o.toFixed(1),"% (long tail)."]})]})]})}const ee=30,pe=9,F=(ee+pe)*2;function Nt({totals:t}){const s=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,n=s>0?t.cacheReadTokens/s*100:0,c=2*Math.PI*ee,o=F/2;return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Cache"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative shrink-0",style:{width:F,height:F},children:[e.jsxs("svg",{width:F,height:F,viewBox:`0 0 ${F} ${F}`,className:"-rotate-90",children:[e.jsx("circle",{cx:o,cy:o,r:ee,fill:"none",stroke:"currentColor",className:"text-bg-hi",strokeWidth:pe}),e.jsx("circle",{cx:o,cy:o,r:ee,fill:"none",stroke:ut,strokeWidth:pe,strokeDasharray:c,strokeDashoffset:c*(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:z(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:z(t.cacheCreationTokens)})]})]})]})]})}const wt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Mt({days:t,measure:s}){const{buckets:n,weekendShare:c,peakIdx:o}=m.useMemo(()=>{const a=new Array(7).fill(0);for(const i of t){const[x,f,v]=i.date.split("-").map(Number),C=new Date(x,f-1,v).getDay();a[C]+=R(i.totals,s)}const l=a.reduce((i,x)=>i+x,0),u=a[0]+a[6];let d=0;for(let i=1;i<7;i++)a[i]>a[d]&&(d=i);return{buckets:a,weekendShare:l>0?u/l*100:0,peakIdx:d}},[t,s]),r=Math.max(...n,1);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Rhythm",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["weekend ",c.toFixed(0),"%"]})}),e.jsx("div",{className:"flex items-end gap-2 h-24",children:n.map((a,l)=>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 ${l===o?"bg-accent":"bg-rhythm"}`,style:{height:`${r>0?a/r*100:0}%`,minHeight:a>0?2:0}}),e.jsx("span",{className:"text-[9px] text-fg-faint font-mono",children:wt[l]})]},l))})]})}const St=["in","out","total","prompts","sessions","time","spend"],$t=[30,60,90,0],Rt="spend",Dt=30,Ut=[];function Et(){return{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0}}function Pt(){var be;const[t,s]=m.useState(Rt),[n,c]=m.useState(Dt),o=m.useRef(!1),r=m.useRef(!1),a=p=>{o.current=!0;const g=t;s(p),ue({measure:p}).catch(()=>{s(g),q.error("Couldn't save the measure preference — reverted.")})},l=p=>{r.current=!0;const g=n;c(p),ue({range:p}).catch(()=>{c(g),q.error("Couldn't save the range preference — reverted.")})};m.useEffect(()=>{let p=!1;return he().then(g=>{p||(!o.current&&g.measure&&St.includes(g.measure)&&s(g.measure),!r.current&&g.range!==void 0&&$t.includes(g.range)&&c(g.range))}),()=>{p=!0}},[]);const u=We(p=>p.navFace),d=Ne(p=>p.tabs),i=Ne(p=>p.activeTabId),x=((be=d.find(p=>p.id===i))==null?void 0:be.cwd)??null,f=m.useRef(u),v=x?ze(x):null,[C,S]=m.useState(null),h=m.useMemo(()=>u==="project"&&v?new Set([v]):C,[u,v,C]),[k,P]=m.useState(null),[j,te]=m.useState(null),[G,B]=m.useState(!0),[se,ne]=m.useState(0);m.useEffect(()=>{let p=!1;return B(!0),window.api.history.dashboard({rangeDays:n}).then(g=>{p||(te(g),B(!1))}).catch(g=>{p||(B(!1),q.error(`History analytics failed to load: ${String(g)}`))}),()=>{p=!0}},[n,se]);const fe=m.useRef(!1);m.useEffect(()=>{if(!fe.current){fe.current=!0;return}S(null),P(null)},[n]),m.useEffect(()=>{f.current!==u&&(f.current=u,u==="home"&&S(null))},[u]);const{projects:me,resolving:je}=Ke(),ge=m.useMemo(()=>{const p={};for(const g of me)for(const T of g.encodedIds)p[T]=g.cwd;return p},[me]),_=m.useMemo(()=>j&&!je?ot(j.days,ge):null,[j,ge,je]),y=(_==null?void 0:_.days)??(j==null?void 0:j.days)??Ut,oe=(_==null?void 0:_.excluded)??null,$=m.useMemo(()=>j?Xe({days:y,totals:j.totals,prevTotals:j.prevTotals},h):null,[j,y,h]),O=m.useMemo(()=>h===null?y:y.map(p=>({date:p.date,byProject:Object.fromEntries(Object.entries(p.byProject).filter(([g])=>h.has(g)))})),[y,h]),Y=m.useMemo(()=>Me(y,t),[y,t]),ae=m.useMemo(()=>Me(O,t),[O,t]),Ae=m.useMemo(()=>O.map(p=>({date:p.date,values:Object.fromEntries(Object.entries(p.byProject).map(([g,T])=>[g,R(T,t)]))})),[O,t]),ke=m.useMemo(()=>$?Ze($,t):null,[$,t]),V=m.useMemo(()=>{if(!j||!k)return null;const p=Et(),g={},T={};for(const H of y){const b=H.byProject[k];if(b){p.promptCount+=b.promptCount,p.inputTokens+=b.inputTokens,p.outputTokens+=b.outputTokens,p.cacheReadTokens+=b.cacheReadTokens,p.cacheCreationTokens+=b.cacheCreationTokens,p.toolCallCount+=b.toolCallCount,p.sessionCount+=b.sessionCount,p.errorCount+=b.errorCount,p.activeMinutes+=b.activeMinutes,p.estimatedCostUsd+=b.estimatedCostUsd;for(const[N,w]of Object.entries(b.byModel)){const U=g[N]??(g[N]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});U.inputTokens+=w.inputTokens,U.outputTokens+=w.outputTokens,U.cacheReadTokens+=w.cacheReadTokens,U.cacheCreationTokens+=w.cacheCreationTokens,U.costUsd+=w.costUsd}for(const[N,w]of Object.entries(b.toolBreakdown))T[N]=(T[N]??0)+w}}return{totals:p,byModel:g,toolBreakdown:T}},[j,y,k]);m.useEffect(()=>{k&&h!==null&&!h.has(k)&&P(null)},[k,h]);function Be(p){S(g=>{const T=new Set(Y.map(N=>N.projectDir)),H=g??new Set(T),b=new Set(H);return b.has(p)?b.delete(p):b.add(p),b.size>=T.size?null:b})}function _e(p){S(new Set([p]))}function Oe(){S(null)}function He(){if(!j)return;const p=O.map(N=>{let w=0,U=0,ve=0,Ce=0,Te=0;const ce={};for(const L of Object.values(N.byProject)){w+=L.estimatedCostUsd,U+=L.inputTokens,ve+=L.outputTokens,Ce+=L.cacheCreationTokens,Te+=L.cacheReadTokens;for(const[ye,X]of Object.entries(L.byModel)){const Q=ce[ye]??(ce[ye]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});Q.inputTokens+=X.inputTokens,Q.outputTokens+=X.outputTokens,Q.cacheReadTokens+=X.cacheReadTokens,Q.cacheCreationTokens+=X.cacheCreationTokens}}return{date:N.date,costUsd:w,inputTokens:U,outputTokens:ve,cacheCreationTokens:Ce,cacheReadTokens:Te,byModel:ce}}),g=et(p),T=new Blob([g],{type:"text/csv"}),H=URL.createObjectURL(T),b=document.createElement("a");b.href=H,b.download=`usage-history-${j.from}-${j.to}.csv`,b.click(),URL.revokeObjectURL(H)}return G&&!j?e.jsx(De,{}):j&&j.days.length===0?e.jsx(Ge,{title:"no sessions in range",hint:"Widen the range or check back after your next session."}):!j||!$||!ke?e.jsx(De,{}):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(lt,{measure:t,onMeasure:a,range:n,onRange:l,projectsShown:h===null?Y.length:h.size,projectsTotal:Y.length,fromDate:j.from,toDate:j.to,onRefresh:()=>ne(p=>p+1),onExport:He,exportDisabled:O.length===0}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-4 space-y-4",children:[e.jsx(pt,{measure:t,headline:ke,activeDays:$.activeDays,projectsTouched:ae.length,totalSessions:$.totals.sessionCount}),e.jsx(ft,{days:y}),oe&&at(oe)&&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:ct(oe)}),u==="home"&&e.jsx(mt,{chips:Y.map(p=>({projectDir:p.projectDir,value:p.value})),keep:h,onToggle:Be,onIsolate:_e,onShowAll:Oe}),e.jsx(bt,{days:Ae,measure:t,selected:k,onSelect:P}),e.jsx(vt,{rows:ae,measure:t,selected:k,onSelect:P}),k&&V&&e.jsx(Ct,{projectDir:k,totals:V.totals,byModel:V.byModel,toolBreakdown:V.toolBreakdown,onClear:()=>P(null)}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(Tt,{byModelTotals:$.byModelTotals}),e.jsx(yt,{rows:ae}),e.jsx(Nt,{totals:$.totals}),e.jsx(Mt,{days:$.days,measure:t})]})]})]})}function De(){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 Ft(){return e.jsx(Ye,{children:e.jsx(Pt,{})})}const Ot=m.memo(Ft);export{Ot as History};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{aw as d,aS as X,aM as Z,aU as ee,aN as F,aj as te,ao as se,ad as ae,ah as e,m as E,V as oe,G as ne,aD as re,u as ie}from"./index-v_3LvhMx.js";import{P as R}from"./Panel-Cyt1wpUf.js";import{L as le}from"./ListDetail-qI27OYfy.js";import{S as ce}from"./SaveBar-BuYrg5E9.js";import{S as D}from"./ScopeSwitcher-BM0gLPhd.js";import{P as de}from"./ProvenanceBadge-C_sk5-v3.js";import{u as me,E as pe,s as ue}from"./settingsSchema-CE46TA3V.js";import{H as he}from"./Library-rqaJJJ1b.js";import{V as xe}from"./ViewTabs-BHV3MA5u.js";import"./monaco-editor-BsIlgG7c.js";import"./claude-settings-schema-COigsajx.js";import"./Button-CRLhoI2K.js";const fe={UserPromptSubmit:{when:"Fires just before the user prompt is sent to the model.",payload:"{ prompt: string }",example:"Block submission if the prompt mentions a secret."},UserPromptExpansion:{when:"Fires when a slash command expands into its final prompt text.",payload:"{ command: string, expanded: string }",example:"Audit which slash commands actually run, post-expansion."},PreToolUse:{when:"Fires before any tool runs. Can block the call.",payload:"{ tool_name: string, tool_input: object }",example:'matcher="Bash" — block dangerous shell commands.'},PostToolUse:{when:"Fires after a tool completes successfully.",payload:"{ tool_name: string, tool_input: object, tool_result: string }",example:'matcher="Write|Edit" — run a linter on changed files.'},PostToolUseFailure:{when:"Fires after a tool errors out (non-zero exit, exception, or refusal).",payload:"{ tool_name: string, tool_input: object, error: string }",example:"Pipe failed Bash runs into a desktop notification."},PostToolBatch:{when:"Fires once after a parallel batch of tool calls all complete.",payload:"{ tool_uses: Array<{ tool_name, tool_input, tool_result? }> }",example:"Aggregate file-edit batches into a single commit message."},Stop:{when:"Fires when the model emits end_turn.",payload:"{ stop_reason: string, output_tokens: number }",example:"Play a chime when the agent finishes a long task."},StopFailure:{when:"Fires when a turn aborts without end_turn (rate-limit, network, OOM).",payload:'{ reason: "rate_limit"|"network"|"oom"|"killed"|string }',example:"Auto-resume on transient failures."},SessionStart:{when:"Fires once when a session boots (claude or claude -p).",payload:'{ source: "startup"|"resume", model: string, agent_type: string }',example:"Inject a project-specific system prompt addendum."},SessionEnd:{when:"Fires once when the session terminates.",payload:'{ reason: "user_quit"|"timeout"|"error"|string }',example:"Persist transcript summary to ~/.claude/projects/<>."},Setup:{when:"Fires during interactive setup (claude /setup, /init).",payload:'{ mode: "init"|"reconfigure"|string }'},PreCompact:{when:"Fires before transcript compaction runs.",payload:'{ transcript_path: string, trigger: "manual"|"auto" }',example:"Snapshot the pre-compact transcript for later diffing."},PostCompact:{when:"Fires after compaction; the active transcript is the compacted one.",payload:'{ transcript_path: string, trigger: "manual"|"auto" }'},InstructionsLoaded:{when:"Fires after CLAUDE.md and any imported memory files are loaded.",payload:'{ source: "session_start"|"reload" }'},Notification:{when:"Fires when Claude Code emits a desktop notification.",payload:"{ title: string, message: string }",example:"Forward to your own notify-send / osascript pipeline."},PermissionRequest:{when:"Fires when a tool needs user permission (per the permissions block).",payload:"{ tool_name: string, tool_input?: object }",example:"Auto-allow npm test invocations."},PermissionDenied:{when:"Fires when the user (or policy) denies a permission request.",payload:"{ tool_name: string, retry: boolean }",example:"Track which tools the user habitually rejects."},SubagentStart:{when:"Fires when a subagent (Task tool) spawns.",payload:"{ agent_type: string }",example:'matcher="security-reviewer" — log every security scan.'},SubagentStop:{when:"Fires when a subagent finishes.",payload:'{ agent_type: string, reason: "end_turn"|"error"|string }'},TeammateIdle:{when:"Fires when a teammate agent goes idle (waiting for input).",payload:"{ teammate_id?: string }"},TaskCreated:{when:"Fires when a new Task is created via the Task tool.",payload:"{ task: { description: string, ...} }",example:"Track each spawned task in an external queue."},TaskCompleted:{when:"Fires when a Task completes (success or failure).",payload:"{ task: { description: string, ...} }"},ConfigChange:{when:"Fires when settings.json (any scope) is mutated mid-session.",payload:'{ source: "user_settings"|"project_settings"|"local_settings" }',example:"Reload tooling that depends on env vars on config change."},CwdChanged:{when:"Fires when the working directory changes (e.g. agent cd-ing).",payload:"{ old_cwd: string, new_cwd: string }",example:"Refresh project-scoped indexers when cwd drifts."},FileChanged:{when:"Fires when a watched file outside Claude Code's edits changes.",payload:'{ file_path: string, change_type: "modified"|"created"|"deleted" }',example:"Re-run typecheck when any .ts file changes."},WorktreeCreate:{when:"Fires after a git worktree is created via /worktree or subagent isolation.",payload:"{ worktree_path?: string, branch?: string }"},WorktreeRemove:{when:"Fires after a git worktree is removed.",payload:"{ worktree_path?: string }"},Elicitation:{when:"Fires when Claude asks the user a multiple-choice question.",payload:'{ action: "accept"|"reject", ...}'},ElicitationResult:{when:"Fires after the user resolves an elicitation prompt.",payload:"{ choice?: string }"}},I=["UserPromptSubmit","UserPromptExpansion","PreToolUse","PostToolUse","PostToolUseFailure","PostToolBatch","Stop","StopFailure","SessionStart","SessionEnd","Setup","PreCompact","PostCompact","InstructionsLoaded","Notification","PermissionRequest","PermissionDenied","SubagentStart","SubagentStop","TeammateIdle","TaskCreated","TaskCompleted","ConfigChange","CwdChanged","FileChanged","WorktreeCreate","WorktreeRemove","Elicitation","ElicitationResult"],ge=new Set(I),be=["command","http","prompt","agent","mcp_tool"],ye={UserPromptSubmit:{prompt:"hello"},UserPromptExpansion:{command:"/example",expanded:"hello"},PreToolUse:{tool_name:"Bash",tool_input:{command:"ls"}},PostToolUse:{tool_name:"Bash",tool_input:{command:"ls"},tool_result:""},PostToolUseFailure:{tool_name:"Bash",tool_input:{command:"ls"},error:""},PostToolBatch:{tool_uses:[]},Stop:{stop_reason:"end_turn",output_tokens:0},StopFailure:{reason:"rate_limit"},SessionStart:{source:"startup",model:"",agent_type:""},SessionEnd:{reason:"user_quit"},Setup:{mode:"init"},PreCompact:{transcript_path:"",trigger:"manual"},PostCompact:{transcript_path:"",trigger:"manual"},InstructionsLoaded:{source:"session_start"},Notification:{title:"test",message:"test notification"},PermissionRequest:{tool_name:"Bash"},PermissionDenied:{tool_name:"Bash",retry:!1},SubagentStart:{agent_type:"general-purpose"},SubagentStop:{agent_type:"general-purpose",reason:"end_turn"},TeammateIdle:{},TaskCreated:{task:{description:""}},TaskCompleted:{task:{description:""}},ConfigChange:{source:"user_settings"},CwdChanged:{old_cwd:"",new_cwd:""},FileChanged:{file_path:"",change_type:"modified"},WorktreeCreate:{},WorktreeRemove:{},Elicitation:{action:"accept"},ElicitationResult:{}};function ve(t){if(t.trim()==="")return{full:{},hooks:{},err:null};try{const n=JSON.parse(t);return{full:n,hooks:n.hooks??{},err:null}}catch(n){return{full:{},hooks:{},err:n.message}}}function je(t,n){return JSON.stringify({...t,hooks:n},null,2)+`
|
|
2
|
-
`}function we(t,n){return(t[n]??[]).reduce((o,l)=>{var c;return o+(((c=l.hooks)==null?void 0:c.length)??0)},0)}function ke(){const t=X(),n=Z(),o=(n==null?void 0:n.cwd)??null,l=ee(a=>a.navFace),c=d.useRef(!1),f=d.useRef(l),[m,x]=d.useState(()=>l==="project"&&o?"project":"user"),[r,u]=d.useState("PreToolUse"),[s,S]=d.useState("effective");d.useEffect(()=>{if(f.current!==l){if(f.current=l,c.current){c.current=!1;return}x(l==="project"&&o?"project":"user")}},[l,o]),d.useEffect(()=>{l==="project"&&s==="library"&&S("effective")},[l,s]);const g=a=>{c.current=!0,x(a)},j=me(ne,t,o),p=j[m]??null,w=F(a=>a.files),O=F(a=>a.setDraft),q=F(a=>a.saveJson),J=F(a=>a.revert),[M,N]=d.useState(null),[C,U]=d.useState(null),T=e.jsx(xe,{options:[{key:"effective",label:"Effective"},{key:"events",label:"Events"},...l==="home"?[{key:"library",label:"Library"}]:[]],active:s,onChange:S}),W=d.useMemo(()=>{const a=te(se(w,j));return ae(a,["hooks"])??{kind:"object",children:{}}},[w,j]),$=(a,h)=>{var L;const i=j[m];if(!i)return;N(null);const k=((L=w[i])==null?void 0:L.draftRaw)??"";let v={};if(k.trim())try{v=JSON.parse(k)}catch{v={}}const Y=re(v.hooks??{},a,h),Q={...v,hooks:Y};O(i,JSON.stringify(Q,null,2)+`
|
|
3
|
-
`)};if(!t)return e.jsx(E,{title:"loading…"});if(s==="library")return e.jsx(R,{toolbar:T,children:e.jsx(he,{})});if(m!=="user"&&!o)return e.jsx(R,{toolbar:e.jsxs(e.Fragment,{children:[T,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(D,{scopes:["user","project","local"],active:m,onChange:g})]}),children:e.jsx(E,{title:"no active project"})});if(!p)return e.jsx(E,{title:"loading…"});const b=w[p],{full:V,hooks:y,err:H}=b?ve(b.draftRaw):{full:{},hooks:{},err:null},A=Object.keys(y).filter(a=>!ge.has(a)),B=A.reduce((a,h)=>a+(y[h]??[]).reduce((i,k)=>{var v;return i+(((v=k.hooks)==null?void 0:v.length)??0)},0),0),P=a=>{N(null),O(p,je(V,a))},_=y[r]??[],G=()=>{P({...y,[r]:[..._,{matcher:"",hooks:[{type:"command",command:""}]}]})},K=(a,h)=>{const i=_.slice();i[a]=h,P({...y,[r]:i})},z=a=>{P({...y,[r]:_.filter((h,i)=>i!==a)})};return e.jsxs(R,{toolbar:e.jsxs(e.Fragment,{children:[T,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(D,{scopes:["user","project","local"],active:m,onChange:g}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:s==="effective"?`overrides → ${p}`:p}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/hooks",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"hook reference ↗"})]}),footer:b?e.jsx(ce,{dirty:b.dirty,busy:b.busy,parseError:M||H||b.parseError,lastSavedAt:b.lastSavedAt,onSave:async()=>{N(null);const a=await q(p);a.ok||N(a.error??"save failed")},onRevert:()=>{N(null),J(p)}}):null,children:[s==="effective"?e.jsx(pe,{node:W,targetScope:m,onOverride:$,schema:ue().rootedAt(["hooks"]),rootLabel:"hooks"}):e.jsxs("div",{className:"flex flex-col h-full",children:[B>0?e.jsxs("div",{className:"px-3 py-2 border-b border-line text-xs bg-bg-elev text-fg-dim",children:[e.jsx("span",{className:"text-yellow-400",children:"⚠"})," ",B," hook(s) configured under unknown event names: ",e.jsx("span",{className:"font-mono text-fg",children:A.join(", ")}),e.jsx("span",{className:"text-fg-faint",children:" · these are ignored by Claude Code 2026; edit settings.json directly to remove."})]}):null,e.jsx(le,{sidebarWidth:"14rem",sidebar:e.jsx("div",{className:"py-1",children:I.map(a=>{const h=we(y,a),i=fe[a],k=i?e.jsxs("span",{className:"block space-y-1",children:[e.jsx("span",{className:"block text-fg",children:i.when}),e.jsxs("span",{className:"block text-fg-faint font-mono",children:["payload: ",i.payload]}),i.example?e.jsxs("span",{className:"block text-fg-faint italic",children:["e.g. ",i.example]}):null]}):e.jsx("span",{className:"text-fg-faint italic",children:"no documentation yet"});return e.jsx("div",{className:"[&>span]:w-full",children:e.jsx(oe,{content:k,align:"bottom-center",children:e.jsxs("button",{onClick:()=>u(a),title:i==null?void 0:i.when,className:`w-full text-left px-3 py-1 text-xs ${r===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:a}),h>0&&e.jsx("span",{className:"text-accent shrink-0 ml-2",children:h})]}),i?e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:i.when}):e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 italic font-normal truncate",children:"no documentation yet"})]})})},a)})}),detail:e.jsxs("div",{className:"p-4 space-y-3 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg",children:r}),e.jsx("button",{onClick:G,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ add group"})]}),_.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no hooks for this event"}):_.map((a,h)=>e.jsx(Ne,{group:a,jsonInvalid:!!H,onChange:i=>K(h,i),onRemove:()=>z(h),onTestFire:i=>U({event:r,matcher:a.matcher??"",command:i.command??""})},h))]})})]}),C?e.jsx(Fe,{event:C.event,matcher:C.matcher,command:C.command,onClose:()=>U(null)}):null]})}const qe=d.memo(ke);function Ne({group:t,jsonInvalid:n,onChange:o,onRemove:l,onTestFire:c}){const f=()=>o({...t,hooks:[...t.hooks??[],{type:"command",command:""}]}),m=(r,u)=>{const s=t.hooks.slice();s[r]=u,o({...t,hooks:s})},x=r=>o({...t,hooks:t.hooks.filter((u,s)=>s!==r)});return e.jsxs("div",{className:"border border-line rounded p-3 bg-bg-elev space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-fg-faint w-16",children:"matcher"}),e.jsx("input",{value:t.matcher??"",onChange:r=>o({...t,matcher:r.target.value}),placeholder:"tool name regex or exact match (optional)",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:l,className:"text-fg-faint hover:text-red-400 text-xs",title:"remove group",children:"× group"})]}),(t.hooks??[]).map((r,u)=>e.jsx(_e,{rule:r,jsonInvalid:n,onChange:s=>m(u,s),onRemove:()=>x(u),onTestFire:()=>c(r)},u)),e.jsx("button",{onClick:f,className:"text-xs text-fg-faint hover:text-fg",children:"+ add hook"})]})}function _e({rule:t,jsonInvalid:n,onChange:o,onRemove:l,onTestFire:c}){const f=s=>({command:"e.g. node ./scripts/lint.js $FILE",http:"e.g. https://hooks.example.com/notify",prompt:"e.g. Review this change for security issues",agent:"e.g. security-reviewer",mcp_tool:"e.g. mcp__server__tool"})[s],m=t.type==="command"?"command":t.type==="http"?"url":t.type==="prompt"?"prompt":t.type==="mcp_tool"?"mcpTool":"agent",x=t[m]??"",r=(t.args??[]).join(" "),u={type:"hook",name:x||t.type,command:t.type==="command"?t.command:void 0,url:t.type==="http"?t.url:void 0};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{value:t.type,onChange:s=>o({type:s.target.value}),className:"bg-bg border border-line rounded px-1 py-0.5 text-xs text-fg",children:be.map(s=>e.jsx("option",{value:s,children:s},s))}),e.jsx(de,{interactive:!1,input:u}),e.jsx("input",{value:x,onChange:s=>o({...t,[m]:s.target.value}),placeholder:f(t.type),className:`flex-1 bg-bg border rounded px-2 py-0.5 text-xs text-fg font-mono ${n?"border-red-500/70":x.trim()?"border-line":"border-yellow-600/50"}`}),n?e.jsx("span",{className:"text-red-400 text-xs",title:"The enclosing settings.json is malformed; fix the JSON before editing.",children:"× invalid"}):null,e.jsx("input",{value:t.timeout??"",onChange:s=>o({...t,timeout:s.target.value?Number(s.target.value):void 0}),placeholder:"timeout ms",className:"w-20 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),t.type==="command"?e.jsx("button",{onClick:c,disabled:n||!x.trim(),className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",title:"Run this command with a fake event payload",children:"test fire"}):null,e.jsx("button",{onClick:l,className:"text-fg-faint hover:text-red-400 text-xs",children:"×"})]}),t.type==="command"?e.jsxs("div",{className:"flex items-center gap-2 pl-[3.75rem]",children:[e.jsx("span",{className:"text-xs text-fg-faint w-12",children:"args"}),e.jsx("input",{value:r,onChange:s=>o({...t,args:s.target.value.trim()?s.target.value.split(/\s+/).filter(Boolean):void 0}),placeholder:"argv array (v2.1.139+ exec form, no shell)",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"})]}):null,e.jsxs("div",{className:"flex items-center gap-2 pl-[3.75rem]",children:[e.jsx("span",{className:"text-xs text-fg-faint w-12",children:"term"}),e.jsx("input",{value:t.terminalSequence??"",onChange:s=>o({...t,terminalSequence:s.target.value||void 0}),placeholder:"terminalSequence — e.g. \\\\a (bell), v2.1.141+",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"})]})]})}function Se(t){return JSON.stringify(ye[t]??{},null,2)}function Ce(t,n){if(!t.trim())return{matched:!0,target:null,note:"empty matcher → matches all"};const o=n&&typeof n=="object"&&"tool_name"in n?String(n.tool_name??""):null;if(o==null)return{matched:!1,target:null,note:"payload has no tool_name to match against"};try{return{matched:new RegExp(`^(?:${t})$`).test(o),target:o}}catch{return{matched:t===o,target:o,note:"matcher not valid regex; fell back to exact match"}}}function Fe({event:t,matcher:n,command:o,onClose:l}){const[c,f]=d.useState(()=>Se(t)),[m,x]=d.useState(!1),[r,u]=d.useState(null),[s,S]=d.useState(null);let g=null;try{JSON.parse(c)}catch(p){g=p.message}const j=async()=>{x(!0),u(null);let p=null;try{p=JSON.parse(c)}catch{}S(Ce(n,p));try{const w=await window.api.app.testFireHook({command:o,payload:c,timeoutMs:5e3});u(w)}finally{x(!1)}};return e.jsx(ie,{open:!0,onClose:l,title:`Test fire — ${t}`,children:e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"resolved command"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1 break-all",children:o})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1",children:n||e.jsx("span",{className:"text-fg-faint",children:"(empty — matches all)"})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-fg-faint",children:"fake event payload (stdin)"}),g?e.jsxs("span",{className:"text-red-400",children:["× ",g]}):null]}),e.jsx("textarea",{value:c,onChange:p=>f(p.target.value),rows:8,className:`w-full bg-bg border rounded px-2 py-1 font-mono text-fg ${g?"border-red-500/70":"border-line"}`})]}),s?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher result"}),e.jsxs("div",{className:"font-mono",children:[e.jsx("span",{className:s.matched?"text-green-400":"text-red-400",children:s.matched?"✓ match":"✗ no match"}),s.target!=null?e.jsxs("span",{className:"text-fg-dim",children:[' · target tool_name="',s.target,'"']}):null,s.note?e.jsx("div",{className:"text-fg-faint",children:s.note}):null]})]}):null,r?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-fg-faint",children:["exit ",r.exitCode," · ",r.durationMs,"ms"]}),r.stdout?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"stdout"}),e.jsx("pre",{className:"bg-bg border border-line rounded p-2 font-mono text-fg whitespace-pre-wrap break-all max-h-40 overflow-auto",children:r.stdout})]}):null,r.stderr?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"stderr"}),e.jsx("pre",{className:"bg-bg border border-line rounded p-2 font-mono text-red-300 whitespace-pre-wrap break-all max-h-40 overflow-auto",children:r.stderr})]}):null]}):null,e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:l,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"close"}),e.jsx("button",{onClick:j,disabled:m||!!g||!o.trim(),className:"px-2 py-0.5 text-xs border border-line rounded text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:m?"running…":"run"})]})]})})}export{qe as Hooks};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{aw as d,aS as z,aM as H,aU as U,aN as N,aj as W,ao as q,ad as G,ah as e,m as w,P as D,aD as Q}from"./index-v_3LvhMx.js";import{P as A}from"./Panel-Cyt1wpUf.js";import{S as X}from"./ScopeSwitcher-BM0gLPhd.js";import{S as Y}from"./SaveBar-BuYrg5E9.js";import{P as Z}from"./Library-rqaJJJ1b.js";import{u as ee,E as te,s as se}from"./settingsSchema-CE46TA3V.js";import{V as re}from"./ViewTabs-BHV3MA5u.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-CRLhoI2K.js";import"./claude-settings-schema-COigsajx.js";const ne=["allow","deny","ask"];function oe(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function ae(r,n){const o={...r,permissions:n};return JSON.stringify(o,null,2)+`
|
|
2
|
-
`}function ie(){const r=z(),n=H(),o=(n==null?void 0:n.cwd)??null,s=U(t=>t.navFace),i=d.useRef(!1),u=d.useRef(s),[x,c]=d.useState(()=>s==="project"&&o?"project":"user"),[m,P]=d.useState("effective");d.useEffect(()=>{if(u.current!==s){if(u.current=s,i.current){i.current=!1;return}c(s==="project"&&o?"project":"user")}},[s,o]),d.useEffect(()=>{s==="project"&&m==="presets"&&P("effective")},[s,m]);const J=t=>{i.current=!0,c(t)},b=ee(D,r,o),f=b[x]??null,j=N(t=>t.files),E=N(t=>t.setDraft),M=N(t=>t.saveJson),O=N(t=>t.revert),[I,y]=d.useState(null),k=e.jsx(re,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:m,onChange:P}),$=d.useMemo(()=>{const t=W(q(j,b));return G(t,["permissions"])??{kind:"object",children:{}}},[j,b]),F=(t,l)=>{var R;const a=b[x];if(!a)return;y(null);const g=((R=j[a])==null?void 0:R.draftRaw)??"";let v={};if(g.trim())try{v=JSON.parse(g)}catch{v={}}const B=Q(v.permissions??{},t,l),K={...v,permissions:B};E(a,JSON.stringify(K,null,2)+`
|
|
3
|
-
`)};if(!r)return e.jsx(w,{title:"loading…"});if(m==="presets")return e.jsx(A,{toolbar:k,children:e.jsx(Z,{})});const C=t=>t!=="user"&&!o,h=f?j[f]:null,{perms:p,full:L,err:T}=h?oe(h.draftRaw):{perms:{},full:{},err:null},S=t=>{f&&(y(null),E(f,ae(L,t)))},_=(t,l)=>{const a=l.trim();if(!a)return;const g=p[t]??[];g.includes(a)||S({...p,[t]:[...g,a]})},V=(t,l)=>{const a=p[t]??[];S({...p,[t]:a.filter((g,v)=>v!==l)})};return e.jsx(A,{toolbar:e.jsxs(e.Fragment,{children:[k,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(X,{scopes:D.scopes,active:x,onChange:J,annotate:t=>{if(C(t))return{exists:!1};const l=b[t];if(!l)return null;const a=j[l];return{exists:(a==null?void 0:a.exists)??!1,dirty:(a==null?void 0:a.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:f??"—"}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings#permissions",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"rule syntax ↗"})]}),footer:f&&h?e.jsx(Y,{dirty:h.dirty,busy:h.busy,parseError:I||T||h.parseError,lastSavedAt:h.lastSavedAt,onSave:async()=>{y(null);const t=await M(f);t.ok||y(t.error??"save failed")},onRevert:()=>{y(null),O(f)}}):null,children:C(x)?e.jsx(w,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):m==="effective"?e.jsx(te,{node:$,targetScope:x,onOverride:F,schema:se().rootedAt(["permissions"]),rootLabel:"permissions"}):f&&h?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[e.jsx(le,{value:p.defaultMode??"default",onChange:t=>S({...p,defaultMode:t})}),ne.map(t=>e.jsx(ce,{list:t,rules:p[t]??[],onAdd:l=>_(t,l),onRemove:l=>V(t,l)},t)),e.jsx(de,{dirs:p.additionalDirectories??[],onChange:t=>S({...p,additionalDirectories:t})})]}):e.jsx(w,{title:"resolving…"})})}const ye=d.memo(ie);function le({value:r,onChange:n}){const o=["default","acceptEdits","plan","bypassPermissions"];return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Default Mode"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:o.map(s=>e.jsx("button",{onClick:()=>n(s),className:`px-2.5 py-1 text-xs transition-colors ${r===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ce({list:r,rules:n,onAdd:o,onRemove:s}){const[i,u]=d.useState(""),x=r==="allow"?"text-green-400":r==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${x}`,children:r}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,onChange:c=>u(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(o(i),u(""))},placeholder:r==="allow"?"e.g. Bash(ls:*) or Read(~/.claude/**)":"e.g. Write(/etc/**)",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"}),e.jsx("button",{onClick:()=>{o(i),u("")},disabled:!i.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((c,m)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:c}),e.jsx("button",{onClick:()=>s(m),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${m}-${c}`))})]})}function de({dirs:r,onChange:n}){const[o,s]=d.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:o,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&o.trim()&&(n([...r,o.trim()]),s(""))},placeholder:"/absolute/path/to/dir",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"})}),e.jsx("ul",{className:"space-y-0.5",children:r.map((i,u)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:i}),e.jsx("button",{onClick:()=>n(r.filter((x,c)=>c!==u)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${u}-${i}`))})]})}export{ye as Permissions};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-D0Hgdfxq.js","./index-v_3LvhMx.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-tr1w3hHB.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{ah as e,aw as h,m as k,aS as X,aL as V,a as Y}from"./index-v_3LvhMx.js";import{P as W}from"./Panel-Cyt1wpUf.js";import{P as z}from"./ProvenanceBadge-C_sk5-v3.js";import{u as Z}from"./useConfigDirWatch-CjcswsWR.js";import{e as ee}from"./Library-rqaJJJ1b.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as te}from"./monaco-editor-BsIlgG7c.js";import{L as ne}from"./ListDetail-qI27OYfy.js";import{M as se}from"./MarkdownEditor-BEFuHVNz.js";import"./Button-CRLhoI2K.js";function ie({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:m}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:m??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(p=>e.jsx("td",{className:`px-3 py-1 ${p.className??""}`,children:p.render(l)},p.key))},r)})})]})}async function ae(t,n,o){var p,g;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const m=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!m)return null;const l=(g=(p=i.plugins[m])==null?void 0:p[0])==null?void 0:g.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function le(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,m=await window.api.config.readText(i);if(!m.exists)continue;const l=G(m.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function re(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const m=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${m}\\b`,`\`${m}\``];if(i.id.length>=4&&l.push(`\\b${m}\\b`),!l.some(p=>new RegExp(p,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const oe=h.lazy(()=>te(()=>import("./SkillReferenceGraph-D0Hgdfxq.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function ce({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var g;const[i,m]=h.useState(a??((g=n[0])==null?void 0:g.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=h.useMemo(()=>re(n),[n]),[d,p]=h.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>p("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>p("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(k,{title:"no skills in this plugin"}):d==="graph"?e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(oe,{skills:n,edges:r,selectedId:i,onSelect:m})}):e.jsx(ne,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>m(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(se,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(k,{title:"select a skill"})})})]})}const Q=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function de(){const t=X(),[n,o]=h.useState([]),[a,i]=h.useState(!0),[m,l]=h.useState(null),[r,d]=h.useState("installed"),[p,g]=h.useState(null),[c,E]=h.useState(new Set);h.useEffect(()=>{var x,v;let s=!1;return(v=(x=window.api.app).seedStatus)==null||v.call(x).then(j=>{s||g(j)}).catch(()=>{}),()=>{s=!0}},[]);const w=h.useRef(0),$=h.useCallback(async()=>{var v;const s=++w.current;if(!t)return;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const M=j.data;for(const[O,u]of Object.entries(M.plugins??{})){if(!Array.isArray(u))continue;const y=O.split("@")[0],I=O.split("@")[1];for(const b of u){if(!(b!=null&&b.installPath))continue;const R={name:y,path:b.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},P=await pe(R);(v=P.manifest)!=null&&v.version||(P.manifest={...P.manifest??{},version:b.version}),P.marketplace=I,x.push(P)}}}}catch{}w.current===s&&(x.sort((j,M)=>j.name.localeCompare(M.name)),o(x),i(!1))},[t]);h.useEffect(()=>{$()},[$]),h.useEffect(()=>()=>{w.current+=1},[]),Z(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],$);const D=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(z,{interactive:!1,input:Q(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],f=h.useMemo(()=>p?Object.keys(p).filter(s=>p[s].status==="exhausted"&&!c.has(s)):[],[p,c]),C=f.length>0?e.jsx(me,{seeders:f,seedStatus:p,onDismiss:s=>E(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(W,{toolbar:e.jsx(q,{active:r,onChange:d}),children:[C,e.jsx(ee,{})]});const S=m?n.find(s=>s.path===m)??null:null;return e.jsxs(W,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(q,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[C,a?e.jsx(k,{title:"scanning plugins…"}):S?e.jsx(he,{row:S,home:t,onBack:()=>l(null)},S.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ie,{columns:D,rows:n,getKey:s=>s.path,activeKey:m,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const Se=h.memo(de),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function me({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[K[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${K[i]} warning`,children:"✕"})]},i))})}function q({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function he({row:t,home:n,onBack:o}){var x,v,j,M,O;const[a,i]=h.useState([]),[m,l]=h.useState([]),[r,d]=h.useState([]),[p,g]=h.useState([]),[c,E]=h.useState("skills"),[w,$]=h.useState(null),[D,f]=h.useState(!0);h.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{f(!0);try{const[y,I,b,R]=await Promise.all([ae(t.name,t.path,n),F(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),F(`${t.path}/bin`,{filesOnly:!0})]),P=y?await le(y):[],T=I.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),H=[];T.forEach((N,B)=>{const A=U[B];if(!A.exists)return;const _=G(A.text);H.push({id:N,name:_.name??N.replace(/\.md$/,""),description:_.description})});const J=[];if(b&&b.exists&&!b.parseError&&b.data&&typeof b.data=="object"){const N=b.data.mcpServers;if(N&&typeof N=="object")for(const[B,A]of Object.entries(N)){const _=A&&typeof A=="object"?A.command:void 0;J.push({id:B,name:B,description:typeof _=="string"?_:null})}}if(u)return;i(P),l(H),d(J),g(R),E(P.length>0?"skills":H.length>0?"agents":J.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(y){if(u)return;V.error(`Failed to load plugin contents: ${y instanceof Error?y.message:String(y)}`),i([]),l([]),d([]),g([])}finally{u||f(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const C=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:m.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],S=(x=t.manifest)!=null&&x.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,s=async u=>{const y=await window.api.shell.open({as:"external",url:u});y.ok||V.error(y.error??`Failed to open ${u}`)};return w?e.jsx(ce,{pluginName:((v=t.manifest)==null?void 0:v.name)??t.name,skills:a,initialSelectedId:w.id,onBack:()=>$(null)},w.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((j=t.manifest)==null?void 0:j.name)??t.name}),(M=t.manifest)!=null&&M.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(O=t.manifest)!=null&&O.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(z,{input:Q(t)}),t.hasMcp?e.jsx(Y,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[S?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),S]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>s(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:C.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>E(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:D?e.jsx(k,{title:"scanning…"}):e.jsx(fe,{active:c,row:t,skills:a,agents:m,mcpServers:r,files:p,onOpenSkill:$})})]})]})}function fe({active:t,row:n,skills:o,agents:a,mcpServers:i,files:m,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(L,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(k,{title:"no components"}):m.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:m.map((r,d)=>e.jsx(L,{n:d+1,name:r,description:null},r))})}function L({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function pe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const f=await window.api.config.readJson(n);f.exists&&!f.parseError&&f.data&&typeof f.data=="object"&&(a=f.data)}const[i,m,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const f=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(f.data)?d=f.data.length:f.data&&typeof f.data=="object"&&Array.isArray(f.data.monitors)&&(d=f.data.monitors.length)}let p=0;if(r){const f=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(f.data&&typeof f.data=="object"){const C=f.data;p=Object.values(C).reduce((S,s)=>Array.isArray(s)?S+s.reduce((x,v)=>x+(Array.isArray(v.hooks)?v.hooks.length:0),0):S,0)}}const[g,c,E]=await Promise.all([F(`${t.path}/agents`,{filesOnly:!0}),F(`${t.path}/bin`,{filesOnly:!0}),F(`${t.path}/skills`,{dirsOnly:!0})]),w=g.filter(f=>f.endsWith(".md")).length,$=c.length,D=E.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:p,agents:w,skills:D,binCount:$,hasMcp:m}}async function F(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{Se as Plugins};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as P,aS as G,aw as x,ah as i,Z as _,B as R,a as T}from"./index-v_3LvhMx.js";import{a as S,C as B,c as E,d as L,b as I}from"./Library-rqaJJJ1b.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(E.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(E.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(S.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(S.map(e=>e.command.trim())),F=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),w=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?w("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?w("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?w("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&F.has(t))return l("built-in Claude Code command");if(Q.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?w(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[y,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!y)return;const s=C=>{v.current&&!v.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[y]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(T,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:v,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),y&&i.jsxs("span",{className:`absolute ${_.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(b,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${R[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(b,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
|