@statforge/claudestat 1.6.1 → 1.8.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 (63) hide show
  1. package/README.md +36 -3
  2. package/dashboard/dist/assets/AnalyticsView-DDGLDoCN.js +7 -0
  3. package/dashboard/dist/assets/HistoryView-DkPfrNrv.js +1 -0
  4. package/dashboard/dist/assets/LineChart-BOWYkkEW.js +2 -0
  5. package/dashboard/dist/assets/ProjectsView-VRoRiEL4.js +6 -0
  6. package/dashboard/dist/assets/SystemView-B2zbIxhY.js +1 -0
  7. package/dashboard/dist/assets/TopView-C2qdsy0Y.js +1 -0
  8. package/dashboard/dist/assets/index-CMhe3KaT.js +84 -0
  9. package/dashboard/dist/assets/shared-BbBtsdh1.js +1 -0
  10. package/dashboard/dist/assets/{vendor-lucide-Cym0q5l_.js → vendor-lucide-ClCW-axQ.js} +79 -64
  11. package/dashboard/dist/assets/{vendor-react-B_Jzs0gY.js → vendor-react-gHSHIE2L.js} +1 -1
  12. package/dashboard/dist/index.html +3 -3
  13. package/dist/config.d.ts +7 -0
  14. package/dist/config.js +36 -0
  15. package/dist/daemon.js +113 -9
  16. package/dist/db.d.ts +87 -2
  17. package/dist/db.js +325 -65
  18. package/dist/doctor.js +21 -3
  19. package/dist/enricher.d.ts +3 -2
  20. package/dist/enricher.js +10 -5
  21. package/dist/export.d.ts +2 -1
  22. package/dist/export.js +41 -6
  23. package/dist/index.js +406 -20
  24. package/dist/insights.d.ts +1 -0
  25. package/dist/insights.js +26 -0
  26. package/dist/install.js +28 -1
  27. package/dist/intelligence.d.ts +66 -4
  28. package/dist/intelligence.js +205 -17
  29. package/dist/logger.d.ts +6 -0
  30. package/dist/logger.js +49 -0
  31. package/dist/notifier.d.ts +15 -0
  32. package/dist/notifier.js +26 -0
  33. package/dist/paths.d.ts +23 -0
  34. package/dist/paths.js +42 -0
  35. package/dist/pricing.d.ts +2 -0
  36. package/dist/pricing.js +12 -1
  37. package/dist/routes/events.js +136 -5
  38. package/dist/routes/helpers.d.ts +5 -0
  39. package/dist/routes/helpers.js +21 -1
  40. package/dist/routes/history.js +6 -2
  41. package/dist/routes/intents.d.ts +1 -0
  42. package/dist/routes/intents.js +155 -0
  43. package/dist/routes/misc.js +150 -4
  44. package/dist/routes/opencode-reader.js +39 -3
  45. package/dist/routes/projects.js +19 -1
  46. package/dist/routes/replay.d.ts +1 -0
  47. package/dist/routes/replay.js +29 -0
  48. package/dist/routes/reports.js +7 -0
  49. package/dist/routes/top.js +8 -1
  50. package/dist/service.js +11 -0
  51. package/dist/watchers/adapter.d.ts +1 -0
  52. package/dist/watchers/claude-code.d.ts +16 -1
  53. package/dist/watchers/claude-code.js +201 -76
  54. package/dist/watchers/opencode.d.ts +1 -0
  55. package/dist/watchers/opencode.js +152 -14
  56. package/hooks/event.js +44 -26
  57. package/package.json +1 -1
  58. package/dashboard/dist/assets/AnalyticsView-5bUM3UHp.js +0 -8
  59. package/dashboard/dist/assets/HistoryView-C-AsEqos.js +0 -1
  60. package/dashboard/dist/assets/ProjectsView-D9bZBdY2.js +0 -6
  61. package/dashboard/dist/assets/SystemView-DIYDCCF3.js +0 -1
  62. package/dashboard/dist/assets/TopView-DhdLpsiA.js +0 -1
  63. package/dashboard/dist/assets/index-DgbWvj42.js +0 -84
@@ -1 +0,0 @@
1
- import{j as e,T as l}from"./index-DgbWvj42.js";import{a as u,E as F,c as E,d as G,J as P,K as L,H as N,j as C,X as _,N as V,O as q,Q as R}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";const v={Read:"#58a6ff",Write:"#3fb950",Edit:"#3fb950",Bash:"#d29922",Glob:"#79c0ff",Grep:"#79c0ff",WebSearch:"#56d364",WebFetch:"#56d364",Agent:"#bc8cff",Skill:"#58a6ff",TodoWrite:"#8b949e",TodoRead:"#8b949e",Task:"#8b949e",default:"#6e7681"},T={directo:"direct",agentes:"agents",skills:"skills","agentes+skills":"agents+skills"},K={directo:"#7d8590",agentes:"#d29922",skills:"#58a6ff","agentes+skills":"#d29922"},Q={directo:"Claude responded directly, without launching sub-agents or invoking skills",agentes:"Sub-agents (Agent tool) were launched during the session",skills:"Skills (Skill tool) were invoked during the session","agentes+skills":"Both sub-agents and skills were used in this session"};function D(t){return new Date(t).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})}function Y(t){const o=Math.floor(t/36e5),n=Math.floor(t%36e5/6e4);return o>0?`${o}h ${n}m`:n>0?`${n}m`:"<1m"}function J(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}const a={card:(t,o)=>({background:o?"#1a2332":t?"#1c2128":"#161b22",border:`1px solid ${o?"#58a6ff80":t?"#1f6feb":"#21262d"}`,borderRadius:8,padding:"10px 14px",display:"flex",flexDirection:"column",gap:6,cursor:"pointer",transition:"border-color 0.15s, background 0.15s"}),row:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},dim:{color:"#7d8590",fontSize:11},badge:t=>({color:t,background:t+"18",border:`1px solid ${t}30`,borderRadius:4,padding:"1px 6px",fontSize:10,fontWeight:600,display:"inline-flex",alignItems:"center",gap:3}),sep:{color:"#21262d",userSelect:"none",fontSize:11}};function X({session:t,isActive:o,selectable:n,selected:r=!1,onSelect:f}){const m=K[t.mode]??"#7d8590",d=t.efficiency_score>=90?"#3fb950":t.efficiency_score>=70?"#d29922":"#f85149";return e.jsxs("div",{style:a.card(!!o,r),onClick:()=>n&&(f==null?void 0:f(t.id)),children:[e.jsxs("div",{style:a.row,children:[n&&e.jsx("div",{style:{width:15,height:15,borderRadius:3,flexShrink:0,border:`2px solid ${r?"#58a6ff":"#484f58"}`,background:r?"#58a6ff":"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:r&&e.jsx(F,{size:9,color:"#0d1117",strokeWidth:3})}),o&&e.jsxs("span",{style:{color:"#3fb950",fontSize:10,fontWeight:700,display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#3fb950",animation:"livePulse 1.2s ease-in-out infinite",display:"inline-block"}}),"LIVE"]}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Session interval"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Time of first event → last recorded event"})]}),children:e.jsxs("span",{style:a.dim,children:[D(t.started_at)," → ",D(t.last_event_at)]})}),e.jsx("span",{style:a.dim,children:"·"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Duration"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Elapsed time from the first to the last event in the session"})]}),children:e.jsx("span",{style:{...a.dim,fontWeight:600},children:Y(t.duration_ms)})}),t.project_name&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:a.sep,children:"│"}),e.jsxs("span",{style:{color:"#79c0ff",fontSize:11,display:"inline-flex",alignItems:"center",gap:3},children:[e.jsx(E,{size:10})," ",t.project_name]})]}),e.jsx("div",{style:{flex:1}}),e.jsx(l,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:m,fontWeight:700,fontSize:12,marginBottom:4},children:T[t.mode]??t.mode}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:Q[t.mode]??t.mode})]}),children:e.jsx("span",{style:a.badge(m),children:T[t.mode]??t.mode})})]}),e.jsxs("div",{style:a.row,children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"API Cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of all session blocks at Anthropic pricing"})]}),children:e.jsxs("span",{style:a.badge("#3fb950"),children:["$",t.total_cost_usd.toFixed(4)]})}),e.jsx("span",{style:a.dim,children:"·"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Input + Output + Cache read.",e.jsx("br",{}),"Cache read dominates in long sessions — it's the context resent on each API call."]})]}),children:e.jsxs("span",{style:{color:"#79c0ff",background:"#79c0ff22",border:"1px solid #79c0ff50",borderRadius:4,padding:"2px 8px",fontSize:11,fontWeight:700,display:"inline-flex",alignItems:"center",gap:3},children:[J(t.total_tokens)," tok"]})}),e.jsx("span",{style:a.sep,children:"│"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:d,fontWeight:700,fontSize:12,marginBottom:4},children:["Efficiency ",t.efficiency_score,"/100"]}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Score calculated by the daemon.",e.jsx("br",{}),"Penalizes detected loops, re-reads of the same file, and excessive context use."]})]}),children:e.jsxs("span",{style:a.badge(d),children:["efficiency ",t.efficiency_score,"/100"]})}),t.loops_detected>0&&e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#f85149",fontWeight:700,fontSize:12,marginBottom:4},children:"Detected loops"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:[t.loops_detected," loop",t.loops_detected!==1?"s":""," in this session.",e.jsx("br",{}),"Detected when the same action (tool + input) repeats ≥3 times without real progress."]})]}),children:e.jsxs("span",{style:a.badge("#f85149"),children:[e.jsx(G,{size:9})," ",t.loops_detected," loops"]})}),e.jsx("span",{style:a.sep,children:"│"}),e.jsx(l,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Tool calls"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Number of tools that completed execution (Done type) in this session"})]}),children:e.jsxs("span",{style:a.dim,children:[t.done_count," tools"]})})]}),t.top_tools.length>0&&e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:6},children:"Most used tools"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:t.top_tools.map((c,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:v[c]??v.default,flexShrink:0}}),e.jsx("span",{style:{color:"#c9d1d9",fontSize:10},children:c}),h===0&&e.jsx("span",{style:{color:"#484f58",fontSize:9},children:"— most frequent"})]},h))})]}),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[t.top_tools.slice(0,12).map((c,h)=>e.jsx("span",{style:{width:12,height:4,borderRadius:2,flexShrink:0,background:v[c]??v.default,opacity:Math.max(.2,1-h*.07)}},h)),e.jsxs("span",{style:{color:"#484f58",fontSize:9,marginLeft:5},children:[t.top_tools[0],t.top_tools.length>1?` +${t.top_tools.length-1}`:""]})]})}),t.git_branch&&e.jsx("div",{style:a.row,children:e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#8b949e",fontWeight:700,fontSize:12,marginBottom:6},children:"Git status"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{style:{color:"#c9d1d9",fontSize:10},children:["Branch: ",e.jsx("span",{style:{fontFamily:"monospace",color:"#79c0ff"},children:t.git_branch})]}),t.git_dirty&&e.jsx("div",{style:{color:"#d29922",fontSize:10},children:"* Local changes not committed"}),(t.git_ahead??0)>0&&e.jsxs("div",{style:{color:"#58a6ff",fontSize:10},children:["↑ ",t.git_ahead," commit",(t.git_ahead??0)!==1?"s":""," ahead of remote"]}),(t.git_behind??0)>0&&e.jsxs("div",{style:{color:"#d29922",fontSize:10},children:["↓ ",t.git_behind," commit",(t.git_behind??0)!==1?"s":""," behind remote"]}),!t.git_dirty&&!(t.git_ahead??0)&&!(t.git_behind??0)&&e.jsx("div",{style:{color:"#3fb950",fontSize:10},children:"Synced with remote"})]})]}),children:e.jsxs("span",{style:a.badge("#8b949e"),children:[e.jsx(P,{size:9}),t.git_branch,t.git_dirty?e.jsx("span",{style:{color:"#d29922"},children:"*"}):null,(t.git_ahead??0)>0?e.jsxs("span",{style:{color:"#58a6ff"},children:[" ↑",t.git_ahead]}):null,(t.git_behind??0)>0?e.jsxs("span",{style:{color:"#d29922"},children:[" ↓",t.git_behind]}):null]})})}),t.ai_summary&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,marginTop:2},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"AI Summary"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Automatically generated by the daemon when the session ends"})]}),children:e.jsx(L,{size:10,color:"#7d8590",style:{flexShrink:0,marginTop:1}})}),e.jsx("span",{style:{color:"#9198a1",fontSize:11,fontStyle:"italic",lineHeight:1.4},children:t.ai_summary})]})]})}const U=u.memo(X),I={directo:"#7d8590",agentes:"#d29922",skills:"#58a6ff","agentes+skills":"#d29922"};function A(t){const o=new Date(t+"T12:00:00"),n=new Date().toISOString().slice(0,10),r=new Date(Date.now()-864e5).toISOString().slice(0,10);return t===n?"Today":t===r?"Yesterday":o.toLocaleDateString("en",{weekday:"long",day:"numeric",month:"long"})}function z(t){const o=Math.floor(t/36e5),n=Math.floor(t%36e5/6e4);return o>0?`${o}h ${n}m`:`${n}m`}function b(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function x(t,o,n=!1){return t===o?{color:"#8b949e"}:{color:(n?t<o:t>o)?"#3fb950":"#f85149",fontWeight:700}}function Z({a:t,b:o,onClose:n}){const r=[{label:"Cost",tooltip:"Total API cost of the session. Green = cheaper (better).",va:`$${t.total_cost_usd.toFixed(4)}`,vb:`$${o.total_cost_usd.toFixed(4)}`,styleA:x(t.total_cost_usd,o.total_cost_usd,!0),styleB:x(o.total_cost_usd,t.total_cost_usd,!0)},{label:"Tokens",tooltip:"Input + Output + Cache read. Green = fewer tokens consumed (better).",va:b(t.total_tokens),vb:b(o.total_tokens),styleA:x(t.total_tokens,o.total_tokens,!0),styleB:x(o.total_tokens,t.total_tokens,!0)},{label:"Duration",tooltip:"Time between first and last event. Green = shorter session (better).",va:z(t.duration_ms),vb:z(o.duration_ms),styleA:x(t.duration_ms,o.duration_ms,!0),styleB:x(o.duration_ms,t.duration_ms,!0)},{label:"Efficiency",tooltip:"Score 0–100 calculated by the daemon. Penalizes loops, re-reads and excessive context. Green = more efficient (better).",va:`${t.efficiency_score}/100`,vb:`${o.efficiency_score}/100`,styleA:x(t.efficiency_score,o.efficiency_score,!1),styleB:x(o.efficiency_score,t.efficiency_score,!1)},{label:"Tools used",tooltip:"Number of completed tool calls (Done type). Green = fewer calls for the same result (better).",va:`${t.done_count} calls`,vb:`${o.done_count} calls`,styleA:x(t.done_count,o.done_count,!0),styleB:x(o.done_count,t.done_count,!0)},{label:"Loops",tooltip:"Detected loops: same action repeated ≥3 times without real progress. Green = none or fewer (better).",va:`${t.loops_detected} loop${t.loops_detected!==1?"s":""}`,vb:`${o.loops_detected} loop${o.loops_detected!==1?"s":""}`,styleA:x(t.loops_detected,o.loops_detected,!0),styleB:x(o.loops_detected,t.loops_detected,!0)},{label:"Mode",tooltip:"Detected mode: direct (no agents or skills), agents, skills, or both.",va:t.mode,vb:o.mode,styleA:{color:I[t.mode]??"#7d8590",fontWeight:600},styleB:{color:I[o.mode]??"#7d8590",fontWeight:600}}],f=t.project_name||t.id.slice(0,8),m=o.project_name||o.id.slice(0,8);return e.jsxs("div",{style:{margin:"0 0 20px 0",background:"#161b22",border:"1px solid #30363d",borderLeft:"3px solid #58a6ff",borderRadius:8,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid #21262d",background:"#1c2128"},children:[e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Session comparison"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Green = better · Red = worse",e.jsx("br",{}),"Metrics are compared against each other. For cost, tokens, duration and loops: less is better. For efficiency: more is better."]})]}),children:e.jsx(R,{size:14,color:"#58a6ff",style:{cursor:"default"}})}),e.jsx("span",{style:{color:"#e6edf3",fontWeight:700,fontSize:13},children:"Session comparison"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Session A"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[t.project_name??t.id.slice(0,8)," · ",new Date(t.started_at).toLocaleDateString("en",{day:"numeric",month:"short"})]})]}),children:e.jsx("span",{style:{color:"#58a6ff",fontSize:11,background:"#58a6ff18",borderRadius:4,padding:"1px 7px",border:"1px solid #58a6ff30",cursor:"default"},children:new Date(t.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})}),e.jsx("span",{style:{color:"#6e7681",fontSize:11},children:"vs"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:12,marginBottom:4},children:"Session B"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[o.project_name??o.id.slice(0,8)," · ",new Date(o.started_at).toLocaleDateString("en",{day:"numeric",month:"short"})]})]}),children:e.jsx("span",{style:{color:"#bc8cff",fontSize:11,background:"#bc8cff18",borderRadius:4,padding:"1px 7px",border:"1px solid #bc8cff30",cursor:"default"},children:new Date(o.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:n,style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(_,{size:14})})]}),e.jsxs("div",{style:{padding:"0 0 8px 0"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"6px 16px",borderBottom:"1px solid #21262d"},children:[e.jsx("span",{style:{color:"#484f58",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Metric"}),e.jsx("span",{style:{color:"#58a6ff",fontSize:10,fontWeight:700},children:f}),e.jsx("span",{style:{color:"#bc8cff",fontSize:10,fontWeight:700},children:m})]}),r.map((d,c)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"5px 16px",background:c%2===0?"transparent":"#ffffff08"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:d.label}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:d.tooltip})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:11,cursor:"default"},children:d.label})}),e.jsx("span",{style:{fontSize:12,...d.styleA},children:d.va}),e.jsx("span",{style:{fontSize:12,...d.styleB},children:d.vb})]},c)),(t.top_tools.length>0||o.top_tools.length>0)&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"5px 16px"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Top tools"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Most invoked tools in each session, sorted by frequency"})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:11,cursor:"default"},children:"Top tools"})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:(t.top_tools.length>0?t.top_tools:["—"]).map((d,c)=>e.jsx("span",{style:{color:"#8b949e",fontSize:10,background:"#ffffff08",borderRadius:3,padding:"1px 5px"},children:d},c))}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:(o.top_tools.length>0?o.top_tools:["—"]).map((d,c)=>e.jsx("span",{style:{color:"#8b949e",fontSize:10,background:"#ffffff08",borderRadius:3,padding:"1px 5px"},children:d},c))})]})]}),(t.ai_summary||o.ai_summary)&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,padding:"10px 16px",borderTop:"1px solid #21262d"},children:[{s:t,color:"#58a6ff"},{s:o,color:"#bc8cff"}].map(({s:d,color:c})=>e.jsxs("div",{style:{background:c+"08",border:`1px solid ${c}20`,borderRadius:6,padding:"7px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:4},children:[e.jsx(L,{size:10,color:c}),e.jsx("span",{style:{color:c,fontSize:10,fontWeight:700},children:new Date(d.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("span",{style:{color:"#9198a1",fontSize:11,fontStyle:"italic",lineHeight:1.4},children:d.ai_summary??e.jsx("span",{style:{color:"#484f58"},children:"No summary"})})]},d.id))})]})}const p={wrap:{padding:"16px 24px",overflowY:"auto",height:"100%"},dayWrap:{marginBottom:28},dayHead:{display:"flex",alignItems:"center",gap:16,marginBottom:10,paddingBottom:6,borderBottom:"1px solid #21262d"},dayLabel:{color:"#e6edf3",fontWeight:700,fontSize:14},dayStat:{color:"#7d8590",fontSize:11},badge:t=>({color:t,background:t+"18",border:`1px solid ${t}30`,borderRadius:4,padding:"1px 7px",fontSize:11,fontWeight:600}),sessions:{display:"flex",flexDirection:"column",gap:8},empty:{padding:"60px 24px",color:"#7d8590",textAlign:"center",fontSize:13}};function ee({days:t,activeSessionId:o}){return e.jsxs("div",{style:{paddingLeft:8},children:[e.jsx("style",{children:"@keyframes livePulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(1.5)} }"}),t.map(n=>e.jsxs("div",{style:{marginBottom:28},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10},children:[e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:"#30363d",border:"2px solid #484f58",flexShrink:0}}),e.jsx("div",{style:{height:1,width:12,background:"#21262d"}}),e.jsx("span",{style:{color:"#8b949e",fontSize:12,fontWeight:700},children:A(n.date)}),e.jsxs("span",{style:{color:"#484f58",fontSize:11},children:[n.sessions.length," ses. · $",n.total_cost.toFixed(3)," · ",b(n.total_tokens)]})]}),e.jsxs("div",{style:{position:"relative",paddingLeft:28},children:[e.jsx("div",{style:{position:"absolute",left:4,top:0,bottom:0,width:2,background:"#21262d",borderRadius:1}}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.sessions.map(r=>{const f=r.efficiency_score>=90?"#3fb950":r.efficiency_score>=70?"#d29922":"#f85149",m=r.id===o;return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:f,fontWeight:700,fontSize:12,marginBottom:4},children:["Efficiency ",r.efficiency_score,"/100"]}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Green ≥90 · Amber ≥70 · Red <70",e.jsx("br",{}),"Penalizes loops, re-reads and excessive context"]})]}),children:e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,marginTop:6,background:f,border:"2px solid #0d1117",boxShadow:`0 0 6px ${f}66`,position:"relative",zIndex:1,animation:m?"livePulse 1.5s ease-in-out infinite":void 0,cursor:"default"}})}),e.jsx("div",{style:{flex:1,background:"#161b22",border:`1px solid ${m?"#1f6feb":"#21262d"}`,borderRadius:7,padding:"7px 12px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Start time"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"First recorded event of the session"})]}),children:e.jsx("span",{style:{color:"#6e7681",fontSize:10,fontFamily:"monospace",cursor:"default"},children:new Date(r.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})})}),r.project_name&&e.jsx("span",{style:{color:"#79c0ff",fontSize:11,fontWeight:600},children:r.project_name}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"API Cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Sum of all session blocks"})]}),children:e.jsxs("span",{style:{color:"#3fb950",fontSize:10,fontWeight:600,cursor:"default"},children:["$",r.total_cost_usd.toFixed(4)]})}),e.jsx("span",{style:{color:"#484f58",fontSize:10},children:"·"}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:f,fontWeight:700,fontSize:12,marginBottom:4},children:"Efficiency"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Score 0–100. Penalizes loops, re-reads and excessive context"})]}),children:e.jsxs("span",{style:{color:f,fontSize:10,cursor:"default"},children:[r.efficiency_score,"/100"]})}),e.jsx(l,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Input + Output + Cache read"})]}),children:e.jsxs("span",{style:{color:"#484f58",fontSize:10,cursor:"default"},children:["· ",b(r.total_tokens)," tok"]})}),r.ai_summary&&e.jsxs("span",{style:{color:"#7d8590",fontSize:10,fontStyle:"italic",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["— ",r.ai_summary]})]})})]},r.id)})})]})]},n.date))]})}const S=[{label:"All",min:null,max:null},{label:"< $0.01",min:null,max:.01},{label:"$0.01+",min:.01,max:null},{label:"$0.10+",min:.1,max:null},{label:"$1+",min:1,max:null}];function se({days:t,activeSessionId:o}){const[n,r]=u.useState([]),[f,m]=u.useState("list"),[d,c]=u.useState(""),[h,H]=u.useState(0),j=u.useMemo(()=>{const i=d.trim().toLowerCase(),s=S[h];return t.map(g=>({...g,sessions:g.sessions.filter(y=>{var B,$;return s.min!==null&&y.total_cost_usd<s.min||s.max!==null&&y.total_cost_usd>=s.max?!1:i?((B=y.project_name)==null?void 0:B.toLowerCase().includes(i))||y.top_tools.some(M=>M.toLowerCase().includes(i))||(($=y.ai_summary)==null?void 0:$.toLowerCase().includes(i))||y.id.includes(i):!0})})).filter(g=>g.sessions.length>0)},[t,d,h]),k=t.flatMap(i=>i.sessions),w=k.find(i=>i.id===n[0]),W=k.find(i=>i.id===n[1]);function O(i){r(s=>s.includes(i)?s.filter(g=>g!==i):s.length>=2?[s[1],i]:[...s,i])}return t.length===0?e.jsxs("div",{style:{...p.empty,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[e.jsx(N,{size:40,color:"#30363d"}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#6e7681",fontSize:14,fontWeight:600,marginBottom:4},children:"No sessions recorded"}),e.jsx("div",{style:{fontSize:11,color:"#484f58"},children:"Sessions appear here once the daemon processes them."})]})]}):e.jsxs("div",{style:p.wrap,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8,padding:"5px 10px",background:"#161b22",border:"1px solid #21262d",borderRadius:6},children:[e.jsx(C,{size:12,color:"#484f58"}),e.jsx("input",{type:"text",placeholder:"Search by project, tool or summary…",value:d,onChange:i=>c(i.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",color:"#c9d1d9",fontSize:12,fontFamily:"inherit"}}),d&&e.jsx("button",{onClick:()=>c(""),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(_,{size:12})}),e.jsx("div",{style:{width:1,height:16,background:"#21262d"}}),e.jsx("div",{style:{display:"flex",gap:3},children:S.map((i,s)=>{const g=s===0?"Show all sessions without filtering by cost":s===1?"Only sessions with cost under $0.01 — very short conversations":s===2?"Sessions with cost of $0.01 or more — real work":s===3?"Sessions with cost of $0.10 or more — intensive work":"Sessions with cost of $1 or more — long or high-complexity sessions";return e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:["Filtro: ",i.label]}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:g})]}),children:e.jsx("button",{onClick:()=>H(s),style:{padding:"2px 7px",borderRadius:4,border:`1px solid ${h===s?"#3fb95060":"#21262d"}`,background:h===s?"#1a2d1a":"transparent",color:h===s?"#3fb950":"#6e7681",fontSize:10,fontWeight:600,cursor:"pointer"},children:i.label})},s)})}),(d||h>0)&&e.jsxs("span",{style:{color:"#484f58",fontSize:10},children:[j.reduce((i,s)=>i+s.sessions.length,0)," result",j.reduce((i,s)=>i+s.sessions.length,0)!==1?"s":""]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,padding:"6px 10px",background:"#161b22",border:"1px solid #21262d",borderRadius:6},children:[e.jsx("div",{style:{display:"flex",gap:2,background:"#0d1117",borderRadius:5,padding:2},children:[["list",V,"List","Card view grouped by day. Shows all details for each session."],["timeline",q,"Timeline","Chronological view with a timeline. Shows the session flow for the day."]].map(([i,s,g,y])=>e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:g}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:y})]}),children:e.jsxs("button",{onClick:()=>m(i),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:4,border:"none",cursor:"pointer",fontSize:10,fontWeight:600,background:f===i?"#21262d":"transparent",color:f===i?"#e6edf3":"#6e7681",transition:"all 0.15s"},children:[e.jsx(s,{size:10}),g]})},i))}),e.jsx("div",{style:{width:1,height:16,background:"#21262d"}}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Compare sessions"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Click 2 sessions to compare their metrics.",e.jsx("br",{}),"If 2 are already selected, the new one replaces the oldest."]})]}),children:e.jsx(R,{size:12,color:"#58a6ff",style:{cursor:"default"}})}),e.jsx("span",{style:{color:"#6e7681",fontSize:11},children:n.length===0?"Select 2 sessions to compare":n.length===1?"Select 1 more":"Comparing 2 sessions"}),n.length>0&&e.jsx("button",{onClick:()=>r([]),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex",marginLeft:"auto"},children:e.jsx(_,{size:12})})]}),w&&W&&e.jsx(Z,{a:w,b:W,onClose:()=>r([])}),j.length===0&&(d||h>0)&&e.jsxs("div",{style:{...p.empty},children:[e.jsx(C,{size:32,color:"#30363d",style:{marginBottom:8}}),e.jsxs("div",{style:{color:"#6e7681",fontSize:13},children:['No results for "',d||S[h].label,'"']})]}),f==="timeline"?e.jsx(ee,{days:j,activeSessionId:o}):j.map(i=>e.jsxs("div",{style:p.dayWrap,children:[e.jsxs("div",{style:p.dayHead,children:[e.jsx("span",{style:p.dayLabel,children:A(i.date)}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Day sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Number of Claude Code sessions recorded this day"})]}),children:e.jsxs("span",{style:{...p.dayStat,cursor:"default"},children:[i.sessions.length," session",i.sessions.length>1?"s":""]})}),e.jsx("span",{style:p.dayStat,children:"·"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Accumulated duration"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Sum of the duration of all sessions in the day"})]}),children:e.jsx("span",{style:{...p.dayStat,cursor:"default"},children:z(i.total_duration_ms)})}),e.jsx("span",{style:p.dayStat,children:"·"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Day cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Sum of API costs of all sessions in the day"})]}),children:e.jsxs("span",{style:{...p.badge("#3fb950"),cursor:"default"},children:["$",i.total_cost.toFixed(3)]})}),e.jsx("span",{style:p.dayStat,children:"·"}),e.jsx(l,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Day tokens"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of tokens (input + output + cache read) of all sessions in the day"})]}),children:e.jsxs("span",{style:{...p.dayStat,cursor:"default"},children:[b(i.total_tokens)," tokens"]})})]}),e.jsx("div",{style:p.sessions,children:i.sessions.map(s=>e.jsx(U,{session:s,isActive:s.id===o,selectable:!0,selected:n.includes(s.id),onSelect:O},s.id))})]},i.date))]})}export{se as HistoryView};
@@ -1,6 +0,0 @@
1
- import{j as e,T as a}from"./index-DgbWvj42.js";import{a as j,c as b,d as m,U as y,V as k,Y as S,f as z,F as w}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";function p(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function u(t){return t>0&&t<.01?"<$0.01":`$${t.toFixed(2)}`}function T(t){if(!t)return null;const{opusTokens:n,sonnetTokens:l,haikuTokens:s}=t;return n===0&&l===0&&s===0?null:n>=l&&n>=s?{label:"Opus",color:"#d29922"}:l>=s?{label:"Sonnet",color:"#58a6ff"}:{label:"Haiku",color:"#3fb950"}}function W(t){if(!t)return"never";const n=Date.now()-t;return n<6e4?"just now":n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:n<7*864e5?`${Math.round(n/864e5)}d ago`:new Date(t).toLocaleDateString("en",{day:"numeric",month:"short"})}function F({usage:t}){const n=t.opusTokens+t.sonnetTokens+t.haikuTokens;if(n===0)return null;const l=[{label:"Sonnet",tokens:t.sonnetTokens,color:"#58a6ff"},{label:"Opus",tokens:t.opusTokens,color:"#d29922"},{label:"Haiku",tokens:t.haikuTokens,color:"#3fb950"}].filter(s=>s.tokens>0);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:6},children:"Usage by model"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:l.map(s=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:s.color,flexShrink:0}}),e.jsx("span",{style:{color:s.color,fontSize:10,fontWeight:700,width:42},children:s.label}),e.jsxs("span",{style:{color:"#c9d1d9",fontSize:10},children:[p(s.tokens)," tok"]}),e.jsxs("span",{style:{color:"#484f58",fontSize:9},children:[Math.round(s.tokens/n*100),"%"]})]},s.label))})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:10,marginBottom:1},children:"model usage"})}),e.jsx("div",{style:{display:"flex",height:5,borderRadius:3,overflow:"hidden",gap:1},children:l.map(s=>e.jsx("div",{style:{height:"100%",width:`${Math.round(s.tokens/n*100)}%`,background:s.color,minWidth:s.tokens>0?2:0}},s.label))}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:l.map(s=>e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:s.color,flexShrink:0}}),e.jsx("span",{style:{color:s.color,fontSize:9,fontWeight:700},children:s.label}),e.jsx("span",{style:{color:"#7d8590",fontSize:9},children:p(s.tokens)})]},s.label))})]})}const I={tip:"#58a6ff",warning:"#d29922",positive:"#3fb950"},H={tip:y,warning:m,positive:z};function C({insights:t}){const[n,l]=j.useState(!1);if(t.length===0)return null;const s=t.filter(r=>r.level==="warning").length,h=s>0?"#d29922":"#58a6ff";return e.jsxs("div",{style:{borderTop:"1px solid #21262d",paddingTop:8},children:[e.jsxs("button",{onClick:()=>l(r=>!r),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",cursor:"pointer",padding:"4px 0"},children:[e.jsxs("span",{style:{color:h,fontSize:11,fontWeight:700,display:"flex",alignItems:"center",gap:5},children:[s>0?e.jsx(m,{size:12}):e.jsx(y,{size:12}),t.length," insight",t.length>1?"s":"",s>0&&e.jsxs("span",{style:{color:"#d29922",fontSize:10},children:["· ",s," warning",s>1?"s":""]})]}),n?e.jsx(k,{size:14,color:"#484f58"}):e.jsx(S,{size:14,color:"#484f58"})]}),n&&e.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:t.map((r,x)=>{const c=I[r.level];return e.jsxs("div",{style:{background:c+"0d",border:`1px solid ${c}30`,borderRadius:6,padding:"7px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:3},children:[(()=>{const g=H[r.level];return e.jsx(g,{size:11,color:c})})(),e.jsx("span",{style:{color:c,fontSize:11,fontWeight:700},children:r.title}),r.metric&&e.jsx("span",{style:{color:"#7d8590",fontSize:9,marginLeft:"auto"},children:r.metric})]}),e.jsx("p",{style:{color:"#8b949e",fontSize:10,margin:0,lineHeight:1.5},children:r.description})]},x)})})]})}const i={card:t=>({background:t?"#1c2128":"#161b22",border:`1px solid ${t?"#1f6feb":"#21262d"}`,borderRadius:10,padding:"14px 16px",display:"flex",flexDirection:"column",gap:10,cursor:"default",transition:"border-color 0.2s"}),header:{display:"flex",alignItems:"center",gap:8},name:{color:"#e6edf3",fontWeight:700,fontSize:15,flex:1},activeBadge:{color:"#3fb950",background:"#3fb95018",border:"1px solid #3fb95030",borderRadius:4,padding:"1px 7px",fontSize:10,fontWeight:700},autoBadge:{color:"#7d8590",background:"#7d859015",border:"1px solid #7d859030",borderRadius:4,padding:"1px 6px",fontSize:9},path:{color:"#7d8590",fontSize:10,marginTop:-4},progressWrap:{display:"flex",flexDirection:"column",gap:4},progressRow:{display:"flex",alignItems:"center",justifyContent:"space-between"},progressLabel:{color:"#7d8590",fontSize:11},progressPct:t=>({color:t>=80?"#3fb950":t>=50?"#d29922":"#7d8590",fontWeight:700,fontSize:12}),barTrack:{height:6,background:"#21262d",borderRadius:3,overflow:"hidden"},barFill:t=>({height:"100%",width:`${t}%`,background:t>=80?"#3fb950":t>=50?"#d29922":"#58a6ff",borderRadius:3,transition:"width 0.5s ease",boxShadow:`0 0 4px ${t>=80?"#3fb95088":t>=50?"#d2992288":"#58a6ff88"}`}),nextTask:{color:"#58a6ff",fontSize:10,fontStyle:"italic",opacity:.85,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},stats:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,marginTop:2},stat:{display:"flex",flexDirection:"column",gap:1},statVal:{color:"#e6edf3",fontWeight:700,fontSize:12},statLbl:{color:"#7d8590",fontSize:10}};function B({project:t,isActive:n}){const l=!!t.auto_handoff,s=T(t.model_usage);return e.jsxs("div",{style:i.card(!!n),children:[e.jsxs("div",{children:[e.jsxs("div",{style:i.header,children:[e.jsxs("span",{style:{...i.name,display:"flex",alignItems:"center",gap:6},children:[e.jsx(b,{size:14,color:"#6e7681",style:{flexShrink:0}}),t.name]}),n&&e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Active project"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Claude Code is currently working in this directory"})]}),children:e.jsx("span",{style:i.activeBadge,children:"● active"})}),l&&e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#7d8590",fontWeight:700,fontSize:12,marginBottom:4},children:"Auto-generated HANDOFF"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"The daemon generated an automatic HANDOFF.md. Edit it to record your pending tasks."})]}),children:e.jsx("span",{style:i.autoBadge,children:"HANDOFF auto"})})]}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Project path"}),e.jsx("div",{style:{color:"#79c0ff",fontSize:10,fontFamily:"monospace",wordBreak:"break-all"},children:t.path})]}),children:e.jsx("div",{style:i.path,children:t.path.split("/").slice(-3).join("/")})})]}),t.has_handoff?e.jsx("div",{style:i.progressWrap,children:t.progress.total===0?e.jsx("span",{style:{...i.progressLabel,fontStyle:"italic"},children:l?"→ Auto-generated HANDOFF — fill in the sections with your tasks":"no tasks recorded"}):t.progress.done===0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:i.progressLabel,children:[t.progress.total," pending task",t.progress.total>1?"s":""]}),t.progress.nextTask&&e.jsxs("div",{style:i.nextTask,children:["→ next: ",t.progress.nextTask]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:i.progressRow,children:[e.jsxs("span",{style:i.progressLabel,children:[t.progress.done,"/",t.progress.total," tasks"]}),e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"HANDOFF progress"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:[t.progress.done," completed task",t.progress.done!==1?"s":""," out of ",t.progress.total," in HANDOFF.md"]})]}),children:e.jsxs("span",{style:i.progressPct(t.progress.pct),children:[t.progress.pct,"%"]})})]}),e.jsx("div",{style:i.barTrack,children:e.jsx("div",{style:i.barFill(t.progress.pct)})}),t.progress.nextTask&&e.jsxs("div",{style:i.nextTask,children:["→ next: ",t.progress.nextTask]})]})}):null,t.model_usage&&e.jsx(F,{usage:t.model_usage}),e.jsxs("div",{style:i.stats,children:[e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Total cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of all API costs of the sessions in this project"})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:u(t.total_cost_usd)}),e.jsxs("span",{style:i.statLbl,children:["total cost",t.session_count>1&&e.jsxs("span",{style:{color:"#484f58",marginLeft:3},children:["· ",u(t.total_cost_usd/t.session_count),"/ses"]})]})]})}),e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.6},children:["Input + Output + Cache read accumulated.",e.jsx("br",{}),s?e.jsxs(e.Fragment,{children:["Dominant model: ",e.jsx("span",{style:{color:s.color,fontWeight:700},children:s.label})]}):"No model data"]})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:p(t.total_tokens)}),e.jsxs("span",{style:i.statLbl,children:["tokens",s&&e.jsxs("span",{style:{color:s.color,marginLeft:3},children:["· ",s.label]})]})]})}),e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Total recorded sessions, including those before claudestat was installed (read from Claude Code JSONL files)."})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:t.session_count}),e.jsx("span",{style:i.statLbl,children:"sessions"})]})}),e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Last activity"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:t.last_active?new Date(t.last_active).toLocaleString("en",{dateStyle:"medium",timeStyle:"short"}):"No activity recorded"})]}),children:e.jsxs("div",{style:i.stat,children:[e.jsx("span",{style:i.statVal,children:W(t.last_active)}),e.jsx("span",{style:i.statLbl,children:"last seen"})]})})]}),t.insights&&t.insights.length>0&&e.jsx(C,{insights:t.insights})]})}const _=j.memo(B);function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function L({data:t}){if(t.length===0)return null;const n=Math.max(...t.map(s=>s.tokens),1),l=["M","T","W","T","F","S","S"];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3},children:[e.jsx("div",{style:{display:"flex",gap:3},children:t.slice(-7).map((s,h)=>{const r=s.tokens/n,x=r<.05?"#1c2128":r<.3?"#0e4429":r<.6?"#006d32":r<.85?"#26a641":"#39d353";return e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:3},children:s.date}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[v(s.tokens)," tokens that day"]})]}),children:e.jsx("div",{style:{width:12,height:12,borderRadius:2,background:x,border:"1px solid #21262d"}})},h)})}),e.jsx("div",{style:{display:"flex",gap:3},children:t.slice(-7).map((s,h)=>e.jsx("span",{style:{width:12,fontSize:8,color:"#484f58",textAlign:"center"},children:l[h]},h))})]})}function D(){return e.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:10,padding:"14px 16px",display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:120,height:14,borderRadius:4,background:"#21262d",animation:"skeletonShimmer 1.4s ease-in-out infinite"}}),e.jsx("div",{style:{width:40,height:14,borderRadius:4,background:"#21262d",animation:"skeletonShimmer 1.4s ease-in-out infinite 0.2s"}})]}),e.jsx("div",{style:{width:"70%",height:10,borderRadius:3,background:"#21262d",animation:"skeletonShimmer 1.4s ease-in-out infinite 0.1s"}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8},children:[0,1,2,3].map(t=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("div",{style:{height:12,borderRadius:3,background:"#21262d",animation:`skeletonShimmer 1.4s ease-in-out infinite ${t*.1}s`}}),e.jsx("div",{style:{height:8,borderRadius:2,background:"#21262d",animation:`skeletonShimmer 1.4s ease-in-out infinite ${t*.1+.1}s`}})]},t))})]})}const o={wrap:{padding:"16px 24px",overflowY:"auto",height:"100%"},summary:{display:"flex",alignItems:"center",gap:20,padding:"12px 16px",marginBottom:20,background:"#161b22",borderRadius:8,border:"1px solid #21262d",flexWrap:"wrap"},sumItem:{display:"flex",flexDirection:"column",gap:2},sumVal:{color:"#e6edf3",fontWeight:700,fontSize:16},sumLbl:{color:"#7d8590",fontSize:11},grid:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:12},sep:{width:1,height:32,background:"#21262d",flexShrink:0}};function A({projects:t,activeProject:n,weeklyData:l=[],loading:s=!1}){const h=t.reduce((d,f)=>d+f.total_cost_usd,0),r=t.reduce((d,f)=>d+f.total_tokens,0),x=t.reduce((d,f)=>d+f.session_count,0),c=t.filter(d=>d.has_handoff&&!d.auto_handoff),g=c.length>0?Math.round(c.reduce((d,f)=>d+f.progress.pct,0)/c.length):0;return e.jsxs("div",{style:o.wrap,children:[e.jsx("style",{children:`
2
- @keyframes skeletonShimmer {
3
- 0%,100% { opacity: 1 }
4
- 50% { opacity: 0.4 }
5
- }
6
- `}),e.jsxs("div",{style:o.summary,children:[e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Projects"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:["Number of projects detected by claudestat in ",e.jsx("code",{children:"~/.claude/projects/"})]})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsx("span",{style:o.sumVal,children:t.length}),e.jsx("span",{style:o.sumLbl,children:"projects"})]})}),e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:"Total cost"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Sum of all API costs of all sessions across all projects"})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsxs("span",{style:o.sumVal,children:["$",h.toFixed(2)]}),e.jsx("span",{style:o.sumLbl,children:"total cost"})]})}),e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#79c0ff",fontWeight:700,fontSize:12,marginBottom:4},children:"Total tokens"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Input + Output + Cache read accumulated across all projects"})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsx("span",{style:o.sumVal,children:v(r)}),e.jsx("span",{style:o.sumLbl,children:"total tokens"})]})}),e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Historical sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Total sessions recorded by claudestat across all projects"})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsx("span",{style:o.sumVal,children:x}),e.jsx("span",{style:o.sumLbl,children:"historical sessions"})]})}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:o.sep}),e.jsx(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#e6edf3",fontWeight:700,fontSize:12,marginBottom:4},children:"Average progress"}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:["% of completed tasks averaged across ",c.length," project",c.length!==1?"s":""," with HANDOFF.md"]})]}),children:e.jsxs("div",{style:o.sumItem,children:[e.jsxs("span",{style:{...o.sumVal,color:g>=70?"#3fb950":"#d29922"},children:[g,"%"]}),e.jsx("span",{style:o.sumLbl,children:"average progress"})]})})]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:o.sep}),e.jsx(L,{data:l})]})]}),s&&e.jsx("div",{style:o.grid,children:[0,1,2].map(d=>e.jsx(D,{},d))}),!s&&t.length===0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"60px 0",gap:16,color:"#484f58"},children:[e.jsx(w,{size:48,strokeWidth:1.2,color:"#30363d"}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{color:"#6e7681",fontWeight:600,fontSize:14,marginBottom:6},children:"No projects detected"}),e.jsxs("div",{style:{color:"#484f58",fontSize:12,lineHeight:1.6},children:["Projects appear automatically when",e.jsx("br",{}),"Claude Code accesses files in their directories."]})]})]}),!s&&t.length>0&&e.jsx("div",{style:o.grid,children:t.map(d=>e.jsx(_,{project:d,isActive:d.path===n},d.path))})]})}export{A as ProjectsView};
@@ -1 +0,0 @@
1
- import{j as e,T as r}from"./index-DgbWvj42.js";import{L as T,a as h,Z as y,B as M,a8 as v,n as O,S as E,f as L,s as S,a9 as W,Y as R,aa as $}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";function N(t,s){return s>0?Math.round(t/s*100):0}function b(t){if(!t)return"";const s=t.match(/(?:node|python3?|bash|sh|deno|bun)\s+[~\w/.]+\/([\w.-]+)/);return s?`…/${s[1]}`:t.slice(0,50)}function f({children:t,style:s}){return e.jsx("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",...s},children:t})}function x({icon:t,title:s,subtitle:l,color:n="#58a6ff",open:o,onToggle:i,badge:d}){return e.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:8,width:"100%",background:"none",border:"none",cursor:"pointer",padding:0,marginBottom:o?12:0},children:[e.jsx(t,{size:13,color:n}),e.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700,flex:1,textAlign:"left"},children:s}),l&&e.jsx("span",{style:{fontSize:10,color:"#484f58"},children:l}),d,o?e.jsx(R,{size:12,color:"#484f58"}):e.jsx($,{size:12,color:"#484f58"})]})}function a({label:t,value:s,last:l=!1,color:n="#8b949e",tip:o}){const i=e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,paddingLeft:16,position:"relative"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:l?"50%":0,width:1,background:"#21262d"}}),e.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:10,height:1,background:"#21262d"}}),e.jsx("span",{style:{fontSize:11,color:n,fontWeight:500},children:t}),s!==void 0&&e.jsx("span",{style:{fontSize:10,color:"#484f58",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:s})]});return o?e.jsx(r,{position:"top",align:"left",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:o}),children:i}):i}function p({text:t,color:s}){return e.jsx("span",{style:{fontSize:10,fontWeight:600,color:s,background:s+"18",border:`1px solid ${s}35`,borderRadius:4,padding:"1px 6px"},children:t})}const I={SessionStart:{label:"SessionStart",tip:"Runs when each Claude Code session starts. Loads Engram context and the project HANDOFF."},PreToolUse:{label:"PreToolUse",tip:"Runs before each tool call. claudestat uses it to check the kill-switch and record the event start."},PostToolUse:{label:"PostToolUse",tip:"Runs after each tool call with the result. claudestat sends the event to the daemon to enrich it with cost and duration."},Stop:{label:"Stop",tip:"Runs when Claude finishes responding. claudestat records the full block and emits the stop event for SSE."}};function A({hooks:t}){const[s,l]=h.useState(!0),n=Object.keys(t),o=n.length;return e.jsxs(f,{children:[e.jsx(x,{icon:y,title:"Active hooks",color:"#d29922",subtitle:o>0?void 0:"none configured",badge:o>0?e.jsx(p,{text:`${o} hooks`,color:"#d29922"}):void 0,open:s,onToggle:()=>l(i=>!i)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:o===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No hooks in ~/.claude/settings.json — claudestat is not active"}):n.map((i,d)=>{var m;const u=t[i],c=I[i];return e.jsx(r,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:(c==null?void 0:c.label)??i}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:(c==null?void 0:c.tip)??""}),u.map((w,C)=>e.jsx("div",{style:{color:"#3d444d",fontFamily:"monospace",fontSize:9,marginTop:4},children:b(w.command)},C))]}),children:e.jsx(a,{label:(c==null?void 0:c.label)??i,value:e.jsx("span",{style:{fontFamily:"monospace",color:"#3d444d"},children:b(((m=u[0])==null?void 0:m.command)??"")}),last:d===n.length-1,color:"#d29922"})},i)})})]})}function B({agents:t}){const[s,l]=h.useState(!0);return e.jsxs(f,{children:[e.jsx(x,{icon:M,title:"Available agents",color:"#bc8cff",subtitle:"~/.claude/agents/",badge:t.length>0?e.jsx(p,{text:`${t.length}`,color:"#bc8cff"}):void 0,open:s,onToggle:()=>l(n=>!n)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No agents in ~/.claude/agents/"}):t.map((n,o)=>e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:n.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:n.description||"No description in the .md file frontmatter"})]}),children:e.jsx(a,{label:n.name,last:o===t.length-1,color:"#bc8cff",value:n.description?e.jsxs("span",{style:{color:"#3d444d",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block"},children:[n.description.slice(0,40),n.description.length>40?"…":""]}):void 0})},n.name))})]})}const g=500;function F({skills:t}){const[s,l]=h.useState(!0),n=t.filter(o=>o.lines>=g*.9).length;return e.jsxs(f,{children:[e.jsx(x,{icon:y,title:"Available skills",color:"#3fb950",subtitle:"~/.claude/commands/",badge:t.length>0?e.jsx(p,{text:`${t.length}${n>0?` · ${n} ⚠`:""}`,color:n>0?"#d29922":"#3fb950"}):void 0,open:s,onToggle:()=>l(o=>!o)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No skills in ~/.claude/commands/"}):t.map((o,i)=>{const d=o.lines/g,u=z(d),c=d>=.7;return e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#3fb950",fontWeight:700,fontSize:11,marginBottom:3},children:["/",o.name]}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:o.description||"No description in the .md file frontmatter"}),e.jsxs("div",{style:{color:u,fontSize:9,marginTop:4},children:[o.lines," lines ",c?`— recommended limit: ${g}`:`/ ${g} recommended`]})]}),children:e.jsx(a,{label:`/${o.name}`,last:i===t.length-1,color:"#3fb950",value:e.jsxs("span",{style:{color:u,fontVariantNumeric:"tabular-nums"},children:[o.lines," ln ",c?"⚠":""]})})},o.name)})})]})}function D({memoryFiles:t}){const[s,l]=h.useState(!0),n=t.length>0;return e.jsxs(f,{children:[e.jsx(x,{icon:W,title:"Memory system",color:"#58a6ff",badge:n?e.jsx(p,{text:`${t.length} files`,color:"#58a6ff"}):void 0,open:s,onToggle:()=>l(o=>!o)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:n?t.map((o,i)=>e.jsx(a,{label:o,last:i===t.length-1,color:o==="MEMORY.md"?"#79c0ff":"#58a6ff",tip:o==="MEMORY.md"?"Auto-loaded index — every session reads this file automatically.":`Memory file: ~/.claude/projects/…/memory/${o}`},o)):e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"Engram not detected. Optional MCP plugin for persistent memory between sessions."})})]})}function H({workflows:t}){const[s,l]=h.useState(!0);return e.jsxs(f,{children:[e.jsx(x,{icon:v,title:"Workflows / pipelines",color:"#56d364",subtitle:"~/.claude/agents/workflows/",badge:t.length>0?e.jsx(p,{text:`${t.length}`,color:"#56d364"}):void 0,open:s,onToggle:()=>l(n=>!n)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No workflows in ~/.claude/agents/workflows/"}):t.map((n,o)=>e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#56d364",fontWeight:700,fontSize:11,marginBottom:3},children:n.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:n.description||"No description in the .md file frontmatter"})]}),children:e.jsx(a,{label:n.name,last:o===t.length-1,color:"#56d364",value:n.description?e.jsxs("span",{style:{color:"#3d444d"},children:[n.description.slice(0,40),n.description.length>40?"…":""]}):void 0})},n.name))})]})}const P={"CLAUDE.md global":"Permanent instructions for Claude: profile, response style, code rules and project protocol. Loaded every session.","MEMORY.md":"Engram auto-memory index. Auto-loaded into every session via system prompt. Keep under 200 lines — content after line 200 is truncated.","settings.json":"Claude Code configuration: installed hooks, permissions, default model. claudestat needs the hooks here to work.","config claudestat":"Active claudestat configuration: plan, kill switch and quota thresholds. Read on every PreToolUse hook evaluation."},k={"CLAUDE.md global":{lines:200},"MEMORY.md":{lines:200}};function z(t){return t>=.9?"#f85149":t>=.7?"#d29922":"#3fb950"}function K(t,s,l){const n=k[l];if(!n)return null;const o=n.lines?t/n.lines:0,i=n.kb?s/n.kb:0;return z(Math.max(o,i))}function U({f:t}){if(!t.exists)return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:"#f85149"},children:[e.jsx(S,{size:9})," not found"]});const s=K(t.lines,t.sizeKb,t.key),l=s??"#3fb950",n=k[t.key],o=n!=null&&n.lines?`${t.lines} ln / ${n.lines}`:t.sizeKb>0?`${t.sizeKb} KB`:"< 1 KB";return e.jsxs("span",{style:{color:l},children:[o," ",s?"⚠":"✓"]})}function _({files:t}){const[s,l]=h.useState(!0),n=t.filter(o=>o.exists).length;return e.jsxs(f,{children:[e.jsx(x,{icon:O,title:"Context files",color:"#3fb950",badge:e.jsx(p,{text:`${n}/${t.length}`,color:"#3fb950"}),open:s,onToggle:()=>l(o=>!o)}),s&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.map((o,i)=>e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:11,marginBottom:3},children:o.key}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:P[o.key]??"System configuration file."})]}),children:e.jsx(a,{label:o.key,last:i===t.length-1,color:o.exists?"#e6edf3":"#484f58",value:e.jsx(U,{f:o})})},o.key))})]})}const Y={free:"Free",pro:"Pro",max5:"Max 5×",max20:"Max 20×"},j=[{key:"direct",label:"Claude direct",when:"≤ 2 files, no new endpoints",color:"#3fb950",tip:"Claude works alone. Ideal for small changes: CSS, text, simple bugs. No agents or pipeline."},{key:"mini",label:"Mini-pipeline",when:"3–5 files or 1–2 new endpoints",color:"#58a6ff",tip:"3 agents: implementer → quality-docs → tester. Git is not automatic — invoke with /git when the user decides."},{key:"pipeline",label:"Full pipeline",when:"≥ 6 files or new feature",color:"#d29922",tip:"Full agent team. Scrum master, backend, frontend, quality-docs, tester. Git separate — invoke /git when you decide. For large features."}];function q({dist:t}){const[s,l]=h.useState(!0),n=t.total>0?j.reduce((o,i)=>t[i.key]>t[o.key]?i:o,j[0]):null;return e.jsxs(f,{children:[e.jsx(x,{icon:v,title:"Work modes",color:"#f0883e",subtitle:"last 7 days",badge:n&&t.total>0?e.jsx(p,{text:`most used: ${n.label}`,color:n.color}):void 0,open:s,onToggle:()=>l(o=>!o)}),s&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[j.map(o=>{const i=t[o.key],d=N(i,t.total);return e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:o.color,fontWeight:700,fontSize:11,marginBottom:3},children:o.label}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:[e.jsx("span",{style:{color:"#6e7681"},children:"When: "}),o.when,e.jsx("br",{}),o.tip]})]}),children:e.jsxs("div",{style:{cursor:"help"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontSize:11,color:o.color,fontWeight:600,width:130,flexShrink:0},children:o.label}),e.jsx("span",{style:{fontSize:10,color:"#484f58",flex:1},children:o.when}),e.jsx("span",{style:{fontSize:11,color:"#e6edf3",fontVariantNumeric:"tabular-nums",fontWeight:600},children:t.total>0?`${i} (${d}%)`:"—"})]}),e.jsx("div",{style:{height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:e.jsx("div",{style:{width:`${d}%`,height:"100%",background:o.color,borderRadius:2,transition:"width 0.5s"}})})]})},o.key)}),t.total===0&&e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No sessions recorded in the last 7 days"}),t.total>0&&e.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:2},children:[t.total," sessions analyzed · Mode inferred by number of Agent tool calls per session"]})]})]})}function V({cfg:t}){const[s,l]=h.useState(!0),n=t.plan??"pro",o=t.killSwitchEnabled??!0,[i,d,u]=t.warnThresholds??[70,85,95];return e.jsxs(f,{children:[e.jsx(x,{icon:E,title:"claudestat config",color:"#8b949e",subtitle:"~/.claudestat/config.json",open:s,onToggle:()=>l(c=>!c)}),s&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsx(a,{label:"Plan",value:e.jsx(p,{text:Y[n]??n,color:"#58a6ff"}),tip:"Claude Max plan that determines weekly hour limits per model."}),e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:o?"#3fb950":"#f85149",fontWeight:700,fontSize:11,marginBottom:3},children:["Kill switch ",o?"enabled":"disabled"]}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["When ON, blocks new tool calls if the 5h quota exceeds the red threshold.",e.jsx("br",{}),"Configure with: ",e.jsx("code",{style:{color:"#d29922"},children:"claudestat config"})]})]}),children:e.jsx(a,{label:"Kill switch",value:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:o?"#3fb950":"#f85149"},children:[o?e.jsx(L,{size:10}):e.jsx(S,{size:10}),o?"ON":"OFF"]}),color:o?"#3fb950":"#f85149"})}),e.jsx(r,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Quota alert thresholds"}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Percentage of the 5h quota that triggers each SSE alert level.",e.jsx("br",{}),"🟡 warning → 🟠 orange → 🔴 red (kill switch)"]})]}),children:e.jsx(a,{label:"Thresholds",last:!0,value:e.jsxs("span",{style:{display:"inline-flex",gap:6},children:[e.jsxs("span",{style:{color:"#d29922"},children:[i,"%"]}),e.jsxs("span",{style:{color:"#f0883e"},children:[d,"%"]}),e.jsxs("span",{style:{color:"#f85149"},children:[u,"%"]})]})})})]})]})}function Q({config:t,error:s,onRetry:l}){return t?e.jsxs("div",{style:{height:"100%",overflow:"auto",padding:"16px 20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[e.jsx(T,{size:16,color:"#58a6ff"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#e6edf3"},children:"System map"}),e.jsx("div",{style:{fontSize:11,color:"#484f58"},children:"How Claude Code is configured on this machine"})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Active Claude Code hooks in settings.json"}),children:e.jsxs("span",{style:{fontSize:10,color:"#d29922",background:"#d2992215",border:"1px solid #d2992235",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[Object.keys(t.hooks).length," hooks"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Available agents in ~/.claude/agents/"}),children:e.jsxs("span",{style:{fontSize:10,color:"#bc8cff",background:"#bc8cff15",border:"1px solid #bc8cff35",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.agents.length," agents"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Workflows in ~/.claude/agents/workflows/"}),children:e.jsxs("span",{style:{fontSize:10,color:"#56d364",background:"#56d36415",border:"1px solid #56d36435",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.workflows.length," workflows"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Skills in ~/.claude/commands/"}),children:e.jsxs("span",{style:{fontSize:10,color:"#3fb950",background:"#3fb95015",border:"1px solid #3fb95035",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.skills.length," skills"]})}),e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Memory files in Engram"}),children:e.jsxs("span",{style:{fontSize:10,color:"#58a6ff",background:"#58a6ff15",border:"1px solid #58a6ff35",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[t.memoryFiles.length," memories"]})}),l&&e.jsx(r,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Refresh system configuration"}),children:e.jsx("button",{onClick:l,style:{background:"none",border:"1px solid #30363d",borderRadius:4,padding:"2px 7px",cursor:"pointer",color:"#6e7681",fontSize:12,lineHeight:1,transition:"color 0.15s, border-color 0.15s"},onMouseEnter:n=>{n.currentTarget.style.color="#e6edf3",n.currentTarget.style.borderColor="#6e7681"},onMouseLeave:n=>{n.currentTarget.style.color="#6e7681",n.currentTarget.style.borderColor="#30363d"},children:"↺"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,maxWidth:1200,margin:"0 auto"},children:[e.jsx(F,{skills:t.skills}),e.jsx(B,{agents:t.agents}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(H,{workflows:t.workflows??[]})}),e.jsx(q,{dist:t.modeDistribution}),e.jsx(A,{hooks:t.hooks}),e.jsx(_,{files:t.contextFiles}),e.jsx(V,{cfg:t.claudestatConfig}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(D,{memoryFiles:t.memoryFiles})})]})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:12},children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#f85149",fontSize:13},children:"Error loading system configuration"}),l&&e.jsx("button",{onClick:l,style:{padding:"5px 14px",fontSize:12,fontWeight:600,cursor:"pointer",background:"none",border:"1px solid #f8514966",borderRadius:5,color:"#f85149",transition:"background 0.15s"},children:"Retry"})]}):e.jsx("span",{style:{color:"#6e7681",fontSize:13},children:"Loading system configuration…"})})}export{Q as SystemView};
@@ -1 +0,0 @@
1
- import{j as t,T as l}from"./index-DgbWvj42.js";import{a as c,a3 as S,a6 as C,a0 as W,a7 as z,W as k}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";function g(o){return o<.001?"$0":o<.01?`$${o.toFixed(4)}`:o<1?`$${o.toFixed(3)}`:`$${o.toFixed(2)}`}function $(o){return o<1e3?`${o}ms`:o<6e4?`${(o/1e3).toFixed(1)}s`:`${(o/6e4).toFixed(1)}m`}const a=["#58a6ff","#3fb950","#d29922","#f0883e","#bc8cff","#f778ba","#79c0ff","#56d364","#e3b341","#ff7b72"];function w(){const[o,h]=c.useState(),[s,p]=c.useState(),[i,j]=c.useState("cost"),[r,m]=c.useState(30);c.useEffect(()=>{fetch(`/api/top?by=${i}&limit=10&days=${r}`).then(e=>e.ok?e.json():void 0).then(e=>e&&h(e)).catch(()=>{}),fetch("/cost-projection").then(e=>e.ok?e.json():void 0).then(e=>e&&p(e)).catch(()=>{})},[i,r]);const d=(o==null?void 0:o.tools)??[],u=Math.max(...d.map(e=>e.estimatedCostUsd),.001),b=Math.max(...d.map(e=>e.count),1);return t.jsxs("div",{style:{height:"100%",overflow:"auto",padding:"20px 24px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:20,flexWrap:"wrap"},children:[t.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"#e6edf3"},children:"Tool Rankings"}),t.jsx("div",{style:{display:"flex",gap:6},children:[{key:"cost",label:"Cost",icon:S,color:"#3fb950",tip:"Estimated USD cost per tool, calculated from each tool's share of total token usage"},{key:"count",label:"Calls",icon:C,color:"#58a6ff",tip:"Total number of invocations in the selected period"},{key:"duration",label:"Duration",icon:W,color:"#e3b341",tip:"Cumulative execution time (sum of all calls)"}].map(({key:e,label:n,icon:x,color:f,tip:v})=>t.jsx(l,{position:"bottom",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsxs("div",{style:{fontWeight:700,color:f,marginBottom:4},children:["Sort by ",n.toLowerCase()]}),t.jsx("div",{style:{color:"#7d8590"},children:v})]}),children:t.jsxs("button",{onClick:()=>j(e),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",fontSize:11,fontWeight:i===e?600:400,color:i===e?"#e6edf3":"#8b949e",background:i===e?"#21262d":"transparent",border:`1px solid ${i===e?"#30363d":"transparent"}`,borderRadius:5,cursor:"pointer"},children:[t.jsx(x,{size:11})," ",n]})},e))}),t.jsx("div",{style:{display:"flex",gap:4},children:[7,30,90].map(e=>t.jsxs("button",{onClick:()=>m(e),style:{padding:"4px 8px",fontSize:11,fontWeight:r===e?600:400,color:r===e?"#e6edf3":"#8b949e",background:r===e?"#21262d":"transparent",border:`1px solid ${r===e?"#30363d":"transparent"}`,borderRadius:5,cursor:"pointer"},children:[e,"d"]},e))})]}),s&&t.jsxs("div",{style:{display:"flex",gap:12,marginBottom:20},children:[t.jsx(y,{label:"This week",tooltip:"Cost accumulated since Monday of the current week, extrapolated to 7 days",costSoFar:s.weekly.costSoFar,projected:s.weekly.projected,daysWithData:s.weekly.daysWithData}),t.jsx(y,{label:"This month",tooltip:"Cost accumulated since the 1st of the current month, extrapolated to 30 days",costSoFar:s.monthly.costSoFar,projected:s.monthly.projected,daysWithData:s.monthly.daysWithData})]}),d.length===0?t.jsx("div",{style:{color:"#8b949e",fontSize:13,textAlign:"center",marginTop:40},children:"No tool usage data for this period."}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"32px 140px 70px 80px 80px",gap:8,padding:"0 8px",fontSize:10,fontWeight:600,color:"#8b949e",textTransform:"uppercase",letterSpacing:"0.5px"},children:[t.jsx("span",{children:"#"}),t.jsx("span",{children:"Tool"}),t.jsx("span",{style:{textAlign:"right"},children:t.jsx(l,{position:"bottom",align:"right",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#58a6ff",marginBottom:4},children:"Calls"}),t.jsx("div",{style:{color:"#7d8590"},children:"Total invocations in the selected period"})]}),children:"Calls"})}),t.jsx("span",{style:{textAlign:"right"},children:t.jsx(l,{position:"bottom",align:"right",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#e3b341",marginBottom:4},children:"Duration"}),t.jsx("div",{style:{color:"#7d8590"},children:"Cumulative execution time across all calls"})]}),children:"Duration"})}),t.jsx("span",{style:{textAlign:"right"},children:t.jsx(l,{position:"bottom",align:"right",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#3fb950",marginBottom:4},children:"Est. Cost"}),t.jsxs("div",{style:{color:"#7d8590"},children:["Proportion of total session cost",t.jsx("br",{}),"attributed to each tool by call count"]})]}),children:"Est. Cost"})})]}),d.map((e,n)=>{const x=i==="cost"?e.estimatedCostUsd/u:i==="count"?e.count/b:e.totalDurationMs/Math.max(...d.map(f=>f.totalDurationMs),1);return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"32px 140px 70px 80px 80px",gap:8,padding:"8px",fontSize:12,color:"#e6edf3",background:"#161b22",border:"1px solid #21262d",borderRadius:6,position:"relative",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",top:0,left:0,bottom:0,width:`${Math.max(x*100,2)}%`,background:`${a[n%a.length]}12`,transition:"width 0.3s ease"}}),t.jsx("span",{style:{color:"#8b949e",fontWeight:600,position:"relative"},children:n+1}),t.jsx("span",{style:{display:"flex",alignItems:"center",gap:6,position:"relative"},children:e.tool==="Other"?t.jsx(l,{position:"top",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#8b949e",marginBottom:4},children:"Other tools"}),t.jsxs("div",{style:{color:"#7d8590"},children:["Remaining cost not attributed to the",t.jsx("br",{}),"top tools listed above"]})]}),children:t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx(z,{size:11,color:"#8b949e"}),e.tool]})}):t.jsxs(t.Fragment,{children:[t.jsx(k,{size:11,color:a[n%a.length]}),e.tool]})}),t.jsx("span",{style:{textAlign:"right",color:"#8b949e",position:"relative"},children:e.tool==="Other"?"—":e.count.toLocaleString()}),t.jsx("span",{style:{textAlign:"right",color:"#8b949e",position:"relative"},children:e.tool==="Other"?"—":$(e.totalDurationMs)}),t.jsx("span",{style:{textAlign:"right",fontWeight:600,color:a[n%a.length],position:"relative"},children:g(e.estimatedCostUsd)})]},e.tool)})]})]})}function y({label:o,tooltip:h,costSoFar:s,projected:p,daysWithData:i}){return t.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px"},children:[t.jsx(l,{position:"top",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#e6edf3",marginBottom:4},children:o}),t.jsx("div",{style:{color:"#7d8590"},children:h})]}),children:t.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#8b949e",marginBottom:8,cursor:"default"},children:o})}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:4},children:[t.jsx("span",{style:{fontSize:22,fontWeight:700,color:"#e6edf3"},children:g(p)}),t.jsx(l,{position:"top",align:"left",content:t.jsxs("div",{style:{fontSize:11,lineHeight:1.7},children:[t.jsx("div",{style:{fontWeight:700,color:"#58a6ff",marginBottom:4},children:"Projected spend"}),t.jsxs("div",{style:{color:"#7d8590"},children:["Extrapolated from daily average based on ",i.toFixed(1)," days of data"]})]}),children:t.jsx("span",{style:{fontSize:11,color:"#8b949e",cursor:"default"},children:"projected"})})]}),t.jsxs("div",{style:{fontSize:11,color:"#484f58"},children:[g(s)," spent over ",i.toFixed(1)," days"]})]})}export{w as TopView};