@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.
- package/README.md +36 -3
- package/dashboard/dist/assets/AnalyticsView-DDGLDoCN.js +7 -0
- package/dashboard/dist/assets/HistoryView-DkPfrNrv.js +1 -0
- package/dashboard/dist/assets/LineChart-BOWYkkEW.js +2 -0
- package/dashboard/dist/assets/ProjectsView-VRoRiEL4.js +6 -0
- package/dashboard/dist/assets/SystemView-B2zbIxhY.js +1 -0
- package/dashboard/dist/assets/TopView-C2qdsy0Y.js +1 -0
- package/dashboard/dist/assets/index-CMhe3KaT.js +84 -0
- package/dashboard/dist/assets/shared-BbBtsdh1.js +1 -0
- package/dashboard/dist/assets/{vendor-lucide-Cym0q5l_.js → vendor-lucide-ClCW-axQ.js} +79 -64
- package/dashboard/dist/assets/{vendor-react-B_Jzs0gY.js → vendor-react-gHSHIE2L.js} +1 -1
- package/dashboard/dist/index.html +3 -3
- package/dist/config.d.ts +7 -0
- package/dist/config.js +36 -0
- package/dist/daemon.js +113 -9
- package/dist/db.d.ts +87 -2
- package/dist/db.js +325 -65
- package/dist/doctor.js +21 -3
- package/dist/enricher.d.ts +3 -2
- package/dist/enricher.js +10 -5
- package/dist/export.d.ts +2 -1
- package/dist/export.js +41 -6
- package/dist/index.js +406 -20
- package/dist/insights.d.ts +1 -0
- package/dist/insights.js +26 -0
- package/dist/install.js +28 -1
- package/dist/intelligence.d.ts +66 -4
- package/dist/intelligence.js +205 -17
- package/dist/logger.d.ts +6 -0
- package/dist/logger.js +49 -0
- package/dist/notifier.d.ts +15 -0
- package/dist/notifier.js +26 -0
- package/dist/paths.d.ts +23 -0
- package/dist/paths.js +42 -0
- package/dist/pricing.d.ts +2 -0
- package/dist/pricing.js +12 -1
- package/dist/routes/events.js +136 -5
- package/dist/routes/helpers.d.ts +5 -0
- package/dist/routes/helpers.js +21 -1
- package/dist/routes/history.js +6 -2
- package/dist/routes/intents.d.ts +1 -0
- package/dist/routes/intents.js +155 -0
- package/dist/routes/misc.js +150 -4
- package/dist/routes/opencode-reader.js +39 -3
- package/dist/routes/projects.js +19 -1
- package/dist/routes/replay.d.ts +1 -0
- package/dist/routes/replay.js +29 -0
- package/dist/routes/reports.js +7 -0
- package/dist/routes/top.js +8 -1
- package/dist/service.js +11 -0
- package/dist/watchers/adapter.d.ts +1 -0
- package/dist/watchers/claude-code.d.ts +16 -1
- package/dist/watchers/claude-code.js +201 -76
- package/dist/watchers/opencode.d.ts +1 -0
- package/dist/watchers/opencode.js +152 -14
- package/hooks/event.js +44 -26
- package/package.json +1 -1
- package/dashboard/dist/assets/AnalyticsView-5bUM3UHp.js +0 -8
- package/dashboard/dist/assets/HistoryView-C-AsEqos.js +0 -1
- package/dashboard/dist/assets/ProjectsView-D9bZBdY2.js +0 -6
- package/dashboard/dist/assets/SystemView-DIYDCCF3.js +0 -1
- package/dashboard/dist/assets/TopView-DhdLpsiA.js +0 -1
- package/dashboard/dist/assets/index-DgbWvj42.js +0 -84
package/README.md
CHANGED
|
@@ -112,6 +112,8 @@ Then just ask:
|
|
|
112
112
|
- **MCP server** — 7 tools so Claude can answer questions about its own usage
|
|
113
113
|
- **Weekly insights** — pattern analysis with actionable tips
|
|
114
114
|
- **Multi-source** — switch between Claude Code and OpenCode sessions in one click
|
|
115
|
+
- **Source filter** — filter KPIs, charts, and tool rankings by Claude Code / OpenCode across all tabs
|
|
116
|
+
- **Multi-tool coordination** — live intent panel with real collision detection (same file edited by CC and OC)
|
|
115
117
|
|
|
116
118
|
---
|
|
117
119
|
|
|
@@ -184,7 +186,7 @@ claudestat start # start the daemon manually
|
|
|
184
186
|
|
|
185
187
|
## Dashboard
|
|
186
188
|
|
|
187
|
-
The dashboard lives at `http://localhost:7337` and has six tabs: **Live** (real-time trace), **History** (sessions by date), **Projects** (grid with
|
|
189
|
+
The dashboard lives at `http://localhost:7337` and has six tabs: **Live** (real-time trace with source badge and expandable Bash commands), **History** (sessions by date with compare panel), **Projects** (grid with weekly heatmap and cost breakdown), **Analytics** (real spend + tokens + hours + efficiency KPIs, source filter, weekly AI reports), **Top** (tool rankings by cost/count/duration with cost projection), and **System** (hooks, agents, skills, workflows, context file limits, work mode distribution, OpenCode config, memory files, claudestat config).
|
|
188
190
|
|
|
189
191
|

|
|
190
192
|
|
|
@@ -280,7 +282,7 @@ Claude Code event
|
|
|
280
282
|
## Troubleshooting
|
|
281
283
|
|
|
282
284
|
**`claudestat start` hangs for ~5 seconds**
|
|
283
|
-
Normal — `require('express')` takes a few seconds on first load.
|
|
285
|
+
Normal — `require('express')` takes a few seconds on first load. The daemon is running; wait for the "Daemon started" confirmation.
|
|
284
286
|
|
|
285
287
|
**Hooks are not firing / dashboard shows no events**
|
|
286
288
|
Run `claudestat doctor` — it checks every component and prints the exact fix command.
|
|
@@ -300,7 +302,38 @@ The daemon polls quota every 60s and logs warnings at 70%, 85%, and 95%. Check a
|
|
|
300
302
|
**Working with multiple projects**
|
|
301
303
|
claudestat tracks every project automatically. The Projects tab groups sessions by working directory.
|
|
302
304
|
|
|
303
|
-
|
|
305
|
+
**Dashboard shows 0 cost / $0.00 for all sessions**
|
|
306
|
+
Token data comes from Claude Code's JSONL files, not from hook events. Make sure Claude Code is writing JSONL logs — check `~/.claude/projects/` for `.jsonl` files. If the directory is empty, Claude Code may not have logging enabled.
|
|
307
|
+
|
|
308
|
+
**Daemon stops after terminal closes**
|
|
309
|
+
The daemon must be started with `nohup` to persist beyond the shell session:
|
|
310
|
+
```bash
|
|
311
|
+
nohup claudestat start &
|
|
312
|
+
```
|
|
313
|
+
Or use `claudestat setup` which installs a system service (launchd on macOS, systemd on Linux).
|
|
314
|
+
|
|
315
|
+
**`claudestat export` produces empty output**
|
|
316
|
+
If no sessions appear, the daemon may not have been running during your Claude Code sessions. Check `claudestat status` and restart with `claudestat start`. For historical data only (without a running daemon), export still reads from the local SQLite database — so past sessions captured while the daemon was running are always available.
|
|
317
|
+
|
|
318
|
+
**Loop detector fires too often / not enough**
|
|
319
|
+
Adjust the threshold and window:
|
|
320
|
+
```bash
|
|
321
|
+
claudestat config --loop-threshold 5 # default: 8 calls
|
|
322
|
+
claudestat config --loop-window 90 # default: 120 seconds
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**MCP server not responding**
|
|
326
|
+
Restart the daemon (`claudestat restart`) and verify it's registered:
|
|
327
|
+
```bash
|
|
328
|
+
claude mcp list
|
|
329
|
+
```
|
|
330
|
+
If not listed, re-run: `claude mcp add claudestat -s user -- claudestat-mcp`
|
|
331
|
+
|
|
332
|
+
**OpenCode sessions not appearing**
|
|
333
|
+
claudestat reads OpenCode data from `~/.local/share/opencode/opencode.db`. If the file does not exist, OpenCode has not run yet or uses a different data path on your system. Run `opencode` at least once to initialize it.
|
|
334
|
+
|
|
335
|
+
**Node.js experimental SQLite warning on startup**
|
|
336
|
+
Expected — `node:sqlite` is experimental in Node 22. The warning is suppressed automatically. If you see it repeatedly, ensure you are running Node.js 22 or later (`node --version`).
|
|
304
337
|
|
|
305
338
|
## FAQ
|
|
306
339
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{u as Rt,c as It,d as Bt,i as L,e as Lt,f as Dt,g as ne,w as Ke,h as dt,k as ft,l as ut,C as ht,m as K,L as Y,n as ve,o as ke,A as pt,p as V,q as Q,r as Mt,s as We,t as Ne,v as Nt,x as yt,G as mt,y as le,z as Ae,D as Ht,B as xt,S as Ve,E as Ft,F as Gt,H as gt,I as Kt,J as Vt,K as Yt,M as Ut,N as vt,X as Re,Y as we,O as Xt,j as i,T as D,R as Ye,a as Ue,P as Jt}from"./index-CMhe3KaT.js";import{x as j,a as C,y as ce,a1 as He,q as Zt,a2 as Qt,p as qt,I as bt,a3 as Xe,M as ei,W as ti,Z as Fe,a4 as ii,b as jt,a5 as St,d as Ge,_ as Je,f as kt,s as ni,a6 as Ze,a7 as ri,F as oi,n as Qe,$ as si,a0 as ai,a8 as li,X as ci}from"./vendor-lucide-ClCW-axQ.js";import{e as be,d as pe,g as $e}from"./shared-BbBtsdh1.js";import{a as Ie,L as di}from"./LineChart-BOWYkkEW.js";import"./vendor-react-gHSHIE2L.js";var fi=["x1","y1","x2","y2","key"],ui=["offset"];function re(t){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},re(t)}function qe(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function E(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(n),!0).forEach(function(r){hi(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hi(t,e,n){return e=pi(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pi(t){var e=yi(t,"string");return re(e)=="symbol"?e:e+""}function yi(t,e){if(re(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(re(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function te(){return te=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},te.apply(this,arguments)}function et(t,e){if(t==null)return{};var n=mi(t,e),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function mi(t,e){if(t==null)return{};var n={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(e.indexOf(r)>=0)continue;n[r]=t[r]}return n}var xi=function(e){var n=e.fill;if(!n||n==="none")return null;var r=e.fillOpacity,o=e.x,s=e.y,c=e.width,a=e.height,d=e.ry;return j.createElement("rect",{x:o,y:s,ry:d,width:c,height:a,stroke:"none",fill:n,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function wt(t,e){var n;if(j.isValidElement(t))n=j.cloneElement(t,e);else if(ne(t))n=t(e);else{var r=e.x1,o=e.y1,s=e.x2,c=e.y2,a=e.key,d=et(e,fi),f=K(d,!1);f.offset;var l=et(f,ui);n=j.createElement("line",te({},l,{x1:r,y1:o,x2:s,y2:c,fill:"none",key:a}))}return n}function gi(t){var e=t.x,n=t.width,r=t.horizontal,o=r===void 0?!0:r,s=t.horizontalPoints;if(!o||!s||!s.length)return null;var c=s.map(function(a,d){var f=E(E({},t),{},{x1:e,y1:a,x2:e+n,y2:a,key:"line-".concat(d),index:d});return wt(o,f)});return j.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function vi(t){var e=t.y,n=t.height,r=t.vertical,o=r===void 0?!0:r,s=t.verticalPoints;if(!o||!s||!s.length)return null;var c=s.map(function(a,d){var f=E(E({},t),{},{x1:a,y1:e,x2:a,y2:e+n,key:"line-".concat(d),index:d});return wt(o,f)});return j.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function bi(t){var e=t.horizontalFill,n=t.fillOpacity,r=t.x,o=t.y,s=t.width,c=t.height,a=t.horizontalPoints,d=t.horizontal,f=d===void 0?!0:d;if(!f||!e||!e.length)return null;var l=a.map(function(h){return Math.round(h+o-o)}).sort(function(h,y){return h-y});o!==l[0]&&l.unshift(0);var u=l.map(function(h,y){var S=!l[y+1],x=S?o+c-h:l[y+1]-h;if(x<=0)return null;var v=y%e.length;return j.createElement("rect",{key:"react-".concat(y),y:h,x:r,height:x,width:s,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function ji(t){var e=t.vertical,n=e===void 0?!0:e,r=t.verticalFill,o=t.fillOpacity,s=t.x,c=t.y,a=t.width,d=t.height,f=t.verticalPoints;if(!n||!r||!r.length)return null;var l=f.map(function(h){return Math.round(h+s-s)}).sort(function(h,y){return h-y});s!==l[0]&&l.unshift(0);var u=l.map(function(h,y){var S=!l[y+1],x=S?s+a-h:l[y+1]-h;if(x<=0)return null;var v=y%r.length;return j.createElement("rect",{key:"react-".concat(y),x:h,y:c,width:x,height:d,stroke:"none",fill:r[v],fillOpacity:o,className:"recharts-cartesian-grid-bg"})});return j.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var Si=function(e,n){var r=e.xAxis,o=e.width,s=e.height,c=e.offset;return dt(ft(E(E(E({},ht.defaultProps),r),{},{ticks:ut(r,!0),viewBox:{x:0,y:0,width:o,height:s}})),c.left,c.left+c.width,n)},ki=function(e,n){var r=e.yAxis,o=e.width,s=e.height,c=e.offset;return dt(ft(E(E(E({},ht.defaultProps),r),{},{ticks:ut(r,!0),viewBox:{x:0,y:0,width:o,height:s}})),c.top,c.top+c.height,n)},se={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Be(t){var e,n,r,o,s,c,a=Rt(),d=It(),f=Bt(),l=E(E({},t),{},{stroke:(e=t.stroke)!==null&&e!==void 0?e:se.stroke,fill:(n=t.fill)!==null&&n!==void 0?n:se.fill,horizontal:(r=t.horizontal)!==null&&r!==void 0?r:se.horizontal,horizontalFill:(o=t.horizontalFill)!==null&&o!==void 0?o:se.horizontalFill,vertical:(s=t.vertical)!==null&&s!==void 0?s:se.vertical,verticalFill:(c=t.verticalFill)!==null&&c!==void 0?c:se.verticalFill,x:L(t.x)?t.x:f.left,y:L(t.y)?t.y:f.top,width:L(t.width)?t.width:f.width,height:L(t.height)?t.height:f.height}),u=l.x,h=l.y,y=l.width,S=l.height,x=l.syncWithTicks,v=l.horizontalValues,b=l.verticalValues,m=Lt(),g=Dt();if(!L(y)||y<=0||!L(S)||S<=0||!L(u)||u!==+u||!L(h)||h!==+h)return null;var k=l.verticalCoordinatesGenerator||Si,w=l.horizontalCoordinatesGenerator||ki,z=l.horizontalPoints,A=l.verticalPoints;if((!z||!z.length)&&ne(w)){var P=v&&v.length,_=w({yAxis:g?E(E({},g),{},{ticks:P?v:g.ticks}):void 0,width:a,height:d,offset:f},P?!0:x);Ke(Array.isArray(_),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(re(_),"]")),Array.isArray(_)&&(z=_)}if((!A||!A.length)&&ne(k)){var $=b&&b.length,T=k({xAxis:m?E(E({},m),{},{ticks:$?b:m.ticks}):void 0,width:a,height:d,offset:f},$?!0:x);Ke(Array.isArray(T),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(re(T),"]")),Array.isArray(T)&&(A=T)}return j.createElement("g",{className:"recharts-cartesian-grid"},j.createElement(xi,{fill:l.fill,fillOpacity:l.fillOpacity,x:l.x,y:l.y,width:l.width,height:l.height,ry:l.ry}),j.createElement(gi,te({},l,{offset:f,horizontalPoints:z,xAxis:m,yAxis:g})),j.createElement(vi,te({},l,{offset:f,verticalPoints:A,xAxis:m,yAxis:g})),j.createElement(bi,te({},l,{horizontalPoints:z})),j.createElement(ji,te({},l,{verticalPoints:A})))}Be.displayName="CartesianGrid";var wi=["layout","type","stroke","connectNulls","isRange","ref"],zi=["key"],zt;function fe(t){"@babel/helpers - typeof";return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fe(t)}function At(t,e){if(t==null)return{};var n=Ai(t,e),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function Ai(t,e){if(t==null)return{};var n={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(e.indexOf(r)>=0)continue;n[r]=t[r]}return n}function ie(){return ie=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ie.apply(this,arguments)}function tt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Z(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tt(Object(n),!0).forEach(function(r){U(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tt(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function it(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ot(r.key),r)}}function Oi(t,e,n){return e&&it(t.prototype,e),n&&it(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ci(t,e,n){return e=Pe(e),_i(t,Pt()?Reflect.construct(e,n||[],Pe(t).constructor):e.apply(t,n))}function _i(t,e){if(e&&(fe(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ti(t)}function Ti(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Pt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Pt=function(){return!!t})()}function Pe(t){return Pe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Pe(t)}function $i(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Le(t,e)}function Le(t,e){return Le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Le(t,e)}function U(t,e,n){return e=Ot(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ot(t){var e=Ei(t,"string");return fe(e)=="symbol"?e:e+""}function Ei(t,e){if(fe(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(fe(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var oe=(function(t){function e(){var n;Pi(this,e);for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return n=Ci(this,e,[].concat(o)),U(n,"state",{isAnimationFinished:!0}),U(n,"id",xt("recharts-area-")),U(n,"handleAnimationEnd",function(){var c=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),ne(c)&&c()}),U(n,"handleAnimationStart",function(){var c=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),ne(c)&&c()}),n}return $i(e,t),Oi(e,[{key:"renderDots",value:function(r,o,s){var c=this.props.isAnimationActive,a=this.state.isAnimationFinished;if(c&&!a)return null;var d=this.props,f=d.dot,l=d.points,u=d.dataKey,h=K(this.props,!1),y=K(f,!0),S=l.map(function(v,b){var m=Z(Z(Z({key:"dot-".concat(b),r:3},h),y),{},{index:b,cx:v.x,cy:v.y,dataKey:u,value:v.value,payload:v.payload,points:l});return e.renderDotItem(f,m)}),x={clipPath:r?"url(#clipPath-".concat(o?"":"dots-").concat(s,")"):null};return j.createElement(Y,ie({className:"recharts-area-dots"},x),S)}},{key:"renderHorizontalRect",value:function(r){var o=this.props,s=o.baseLine,c=o.points,a=o.strokeWidth,d=c[0].x,f=c[c.length-1].x,l=r*Math.abs(d-f),u=ve(c.map(function(h){return h.y||0}));return L(s)&&typeof s=="number"?u=Math.max(s,u):s&&Array.isArray(s)&&s.length&&(u=Math.max(ve(s.map(function(h){return h.y||0})),u)),L(u)?j.createElement("rect",{x:d<f?d:d-l,y:0,width:l,height:Math.floor(u+(a?parseInt("".concat(a),10):1))}):null}},{key:"renderVerticalRect",value:function(r){var o=this.props,s=o.baseLine,c=o.points,a=o.strokeWidth,d=c[0].y,f=c[c.length-1].y,l=r*Math.abs(d-f),u=ve(c.map(function(h){return h.x||0}));return L(s)&&typeof s=="number"?u=Math.max(s,u):s&&Array.isArray(s)&&s.length&&(u=Math.max(ve(s.map(function(h){return h.x||0})),u)),L(u)?j.createElement("rect",{x:0,y:d<f?d:d-l,width:u+(a?parseInt("".concat(a),10):1),height:Math.floor(l)}):null}},{key:"renderClipRect",value:function(r){var o=this.props.layout;return o==="vertical"?this.renderVerticalRect(r):this.renderHorizontalRect(r)}},{key:"renderAreaStatically",value:function(r,o,s,c){var a=this.props,d=a.layout,f=a.type,l=a.stroke,u=a.connectNulls,h=a.isRange;a.ref;var y=At(a,wi);return j.createElement(Y,{clipPath:s?"url(#clipPath-".concat(c,")"):null},j.createElement(ke,ie({},K(y,!0),{points:r,connectNulls:u,type:f,baseLine:o,layout:d,stroke:"none",className:"recharts-area-area"})),l!=="none"&&j.createElement(ke,ie({},K(this.props,!1),{className:"recharts-area-curve",layout:d,type:f,connectNulls:u,fill:"none",points:r})),l!=="none"&&h&&j.createElement(ke,ie({},K(this.props,!1),{className:"recharts-area-curve",layout:d,type:f,connectNulls:u,fill:"none",points:o})))}},{key:"renderAreaWithAnimation",value:function(r,o){var s=this,c=this.props,a=c.points,d=c.baseLine,f=c.isAnimationActive,l=c.animationBegin,u=c.animationDuration,h=c.animationEasing,y=c.animationId,S=this.state,x=S.prevPoints,v=S.prevBaseLine;return j.createElement(pt,{begin:l,duration:u,isActive:f,easing:h,from:{t:0},to:{t:1},key:"area-".concat(y),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(b){var m=b.t;if(x){var g=x.length/a.length,k=a.map(function(P,_){var $=Math.floor(_*g);if(x[$]){var T=x[$],W=V(T.x,P.x),J=V(T.y,P.y);return Z(Z({},P),{},{x:W(m),y:J(m)})}return P}),w;if(L(d)&&typeof d=="number"){var z=V(v,d);w=z(m)}else if(Q(d)||Mt(d)){var A=V(v,0);w=A(m)}else w=d.map(function(P,_){var $=Math.floor(_*g);if(v[$]){var T=v[$],W=V(T.x,P.x),J=V(T.y,P.y);return Z(Z({},P),{},{x:W(m),y:J(m)})}return P});return s.renderAreaStatically(k,w,r,o)}return j.createElement(Y,null,j.createElement("defs",null,j.createElement("clipPath",{id:"animationClipPath-".concat(o)},s.renderClipRect(m))),j.createElement(Y,{clipPath:"url(#animationClipPath-".concat(o,")")},s.renderAreaStatically(a,d,r,o)))})}},{key:"renderArea",value:function(r,o){var s=this.props,c=s.points,a=s.baseLine,d=s.isAnimationActive,f=this.state,l=f.prevPoints,u=f.prevBaseLine,h=f.totalLength;return d&&c&&c.length&&(!l&&h>0||!We(l,c)||!We(u,a))?this.renderAreaWithAnimation(r,o):this.renderAreaStatically(c,a,r,o)}},{key:"render",value:function(){var r,o=this.props,s=o.hide,c=o.dot,a=o.points,d=o.className,f=o.top,l=o.left,u=o.xAxis,h=o.yAxis,y=o.width,S=o.height,x=o.isAnimationActive,v=o.id;if(s||!a||!a.length)return null;var b=this.state.isAnimationFinished,m=a.length===1,g=Ne("recharts-area",d),k=u&&u.allowDataOverflow,w=h&&h.allowDataOverflow,z=k||w,A=Q(v)?this.id:v,P=(r=K(c,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},_=P.r,$=_===void 0?3:_,T=P.strokeWidth,W=T===void 0?2:T,J=Nt(c)?c:{},xe=J.clipDot,B=xe===void 0?!0:xe,p=$*2+W;return j.createElement(Y,{className:g},k||w?j.createElement("defs",null,j.createElement("clipPath",{id:"clipPath-".concat(A)},j.createElement("rect",{x:k?l:l-y/2,y:w?f:f-S/2,width:k?y:y*2,height:w?S:S*2})),!B&&j.createElement("clipPath",{id:"clipPath-dots-".concat(A)},j.createElement("rect",{x:l-p/2,y:f-p/2,width:y+p,height:S+p}))):null,m?null:this.renderArea(z,A),(c||m)&&this.renderDots(z,B,A),(!x||b)&&yt.renderCallByParent(this.props,a))}}],[{key:"getDerivedStateFromProps",value:function(r,o){return r.animationId!==o.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,curBaseLine:r.baseLine,prevPoints:o.curPoints,prevBaseLine:o.curBaseLine}:r.points!==o.curPoints||r.baseLine!==o.curBaseLine?{curPoints:r.points,curBaseLine:r.baseLine}:null}}])})(C.PureComponent);zt=oe;U(oe,"displayName","Area");U(oe,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!mt.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});U(oe,"getBaseValue",function(t,e,n,r){var o=t.layout,s=t.baseValue,c=e.props.baseValue,a=c??s;if(L(a)&&typeof a=="number")return a;var d=o==="horizontal"?r:n,f=d.scale.domain();if(d.type==="number"){var l=Math.max(f[0],f[1]),u=Math.min(f[0],f[1]);return a==="dataMin"?u:a==="dataMax"||l<0?l:Math.max(Math.min(f[0],f[1]),0)}return a==="dataMin"?f[0]:a==="dataMax"?f[1]:f[0]});U(oe,"getComposedData",function(t){var e=t.props,n=t.item,r=t.xAxis,o=t.yAxis,s=t.xAxisTicks,c=t.yAxisTicks,a=t.bandSize,d=t.dataKey,f=t.stackedData,l=t.dataStartIndex,u=t.displayedData,h=t.offset,y=e.layout,S=f&&f.length,x=zt.getBaseValue(e,n,r,o),v=y==="horizontal",b=!1,m=u.map(function(k,w){var z;S?z=f[l+w]:(z=le(k,d),Array.isArray(z)?b=!0:z=[x,z]);var A=z[1]==null||S&&le(k,d)==null;return v?{x:Ae({axis:r,ticks:s,bandSize:a,entry:k,index:w}),y:A?null:o.scale(z[1]),value:z,payload:k}:{x:A?null:r.scale(z[1]),y:Ae({axis:o,ticks:c,bandSize:a,entry:k,index:w}),value:z,payload:k}}),g;return S||b?g=m.map(function(k){var w=Array.isArray(k.value)?k.value[0]:null;return v?{x:k.x,y:w!=null&&k.y!=null?o.scale(w):null}:{x:w!=null?r.scale(w):null,y:k.y}}):g=v?o.scale(x):r.scale(x),Z({points:m,baseLine:g,layout:y,isRange:b},h)});U(oe,"renderDotItem",function(t,e){var n;if(j.isValidElement(t))n=j.cloneElement(t,e);else if(ne(t))n=t(e);else{var r=Ne("recharts-area-dot",typeof t!="boolean"?t.className:""),o=e.key,s=At(e,zi);n=j.createElement(Ht,ie({},s,{key:o,className:r}))}return n});function ue(t){"@babel/helpers - typeof";return ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ue(t)}function Wi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ri(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Tt(r.key),r)}}function Ii(t,e,n){return e&&Ri(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Bi(t,e,n){return e=Oe(e),Li(t,Ct()?Reflect.construct(e,n||[],Oe(t).constructor):e.apply(t,n))}function Li(t,e){if(e&&(ue(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Di(t)}function Di(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ct=function(){return!!t})()}function Oe(t){return Oe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Oe(t)}function Mi(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&De(t,e)}function De(t,e){return De=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},De(t,e)}function _t(t,e,n){return e=Tt(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Tt(t){var e=Ni(t,"string");return ue(e)=="symbol"?e:e+""}function Ni(t,e){if(ue(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(ue(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var _e=(function(t){function e(){return Wi(this,e),Bi(this,e,arguments)}return Mi(e,t),Ii(e,[{key:"render",value:function(){return null}}])})(C.Component);_t(_e,"displayName","ZAxis");_t(_e,"defaultProps",{zAxisId:0,range:[64,64],scale:"auto",type:"number"});var Hi=["option","isActive"];function ye(){return ye=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ye.apply(this,arguments)}function Fi(t,e){if(t==null)return{};var n=Gi(t,e),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function Gi(t,e){if(t==null)return{};var n={};for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(e.indexOf(r)>=0)continue;n[r]=t[r]}return n}function Ki(t){var e=t.option,n=t.isActive,r=Fi(t,Hi);return typeof e=="string"?C.createElement(Ve,ye({option:C.createElement(Ft,ye({type:e},r)),isActive:n,shapeType:"symbols"},r)):C.createElement(Ve,ye({option:e,isActive:n,shapeType:"symbols"},r))}function he(t){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},he(t)}function me(){return me=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},me.apply(this,arguments)}function nt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function N(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nt(Object(n),!0).forEach(function(r){q(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nt(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vi(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function rt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Et(r.key),r)}}function Yi(t,e,n){return e&&rt(t.prototype,e),n&&rt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ui(t,e,n){return e=Ce(e),Xi(t,$t()?Reflect.construct(e,n||[],Ce(t).constructor):e.apply(t,n))}function Xi(t,e){if(e&&(he(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ji(t)}function Ji(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function $t(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($t=function(){return!!t})()}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ce(t)}function Zi(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Me(t,e)}function Me(t,e){return Me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Me(t,e)}function q(t,e,n){return e=Et(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Et(t){var e=Qi(t,"string");return he(e)=="symbol"?e:e+""}function Qi(t,e){if(he(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(he(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Te=(function(t){function e(){var n;Vi(this,e);for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return n=Ui(this,e,[].concat(o)),q(n,"state",{isAnimationFinished:!1}),q(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0})}),q(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1})}),q(n,"id",xt("recharts-scatter-")),n}return Zi(e,t),Yi(e,[{key:"renderSymbolsStatically",value:function(r){var o=this,s=this.props,c=s.shape,a=s.activeShape,d=s.activeIndex,f=K(this.props,!1);return r.map(function(l,u){var h=d===u,y=h?a:c,S=N(N({},f),l);return j.createElement(Y,me({className:"recharts-scatter-symbol",key:"symbol-".concat(l==null?void 0:l.cx,"-").concat(l==null?void 0:l.cy,"-").concat(l==null?void 0:l.size,"-").concat(u)},Gt(o.props,l,u),{role:"img"}),j.createElement(Ki,me({option:y,isActive:h,key:"symbol-".concat(u)},S)))})}},{key:"renderSymbolsWithAnimation",value:function(){var r=this,o=this.props,s=o.points,c=o.isAnimationActive,a=o.animationBegin,d=o.animationDuration,f=o.animationEasing,l=o.animationId,u=this.state.prevPoints;return j.createElement(pt,{begin:a,duration:d,isActive:c,easing:f,from:{t:0},to:{t:1},key:"pie-".concat(l),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(h){var y=h.t,S=s.map(function(x,v){var b=u&&u[v];if(b){var m=V(b.cx,x.cx),g=V(b.cy,x.cy),k=V(b.size,x.size);return N(N({},x),{},{cx:m(y),cy:g(y),size:k(y)})}var w=V(0,x.size);return N(N({},x),{},{size:w(y)})});return j.createElement(Y,null,r.renderSymbolsStatically(S))})}},{key:"renderSymbols",value:function(){var r=this.props,o=r.points,s=r.isAnimationActive,c=this.state.prevPoints;return s&&o&&o.length&&(!c||!We(c,o))?this.renderSymbolsWithAnimation():this.renderSymbolsStatically(o)}},{key:"renderErrorBar",value:function(){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var o=this.props,s=o.points,c=o.xAxis,a=o.yAxis,d=o.children,f=gt(d,Kt);return f?f.map(function(l,u){var h=l.props,y=h.direction,S=h.dataKey;return j.cloneElement(l,{key:"".concat(y,"-").concat(S,"-").concat(s[u]),data:s,xAxis:c,yAxis:a,layout:y==="x"?"vertical":"horizontal",dataPointFormatter:function(v,b){return{x:v.cx,y:v.cy,value:y==="x"?+v.node.x:+v.node.y,errorVal:le(v,b)}}})}):null}},{key:"renderLine",value:function(){var r=this.props,o=r.points,s=r.line,c=r.lineType,a=r.lineJointType,d=K(this.props,!1),f=K(s,!1),l,u;if(c==="joint")l=o.map(function(g){return{x:g.cx,y:g.cy}});else if(c==="fitting"){var h=Vt(o),y=h.xmin,S=h.xmax,x=h.a,v=h.b,b=function(k){return x*k+v};l=[{x:y,y:b(y)},{x:S,y:b(S)}]}var m=N(N(N({},d),{},{fill:"none",stroke:d&&d.fill},f),{},{points:l});return j.isValidElement(s)?u=j.cloneElement(s,m):ne(s)?u=s(m):u=j.createElement(ke,me({},m,{type:a})),j.createElement(Y,{className:"recharts-scatter-line",key:"recharts-scatter-line"},u)}},{key:"render",value:function(){var r=this.props,o=r.hide,s=r.points,c=r.line,a=r.className,d=r.xAxis,f=r.yAxis,l=r.left,u=r.top,h=r.width,y=r.height,S=r.id,x=r.isAnimationActive;if(o||!s||!s.length)return null;var v=this.state.isAnimationFinished,b=Ne("recharts-scatter",a),m=d&&d.allowDataOverflow,g=f&&f.allowDataOverflow,k=m||g,w=Q(S)?this.id:S;return j.createElement(Y,{className:b,clipPath:k?"url(#clipPath-".concat(w,")"):null},m||g?j.createElement("defs",null,j.createElement("clipPath",{id:"clipPath-".concat(w)},j.createElement("rect",{x:m?l:l-h/2,y:g?u:u-y/2,width:m?h:h*2,height:g?y:y*2}))):null,c&&this.renderLine(),this.renderErrorBar(),j.createElement(Y,{key:"recharts-scatter-symbols"},this.renderSymbols()),(!x||v)&&yt.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(r,o){return r.animationId!==o.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:o.curPoints}:r.points!==o.curPoints?{curPoints:r.points}:null}}])})(C.PureComponent);q(Te,"displayName","Scatter");q(Te,"defaultProps",{xAxisId:0,yAxisId:0,zAxisId:0,legendType:"circle",lineType:"joint",lineJointType:"linear",data:[],shape:"circle",hide:!1,isAnimationActive:!mt.isSsr,animationBegin:0,animationDuration:400,animationEasing:"linear"});q(Te,"getComposedData",function(t){var e=t.xAxis,n=t.yAxis,r=t.zAxis,o=t.item,s=t.displayedData,c=t.xAxisTicks,a=t.yAxisTicks,d=t.offset,f=o.props.tooltipType,l=gt(o.props.children,Yt),u=Q(e.dataKey)?o.props.dataKey:e.dataKey,h=Q(n.dataKey)?o.props.dataKey:n.dataKey,y=r&&r.dataKey,S=r?r.range:_e.defaultProps.range,x=S&&S[0],v=e.scale.bandwidth?e.scale.bandwidth():0,b=n.scale.bandwidth?n.scale.bandwidth():0,m=s.map(function(g,k){var w=le(g,u),z=le(g,h),A=!Q(y)&&le(g,y)||"-",P=[{name:Q(e.dataKey)?o.props.name:e.name||e.dataKey,unit:e.unit||"",value:w,payload:g,dataKey:u,type:f},{name:Q(n.dataKey)?o.props.name:n.name||n.dataKey,unit:n.unit||"",value:z,payload:g,dataKey:h,type:f}];A!=="-"&&P.push({name:r.name||r.dataKey,unit:r.unit||"",value:A,payload:g,dataKey:y,type:f});var _=Ae({axis:e,ticks:c,bandSize:v,entry:g,index:k,dataKey:u}),$=Ae({axis:n,ticks:a,bandSize:b,entry:g,index:k,dataKey:h}),T=A!=="-"?r.scale(A):x,W=Math.sqrt(Math.max(T,0)/Math.PI);return N(N({},g),{},{cx:_,cy:$,x:_-W,y:$-W,xAxis:e,yAxis:n,zAxis:r,width:2*W,height:2*W,size:T,node:{x:w,y:z,z:A},tooltipPayload:P,tooltipPosition:{x:_,y:$},payload:g},l&&l[k]&&l[k].props)});return N({points:m},d)});var qi=Ut({chartName:"ComposedChart",GraphicalChild:[Ie,oe,vt,Te],axisComponents:[{axisType:"xAxis",AxisComp:Re},{axisType:"yAxis",AxisComp:we},{axisType:"zAxis",AxisComp:_e}],formatAxisMap:Xt});const ee={sonnet:6.6,haiku:1.76,opus:33};function Wt(t){return t!=null&&t.includes("opus")?13.5:t!=null&&t.includes("haiku")?.22:2.7}function en(t){return t.includes("opus")?ee.opus:t.includes("haiku")?ee.haiku:ee.sonnet}function tn(t){return t.includes("opus")?"Opus":t.includes("haiku")?"Haiku":"Sonnet"}function X(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function G(t){return t===0?"$0.00":t<.001?"<$0.001":t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:`$${t.toFixed(2)}`}function nn(t,e=5){const n=[];let r=0,o=[];function s(c,a){if(a.length===0)return;let d=0;for(;d<a.length;){const f=a[d].tool_name;let l=d+1;for(;l<a.length&&a[l].tool_name===f;)l++;const u=l-d;if(u>=e){const h=a.slice(d,l);let y,S=!1;if(["Read","Edit","Write","Glob","Grep"].includes(f)){const x=new Set;for(const v of h)try{const b=JSON.parse(v.tool_input||"{}"),m=b.file_path||b.pattern||b.path||"";m&&x.add(m.split("/").pop()||m)}catch{}if(S=x.size>1,y=x.size===1?[...x][0]:x.size>1?`${x.size} different files`:void 0,S&&u<6){d=l;continue}}else if(f.includes("mem_save")){const x=new Set;for(const v of h)try{const b=JSON.parse(v.tool_input||"{}");b.topic&&x.add(b.topic)}catch{}if(S=x.size>1,y=x.size===1?[...x][0]:void 0,S){d=l;continue}}else if(f==="Bash")try{const x=JSON.parse(h[0].tool_input||"{}").command||"";y=x.length>50?x.slice(0,48)+"…":x}catch{}n.push({blockIndex:c+1,toolName:f,count:u,detail:y,multiFile:S})}d=l}}for(const c of t)c.type==="Stop"?(s(r,o),r++,o=[]):(c.type==="Done"||c.type==="PreToolUse")&&c.tool_name&&o.push(c);return o.length>0&&s(r,o),n}function ot(t,e,n){switch(t){case"Read":return e?"Claude is reading different files in sequence without processing information between reads. Group exploration with Glob/Grep first to reduce the number of Reads.":`"${n||"the file"}" was read multiple times in a row. Use offset+limit to read only the necessary section, or Grep to search without reading the entire file. Re-reading the same file wastes context tokens.`;case"Edit":return`"${n||"the file"}" was edited multiple times in a row. This happens when instructions are imprecise — Claude attempts the edit, fails or it doesn't match expectations, and retries. Be more specific: indicate the exact change (old_string → new_string) instead of describing the result.`;case"Write":return`"${n||"the file"}" was overwritten multiple times. Consolidate all changes into a single instruction instead of writing intermediate versions.`;case"Bash":return`Repeated command: "${n||"…"}". Bash loops are usually retries due to error. Verify that the previous command succeeded before continuing, or ask Claude to show the error output.`;case"Grep":case"Glob":return"Repeated searches with similar patterns. Claude is searching for something it can't find. Try a broader pattern or use Read to see the directory structure directly.";default:return t.includes("mem_save")?`The same topic "${n||"…"}" was saved in Engram multiple times in a row. Use mem_update to edit an existing observation instead of creating duplicates.`:`The tool ${t} was executed multiple times in a row. Check if Claude is ignoring previous results.`}}function rn(t,e,n,r,o){var c;const s=[];if(n&&n.length>0){const a=nn(n,5),d=new Map;for(const f of a){const l=d.get(f.toolName)||[];l.push(f),d.set(f.toolName,l)}for(const[f,l]of d){const u=l.map(x=>`#${x.blockIndex}`).join(", "),h=l.reduce((x,v)=>x+v.count,0),y=l[0],S=(c=r==null?void 0:r.find(x=>x.index===y.blockIndex))==null?void 0:c.text;s.push({level:"error",title:`Loop: ${f} ×${h} — bloques ${u}`,text:ot(f,y.multiFile,y.detail),prompt:S,blockIndex:y.blockIndex})}}else if(t!=null&&t.loops&&t.loops.length>0)for(const a of t.loops)s.push({level:"error",title:`Loop: ${a.toolName} ×${a.count}`,text:ot(a.toolName,!1)});if(n&&n.length>0){const a=new Map;for(const f of n)if(f.tool_name==="Read"&&f.type==="Done"&&f.tool_input)try{const l=JSON.parse(f.tool_input).file_path||"";l&&a.set(l,(a.get(l)||0)+1)}catch{}const d=[...a.entries()].filter(([,f])=>f>=5);if(d.length>0){const f=d.map(([l,u])=>`${l.split("/").pop()} (×${u})`).join(", ");s.push({level:"warning",title:`Scattered re-reads: ${d.length} file${d.length>1?"s":""}`,text:`${f}. These reads are not consecutive but add up to many context tokens. Consider saving the structure mentally before continuing to edit, or use Grep instead of reading the entire file.`})}}if(t){const a=t.input_tokens+t.cache_read+t.cache_creation,d=a>5e3?t.cache_read/a:-1;d>=0&&d<.3&&s.push({level:"warning",title:`Low cache hit: ${Math.round(d*100)}%`,text:"Claude caches context automatically in long sessions. Avoid manually clearing history and work in continuous sessions to accumulate cache."})}if(t&&t.efficiency_score>0&&t.efficiency_score<70&&s.push({level:"warning",title:`Low efficiency: ${t.efficiency_score}/100`,text:"Loops and re-reads are consuming tokens unnecessarily. Check if Claude is repeating steps or if instructions are ambiguous."}),e&&e.burnRateTokensPerMin>6e3&&s.push({level:"info",title:`High burn rate: ${e.burnRateTokensPerMin.toLocaleString()} tok/min`,text:"You are consuming tokens very quickly. Consider asking for more concise responses, avoid attaching large complete files, or break the task into steps."}),n&&n.length>0){const a=n.filter(u=>u.type==="Done"),d=a.filter(u=>u.tool_name==="Bash").length,f=a.filter(u=>u.tool_name==="Read").length,l=a.filter(u=>u.tool_name==="Grep").length;d>6&&l<Math.floor(d*.3)&&f>4&&s.push({level:"info",title:`Bash+Read without Grep (${d} Bash, ${f} Read)`,text:"You are combining Bash and Read to search for information. Grep is more efficient for searching within files — use Grep before Read when you don't know what line something is on."})}if(e&&e.cyclePct>70&&s.push({level:e.cyclePct>85?"error":"warning",title:`Quota at ${e.cyclePct}%`,text:`You used ${e.cyclePrompts}/${e.cycleLimit} prompts in the 5h window. Group several changes in a single message instead of sending one by one.`}),t&&t.cache_read>3e4){const a=t.cache_read/1e6*Wt(t.model);a>.02&&s.push({level:"success",title:`Optimal cache — saving ${G(a)}`,text:"You are making good use of prompt cache. Long and continuous sessions maximize savings."})}return t&&t.efficiency_score>=90&&s.push({level:"success",title:`Excellent efficiency: ${t.efficiency_score}/100`,text:"No loops detected in this session. Good work pace."}),s}const on={"claude-code":"Claude Code",opencode:"OpenCode"};function M({children:t,style:e}){return i.jsx("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",...e},children:t})}function H({icon:t,title:e,subtitle:n,color:r="#58a6ff"}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:12},children:[i.jsx(t,{size:13,color:r}),i.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700},children:e}),n&&i.jsx("span",{style:{fontSize:10,color:"#484f58",marginLeft:2},children:n})]})}function ze({content:t,position:e="bottom",align:n="left",style:r}){return i.jsx(D,{position:e,align:n,content:t,children:i.jsx(bt,{size:9,color:"#3d444d",style:{cursor:"help",...r}})})}function sn({quota:t,cost:e}){const n=(e==null?void 0:e.context_used)??0,r=(e==null?void 0:e.context_window)??2e5,o=Math.round(r*.85),c=e!==void 0&&n>0&&o>0?Math.min(100,Math.round(n/o*100)):null,a=c!==null?100-c:null,d=a===null?"#484f58":a<20?"#f85149":a<40?"#d29922":"#3fb950",f=(e==null?void 0:e.cost_usd)??0,l=(e==null?void 0:e.input_tokens)??0,u=(e==null?void 0:e.output_tokens)??0,h=(e==null?void 0:e.cache_read)??0,y=(e==null?void 0:e.source)??"claude-code",S=on[y]??y,x=y==="opencode"?"#3fb950":"#58a6ff",v=e==null?void 0:e.started_at,b=v?(Date.now()-v)/6e4:0,m=b>0?b>=120?`${Math.round(b/60)}h ${Math.round(b%60)}m`:`${Math.round(b)}m`:null,w=(e==null?void 0:e.model)||(y==="opencode"?"deepseek-v4-flash-free":"claude-sonnet-4-6"),z=t.burnRateTokensPerMin??0,A=w.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/^opencode-go\//,""),P=y==="opencode";return i.jsxs(M,{style:{borderColor:"#30363d"},children:[i.jsx(H,{icon:ce,title:"Current status",subtitle:"real-time",color:x}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:12},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[i.jsx(ce,{size:10,color:"#484f58"}),i.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Source"})]}),i.jsx("span",{style:{fontSize:12,fontWeight:700,color:x,background:`${x}18`,border:`1px solid ${x}30`,borderRadius:4,padding:"2px 8px",marginBottom:4},children:S}),m&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,marginTop:4},children:[i.jsx(He,{size:9,color:"#3d444d"}),i.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:[m," session"]})]}),f>0&&i.jsxs("div",{style:{fontSize:10,color:"#3d444d",marginTop:2},children:[i.jsxs("span",{style:{color:"#79c0ff"},children:[X(l)," in"]}),h>0&&i.jsxs("span",{style:{color:"#3d444d"},children:[" · ",X(h)," cache"]}),i.jsx("br",{}),i.jsxs("span",{style:{color:"#56d364"},children:[X(u)," out"]})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[i.jsx(ce,{size:10,color:"#484f58"}),i.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Session cost"}),i.jsx(ze,{position:"bottom",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Cost of this session"}),i.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:"Accumulated from the first message of the active session."})]})})]}),f>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{fontSize:26,fontWeight:700,color:"#e6edf3",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:G(f)}),i.jsx("div",{style:{fontSize:9,color:"#484f58",marginTop:4},children:b>0?`~${G(f/b*60)}/hr`:"—"})]}):i.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"No active session"})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[i.jsx(Zt,{size:10,color:"#484f58"}),i.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Context"}),i.jsx(ze,{position:"bottom",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Free context space"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:[P?"Estimated from total tokens sent (CC scans JSONL; for OC uses input+cache tokens).":"Percentage available before Claude auto-compacts. Compact at 85% of window.",P&&i.jsxs(i.Fragment,{children:[i.jsx("br",{}),i.jsx("span",{style:{color:"#d29922"},children:"Approximate — OC does not report context directly."})]})]})]})})]}),a!==null?i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{fontSize:26,fontWeight:700,color:d,lineHeight:1,fontVariantNumeric:"tabular-nums"},children:[a,"%"]}),i.jsx("div",{style:{fontSize:9,color:d,opacity:.7,lineHeight:1,marginBottom:4},children:"free"}),i.jsxs("div",{style:{fontSize:9,color:"#484f58",marginBottom:6},children:[Math.round(n/1e3),"k used · limit ",Math.round(o/1e3),"k"]}),i.jsx("div",{style:{width:"100%",height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${c}%`,height:"100%",background:d,borderRadius:2,transition:"width 0.5s"}})}),i.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:4},children:P?"⚠ Estimated (OC)":a<20?"⚠ Consider /clear soon":a<40?"Moderate — ok for now":"No context pressure"})]}):i.jsx("div",{style:{fontSize:12,color:"#484f58"},children:e?"—":"Waiting for data…"})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[i.jsx(Qt,{size:10,color:"#484f58"}),i.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Model"}),i.jsx(ze,{position:"bottom",align:"right",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Active model"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Model used in the current session.",i.jsx("br",{}),"The ",i.jsx("span",{style:{color:"#d29922"},children:"burn rate"})," indicates tokens consumed per minute — useful for estimating quota depletion."]})]})})]}),A?i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#e6edf3",lineHeight:1.3},children:A}),i.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:3,wordBreak:"break-all"},children:w})]}):i.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"—"}),z>0&&i.jsx(D,{position:"top",align:"right",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Current burn rate"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Tokens consumed per minute in this session.",i.jsx("br",{}),"High burn rate = large context or long responses."]})]}),children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:8,cursor:"help"},children:[i.jsx(qt,{size:9,color:"#d29922"}),i.jsxs("span",{style:{fontSize:10,color:"#d29922",fontWeight:600,fontVariantNumeric:"tabular-nums"},children:[z.toLocaleString()," tok/min"]})]})})]})]})]})}const st=["#58a6ff","#3fb950","#d29922","#c9a0ff","#f0883e","#79c0ff","#56d364","#e3b341","#bc8cff","#f85149","#74aa9c","#8b5cf6","#ff7b72"];function je(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n);return st[Math.abs(e)%st.length]}function an(t){return t.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/^opencode-go\//,"")}function ln(t){const e=t.toLowerCase();if(e.includes("sonnet"))return"sonnet";if(e.includes("haiku"))return"haiku";if(e.includes("opus"))return"opus"}function cn({quota:t,weeklyModels:e}){const n=(e==null?void 0:e.reduce((o,s)=>o+s.tokens,0))??0,r=(e==null?void 0:e.reduce((o,s)=>o+s.cost,0))??0;return!e||e.length===0?i.jsxs(M,{children:[i.jsx(H,{icon:Xe,title:"Models this week"}),i.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No activity this week"})]}):i.jsxs(M,{children:[i.jsx(H,{icon:Xe,title:"Models this week"}),e.map(o=>{const s=ln(o.key),c=s==="sonnet"?t.weeklyHoursSonnet:s==="haiku"?t.weeklyHoursHaiku:s==="opus"?t.weeklyHoursOpus:void 0,a=s==="sonnet"?t.weeklyLimitSonnet:s==="opus"?t.weeklyLimitOpus:0,d=a&&c?Math.min(100,c/a*100):0,f=n>0?Math.round(o.tokens/n*100):0;return i.jsxs("div",{style:{marginBottom:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[i.jsx(D,{position:"bottom",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:je(o.key),fontWeight:700,fontSize:11,marginBottom:3},children:an(o.key)}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:[s?`Claude Code model · Estimated price: ~$${ee[s]}/M tokens`:"OpenCode model",i.jsx("br",{}),"Tokens = input + output ",s?" · Hours = 5 min active windows":"",a?` · Max weekly limit: ${a}h`:""]})]}),children:i.jsx("span",{style:{fontSize:11,color:je(o.key),fontWeight:700,flexShrink:0,cursor:"help"},children:o.label})}),c!==void 0?i.jsx("span",{style:{fontSize:13,color:"#e6edf3",fontWeight:600},children:c>0?`${c}h`:"—"}):null,a?i.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:["/ ",a,"h"]}):null,i.jsx("div",{style:{flex:1}}),i.jsx("span",{style:{fontSize:10,color:"#6e7681"},children:X(o.tokens)}),i.jsx("span",{style:{fontSize:10,color:"#3d444d"},children:"·"}),i.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:[f,"%"]}),i.jsxs("span",{style:{fontSize:10,color:"#3fb950",marginLeft:4},children:["~",G(o.cost)]})]}),a&&c?i.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${d}%`,height:"100%",background:d>85?"#f85149":d>65?"#d29922":je(o.key),borderRadius:2}})}):i.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${f}%`,height:"100%",background:je(o.key)+"aa",borderRadius:2}})})]},o.key)}),i.jsxs("div",{style:{borderTop:"1px solid #21262d",paddingTop:8,marginTop:4,display:"flex",gap:16},children:[i.jsxs("div",{children:[i.jsxs("div",{style:{fontSize:11,color:"#8b949e"},children:[X(n)," tokens"]}),i.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"total week"})]}),i.jsxs("div",{children:[i.jsxs("div",{style:{fontSize:11,color:"#3fb950"},children:["~",G(r)]}),i.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"estimated cost"})]})]}),i.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:6},children:"Tokens = input + output · Hours = 5 min active windows (Claude Code only) · Estimated blended price"})]})}const dn={Reading:"Read, Grep, Glob — tools for reading and searching files. High % may indicate excessive exploration before editing.",Editing:"Edit, Write, NotebookEdit — tools that modify files. This is the real productive work.",Terminal:"Bash — shell commands executed directly. Many Bash + few Grep may indicate inefficient searches.",Search:"WebFetch, WebSearch — internet and web page searches.",Agents:"Agent, Task, SendMessage — sub-agents launched for parallel tasks. They consume their own context quota.",Others:"Tools that don't fit in previous categories (Config, ToolSearch, etc.)."},de=[{label:"Reading",tools:["Read","Grep","Glob"],color:"#58a6ff"},{label:"Editing",tools:["Edit","Write","NotebookEdit"],color:"#3fb950"},{label:"Terminal",tools:["Bash"],color:"#d29922"},{label:"Search",tools:["WebFetch","WebSearch"],color:"#bc8cff"},{label:"Agents",tools:["Agent","Task","SendMessage"],color:"#f0883e"}];function fn(t){for(let e=0;e<de.length;e++)if(de[e].tools.some(n=>t.startsWith(n)))return e;return de.length}function un({events:t,cost:e}){const n=t.filter(a=>a.type==="Done"&&a.tool_name);if(n.length===0)return null;const r=new Array(de.length+1).fill(0);for(const a of n)r[fn(a.tool_name)]++;const o=n.length,s=(e==null?void 0:e.output_tokens)??0,c=[...de.map((a,d)=>({...a,count:r[d]})),{label:"Others",color:"#484f58",count:r[de.length]}].filter(a=>a.count>0).sort((a,d)=>d.count-a.count);return i.jsxs(M,{children:[i.jsx(H,{icon:ce,title:"Activity distribution",subtitle:"current session"}),i.jsx("div",{style:{height:8,background:"#21262d",borderRadius:4,overflow:"hidden",display:"flex",marginBottom:12},children:c.map(a=>i.jsx("div",{style:{width:`${a.count/o*100}%`,height:"100%",background:a.color}},a.label))}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[c.map(a=>{const d=Math.round(a.count/o*100),f=s>0?Math.round(s*a.count/o):0;return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("div",{style:{width:8,height:8,borderRadius:2,background:a.color,flexShrink:0}}),i.jsx("span",{style:{fontSize:11,color:"#8b949e",minWidth:70},children:a.label}),i.jsx("div",{style:{flex:1,height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${d}%`,height:"100%",background:a.color,opacity:.7,borderRadius:2}})}),i.jsxs("span",{style:{fontSize:10,color:"#6e7681",fontVariantNumeric:"tabular-nums",minWidth:28,textAlign:"right"},children:[d,"%"]}),i.jsx("span",{style:{fontSize:10,color:"#484f58",fontVariantNumeric:"tabular-nums",minWidth:42,textAlign:"right"},children:f>0?`~${X(f)}`:`${a.count}×`}),i.jsx(ze,{position:"top",align:"right",style:{flexShrink:0},content:i.jsxs("div",{children:[i.jsx("div",{style:{color:a.color,fontWeight:700,fontSize:11,marginBottom:3},children:a.label}),i.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:dn[a.label]??""})]})})]},a.label)}),i.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:2},children:[o," tool calls · ",s>0?`~${X(s)} estimated output tokens`:"tokens pending from active session"]})]})]})}function hn({stats:t}){const e=t.today,n=t.todayLabel,r=t.last7;if(!e&&r.messages===0)return i.jsxs(M,{children:[i.jsx(H,{icon:ce,title:"Activity (stats-cache.json)"}),i.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No data yet in stats-cache.json"})]});const o=[{label:"Messages",icon:ei,today:(e==null?void 0:e.messages)??0,week:r.messages,color:"#58a6ff",tooltip:`Total messages (human + assistant).
|
|
2
|
+
Divide by 2 to estimate real prompts.
|
|
3
|
+
Source: ~/.claude/stats-cache.json`},{label:"Sessions",icon:He,today:(e==null?void 0:e.sessions)??0,week:r.sessions,color:"#3fb950",tooltip:`Different conversations started with Claude Code.
|
|
4
|
+
Each time you run "claude" in a directory counts as a session.`},{label:"Tools",icon:ti,today:(e==null?void 0:e.tools)??0,week:r.tools,color:"#d29922",tooltip:`Tool calls executed (Read, Edit, Bash, Grep…).
|
|
5
|
+
High number indicates code-intensive sessions.`},{label:"Out tokens",icon:Fe,today:(e==null?void 0:e.outputTokens)??0,week:r.outputTokens,color:"#a371f7",fmt:X,tooltip:`Tokens generated by Claude in responses.
|
|
6
|
+
These most influence session cost.`}];return i.jsxs(M,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx(ii,{size:13,color:"#58a6ff"}),i.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700},children:"Activity"}),n&&i.jsxs("span",{style:{fontSize:10,color:"#484f58",marginLeft:2},children:[n," / 7 days"]})]}),t.cacheDate&&i.jsxs("span",{style:{fontSize:9,color:"#3d444d"},children:["cache: ",t.cacheDate]})]}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10,justifyItems:"center"},children:o.map(s=>{const c=s.fmt??(a=>a.toLocaleString());return i.jsx(D,{position:"bottom",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:s.color,fontWeight:700,fontSize:11,marginBottom:4},children:s.label}),i.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5,whiteSpace:"pre-line"},children:s.tooltip})]}),children:i.jsxs("div",{style:{textAlign:"center",cursor:"help"},children:[i.jsx(s.icon,{size:11,color:s.color,style:{marginBottom:4}}),i.jsx("div",{style:{fontSize:9,color:"#6e7681",marginBottom:2,fontWeight:600},children:s.label}),i.jsx("div",{style:{fontSize:16,fontWeight:700,color:s.color,lineHeight:1,fontVariantNumeric:"tabular-nums"},children:c(s.today)}),i.jsx("div",{style:{fontSize:9,color:"#484f58",marginBottom:4},children:n??"—"}),i.jsx("div",{style:{fontSize:11,color:"#6e7681",fontVariantNumeric:"tabular-nums"},children:c(s.week)}),i.jsx("div",{style:{fontSize:9,color:"#3d444d"},children:"7 days"})]})},s.label)})}),i.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:10},children:["Source: ~/.claude/stats-cache.json · Messages include human + assistant (÷2 ≈ real prompts) · ",t.allTime.sessions," total sessions"]}),t.cacheIsStale&&i.jsxs("div",{style:{fontSize:9,color:"#d29922",marginTop:4},children:["⚠ Stale cache (",t.cacheDate,") — Claude Code updates this file when each CLI session ends"]})]})}function pn({quota:t,cost:e}){const n=(t.weeklyTokensSonnet??0)+(t.weeklyTokensOpus??0)+(t.weeklyTokensHaiku??0),r=(t.weeklyTokensSonnet??0)/1e6*ee.sonnet+(t.weeklyTokensOpus??0)/1e6*ee.opus+(t.weeklyTokensHaiku??0)/1e6*ee.haiku,o=r*4.3,s=r/7,c=en((e==null?void 0:e.model)??""),a=tn((e==null?void 0:e.model)??""),d=t.burnRateTokensPerMin>0?t.burnRateTokensPerMin*60/1e6*c:0;return i.jsxs(M,{children:[i.jsx(H,{icon:jt,title:"Monthly projection",subtitle:"based on this week"}),i.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap",marginBottom:10},children:[i.jsx(D,{position:"top",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Monthly projection"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Weekly consumption × 4.3 (weeks/month).",i.jsx("br",{}),"Assumes upcoming weeks will have the same pace.",i.jsx("br",{}),"Based on actual Sonnet, Opus, and Haiku tokens with blended prices."]})]}),children:i.jsxs("div",{style:{cursor:"help"},children:[i.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#e6edf3",fontVariantNumeric:"tabular-nums",lineHeight:1},children:r>0?`~${G(o)}`:"—"}),i.jsxs("div",{style:{fontSize:9,color:"#484f58"},children:["/month · ",r>0?`${G(r)}/week · ${G(s)}/day`:"no data"]})]})}),d>0&&i.jsx(D,{position:"top",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Cost per hour (now)"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Calculated with active model (",a,") at blended price.",i.jsx("br",{}),t.burnRateTokensPerMin.toLocaleString()," tok/min × 60 ÷ 1M × price/M"]})]}),children:i.jsxs("div",{style:{cursor:"help"},children:[i.jsxs("div",{style:{fontSize:18,fontWeight:700,color:"#d29922",fontVariantNumeric:"tabular-nums",lineHeight:1},children:["~",G(d),"/h"]}),i.jsxs("div",{style:{fontSize:9,color:"#484f58"},children:["now · ",t.burnRateTokensPerMin.toLocaleString()," tok/min"]})]})})]}),n>0&&i.jsxs("div",{style:{fontSize:10,color:"#484f58"},children:[X(n)," tokens this week · estimated blended input/output prices"]})]})}const yn={"cache hit":'Tokens served from prompt cache. They are ~10× cheaper than fresh input. Indicates how much context Claude already "remembered" without reprocessing.',"cache create":"Tokens written to cache for the first time. Paid once and reused in subsequent reads. More expensive than fresh input but amortize over time.","input fresh":"New context that Claude processed without prior cache — full input price.",output:"Tokens generated by Claude in responses. They are the most expensive (~3× more than input in Sonnet)."};function mn({cost:t}){const{input_tokens:e,cache_read:n,cache_creation:r,output_tokens:o}=t,s=e+n+r+o,c=s>0?Math.round(n/(e+n+r)*100):0,a=n/1e6*Wt(t.model),d=c>=70?"#3fb950":c>=40?"#d29922":"#f85149",f=[{label:"cache hit",color:"#3fb95099",tokens:n,pct:s>0?n/s*100:0},{label:"cache create",color:"#58a6ff55",tokens:r,pct:s>0?r/s*100:0},{label:"input fresh",color:"#8b949e55",tokens:e,pct:s>0?e/s*100:0},{label:"output",color:"#d2992255",tokens:o,pct:s>0?o/s*100:0}].filter(l=>l.tokens>0);return i.jsxs(M,{children:[i.jsx(H,{icon:St,title:"Cache efficiency",subtitle:"current session",color:d}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10},children:[i.jsxs("span",{style:{fontSize:28,fontWeight:700,color:d,fontVariantNumeric:"tabular-nums",lineHeight:1},children:[c,"%"]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:11,color:"#e6edf3"},children:"cache hit rate"}),a>.001&&i.jsxs("div",{style:{fontSize:10,color:"#3fb950"},children:["~",G(a)," saved"]}),i.jsx(D,{position:"bottom",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Why 70%?"}),i.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"Below 70% cache savings are marginal. In long and continuous sessions hit rate naturally rises. Avoid using /clear in the middle of a session to not lose accumulated cache."})]}),children:i.jsx("span",{style:{fontSize:9,color:"#484f58",cursor:"help",textDecoration:"underline dotted"},children:"target ≥70%"})})]})]}),i.jsx("div",{style:{height:8,background:"#21262d",borderRadius:4,overflow:"hidden",display:"flex",marginBottom:10},children:f.map(l=>i.jsx("div",{style:{width:`${l.pct}%`,height:"100%",background:l.color}},l.label))}),i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 14px"},children:f.map(l=>i.jsx(D,{position:"top",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:l.color.substring(0,7),fontWeight:700,fontSize:11,marginBottom:3},children:l.label}),i.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:yn[l.label]??""})]}),children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,cursor:"help"},children:[i.jsx("div",{style:{width:8,height:8,borderRadius:2,background:l.color,flexShrink:0}}),i.jsx("span",{style:{fontSize:10,color:"#6e7681"},children:X(l.tokens)}),i.jsx("span",{style:{fontSize:10,color:"#484f58"},children:l.label})]})},l.label))})]})}function xn(t){const e=new Map;for(const n of t){const r=e.get(n.toolName)??{totalCalls:0,alertCount:0};r.totalCalls+=n.count,r.alertCount+=1,e.set(n.toolName,r)}return[...e.entries()].map(([n,r])=>({toolName:n,...r})).sort((n,r)=>r.totalCalls-n.totalCalls)}function gn({cost:t}){const{loops:e,efficiency_score:n}=t,r=(e==null?void 0:e.length)??0,o=e?xn(e):[],s=o.reduce((u,h)=>u+h.totalCalls,0),c=o[0],a=1200,d=s*a/1e6*ee.sonnet,f=n>=90?"#3fb950":n>=70?"#d29922":"#f85149",l=r>0;return i.jsxs(M,{children:[i.jsx(H,{icon:Ge,title:"Loops and efficiency",subtitle:"current session",color:l?"#f85149":"#3fb950"}),i.jsxs("div",{style:{display:"flex",gap:16,marginBottom:l?10:0},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:26,fontWeight:700,color:l?"#f85149":"#3fb950",lineHeight:1},children:r}),i.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"loop blocks"}),s>0&&i.jsxs("div",{style:{fontSize:9,color:"#3d444d"},children:[s," total calls"]})]}),i.jsx(D,{position:"bottom",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:f,fontWeight:700,fontSize:11,marginBottom:3},children:"Efficiency score"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["100 = no loops detected.",i.jsx("br",{}),"-10 per loop block (cap -25), plus penalties for excessive calls + high cost.",i.jsx("br",{}),"Below 70 → the agent is repeating itself. Consider giving clearer instructions or /clear to reset context."]})]}),children:i.jsxs("div",{style:{cursor:"help"},children:[i.jsx("div",{style:{fontSize:26,fontWeight:700,color:f,lineHeight:1},children:n}),i.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"efficiency /100"})]})}),l&&i.jsx(D,{position:"bottom",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Wasted cost estimate"}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:[s," redundant tool calls × ~",a.toLocaleString()," tokens/tool × Sonnet blended price.",i.jsx("br",{}),"Conservative — actual cost higher if loops involve large file reads/edits."]})]}),children:i.jsxs("div",{style:{cursor:"help"},children:[i.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"#d29922",lineHeight:1},children:["~",G(d)]}),i.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"wasted cost"})]})})]}),l&&i.jsxs("div",{style:{marginBottom:10},children:[c&&i.jsxs("div",{style:{fontSize:10,color:"#8b949e",marginBottom:6},children:["Most loops: ",i.jsx("span",{style:{color:"#f85149",fontWeight:600},children:c.toolName})," — ",c.totalCalls," calls in ",c.alertCount," block",c.alertCount>1?"s":"","."," ",c.toolName==="Edit"||c.toolName==="Bash"?"The agent is likely re-trying the same operation. Try a /clear and rephrase the instruction.":c.toolName==="Read"?"The agent is re-reading files without making progress. Provide more precise file paths.":"Consider whether the task needs more structure from the start."]}),i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:[o.slice(0,8).map(u=>i.jsx(D,{position:"top",align:"left",content:i.jsxs("div",{children:[i.jsx("div",{style:{color:"#f85149",fontWeight:700,fontSize:11,marginBottom:3},children:u.toolName}),i.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:[u.totalCalls," total redundant calls",i.jsx("br",{}),"across ",u.alertCount," detected loop block",u.alertCount>1?"s":""]})]}),children:i.jsxs("span",{style:{fontSize:11,color:"#f85149",background:"#f8514914",border:"1px solid #f8514930",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[u.toolName," ×",u.totalCalls]})},u.toolName)),o.length>8&&i.jsxs("span",{style:{fontSize:10,color:"#484f58",padding:"2px 4px"},children:["+",o.length-8," more"]})]})]}),i.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:i.jsx("div",{style:{width:`${n}%`,height:"100%",background:f,borderRadius:2,transition:"width 0.5s"}})})]})}const vn={error:{color:"#f85149",bg:"#3d1717",border:"#f8514940",Icon:ni},warning:{color:"#d29922",bg:"#2d2008",border:"#d2992240",Icon:Ge},info:{color:"#58a6ff",bg:"#0d1e33",border:"#58a6ff30",Icon:bt},success:{color:"#3fb950",bg:"#0d1f10",border:"#3fb95030",Icon:kt}};function bn({tips:t}){return t.length===0?i.jsxs(M,{children:[i.jsx(H,{icon:Je,title:"Real-time optimizer",color:"#d29922"}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#484f58",fontSize:12},children:[i.jsx(kt,{size:14,color:"#3fb950"}),"Clean session — no optimization suggestions at this time"]})]}):i.jsxs(M,{children:[i.jsx(H,{icon:Je,title:"Real-time optimizer",subtitle:`${t.length} suggestion${t.length>1?"s":""}`,color:"#d29922"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.map((e,n)=>{const r=vn[e.level];return i.jsxs("div",{style:{background:r.bg,border:`1px solid ${r.border}`,borderLeft:`3px solid ${r.color}`,borderRadius:6,padding:"8px 10px"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[i.jsx(r.Icon,{size:13,color:r.color,style:{flexShrink:0,marginTop:2}}),i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[i.jsx("span",{style:{fontSize:11,fontWeight:700,color:r.color},children:e.title}),e.source&&i.jsx("span",{style:{fontSize:9,fontWeight:700,color:"#484f58",background:"#21262d",border:"1px solid #30363d",borderRadius:3,padding:"1px 5px",textTransform:"uppercase",letterSpacing:"0.05em"},children:e.source==="claude-code"?"CC":e.source==="opencode"?"OC":e.source})]}),i.jsx("div",{style:{fontSize:11,color:"#8b949e",lineHeight:1.5},children:e.text})]})]}),e.prompt&&i.jsxs("div",{style:{marginTop:8,padding:"6px 10px",background:"#0d1117",border:"1px solid #30363d",borderRadius:5},children:[i.jsxs("div",{style:{fontSize:9,color:"#484f58",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:4},children:["Prompt that caused it — Block #",e.blockIndex]}),i.jsxs("div",{style:{fontSize:11,color:"#7d8590",fontStyle:"italic",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:80,overflow:"hidden",WebkitMaskImage:"linear-gradient(to bottom, black 60%, transparent 100%)"},children:['"',e.prompt,'"']})]})]},n)})})]})}function jn({quota:t,cost:e,events:n,prompts:r,claudeStats:o,weeklyModels:s}){if(!t)return i.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#484f58",fontSize:13},children:"Loading usage data…"});const c=rn(e,t,n,r);return i.jsx("div",{style:{padding:"16px 20px"},children:i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:"auto",gap:12,maxWidth:1200,margin:"0 auto"},children:[i.jsx("div",{style:{gridColumn:"1 / -1"},children:i.jsx(sn,{quota:t,cost:e})}),o&&i.jsx("div",{style:{gridColumn:"1 / -1"},children:i.jsx(hn,{stats:o})}),i.jsx("div",{style:{gridColumn:"1 / -1"},children:i.jsx(bn,{tips:c})}),n&&n.length>0?i.jsx(un,{events:n,cost:e}):i.jsx("div",{}),e?i.jsx(mn,{cost:e}):i.jsxs(M,{children:[i.jsx(H,{icon:St,title:"Cache efficiency"}),i.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No active session data"})]}),i.jsx(cn,{quota:t,weeklyModels:s}),e?i.jsx(gn,{cost:e}):i.jsxs(M,{children:[i.jsx(H,{icon:Ge,title:"Loops and efficiency"}),i.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No active session data"})]}),i.jsx("div",{style:{gridColumn:"1 / -1"},children:i.jsx(pn,{quota:t,cost:e})})]})})}const Ee={7:"7 days",30:"30 days",90:"90 days"},Sn={all:"All","claude-code":"Claude Code",opencode:"OpenCode"},at=["#58a6ff","#3fb950","#d29922","#c9a0ff","#f0883e","#79c0ff","#56d364","#e3b341","#bc8cff","#f85149","#74aa9c","#8b5cf6","#ff7b72","#a5d6ff","#7ee787"];function lt(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n);return at[Math.abs(e)%at.length]}function kn(t){return t.replace(/^claude-/,"").replace(/-\d{8}$/,"").replace(/^opencode-go\//,"")}function wn(t){return t==="No project"?t:t.split("/").filter(Boolean).pop()??t}function zn(t){const e=new Map;for(const n of t){e.has(n.date)||e.set(n.date,{date:n.date});const r=e.get(n.date);r[n.model]=(r[n.model]??0)+n.tokens}return[...e.values()]}function An(t){const e={};for(const n of t)e[n.model]||(e[n.model]={tokens:0,cost:0}),e[n.model].tokens+=n.tokens,e[n.model].cost+=n.cost;return Object.entries(e).map(([n,r])=>({key:n,label:kn(n),...r})).filter(n=>n.tokens>0).sort((n,r)=>r.tokens-n.tokens)}function Pn(t){const e=new Map;for(const n of t){const r=e.get(n.project)??{project:n.project,cc_hours:0,oc_hours:0,cc_cost:0,oc_cost:0,sessions:0,total_hours:0};n.source==="opencode"?(r.oc_hours+=n.hours,r.oc_cost+=n.cost):(r.cc_hours+=n.hours,r.cc_cost+=n.cost),r.sessions+=n.sessions,r.total_hours+=n.hours,e.set(n.project,r)}return[...e.values()].sort((n,r)=>r.total_hours-n.total_hours)}const Se={fontSize:11,fontWeight:600,color:"#6e7681",marginBottom:14,textTransform:"uppercase",letterSpacing:"0.05em"},ct={contentStyle:{background:"#161b22",border:"1px solid #30363d",borderRadius:6,fontSize:11},labelStyle:{color:"#e6edf3",fontWeight:600},itemStyle:{color:"#8b949e"}};function ae({icon:t,label:e,value:n,sub:r,color:o="#58a6ff",tip:s}){return i.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",flex:1,minWidth:140},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[i.jsx("span",{style:{color:o,opacity:.8},children:t}),i.jsx(D,{content:s,position:"bottom",align:"left",children:i.jsx("span",{style:{fontSize:10,color:"#6e7681",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",cursor:"default",borderBottom:"1px dotted #484f58"},children:e})})]}),i.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#e6edf3",lineHeight:1},children:n}),r&&i.jsx("div",{style:{fontSize:10,color:"#484f58",marginTop:4},children:r})]})}function On({content:t}){return i.jsx("div",{style:{fontFamily:"inherit",lineHeight:1.7,color:"#c9d1d9"},children:t.split(`
|
|
7
|
+
`).map((e,n)=>e.startsWith("# ")?i.jsx("h1",{style:{fontSize:18,fontWeight:700,color:"#e6edf3",margin:"20px 0 8px",borderBottom:"1px solid #21262d",paddingBottom:6},children:e.slice(2)},n):e.startsWith("## ")?i.jsx("h2",{style:{fontSize:15,fontWeight:600,color:"#e6edf3",margin:"16px 0 6px"},children:e.slice(3)},n):e.startsWith("### ")?i.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"#8b949e",margin:"12px 0 4px"},children:e.slice(4)},n):e.startsWith("- [x] ")?i.jsxs("div",{style:{display:"flex",gap:8,margin:"3px 0",fontSize:12,color:"#3fb950"},children:[i.jsx("span",{style:{width:14,height:14,borderRadius:3,background:"#3fb950",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,color:"#0d1117",flexShrink:0},children:"✓"}),i.jsx("span",{style:{textDecoration:"line-through",color:"#6e7681"},children:e.slice(6)})]},n):e.startsWith("- [ ] ")?i.jsxs("div",{style:{display:"flex",gap:8,margin:"3px 0",fontSize:12},children:[i.jsx("span",{style:{width:14,height:14,borderRadius:3,border:"1.5px solid #484f58",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0}}),i.jsx("span",{children:e.slice(6)})]},n):e.startsWith("- ")?i.jsxs("div",{style:{margin:"3px 0",paddingLeft:16,fontSize:12},children:["· ",e.slice(2)]},n):e.startsWith("> ")?i.jsx("blockquote",{style:{margin:"8px 0",paddingLeft:12,borderLeft:"3px solid #30363d",color:"#8b949e",fontSize:12},children:e.slice(2)},n):e.startsWith("---")?i.jsx("hr",{style:{border:"none",borderTop:"1px solid #21262d",margin:"14px 0"}},n):e.trim()===""?i.jsx("div",{style:{height:6}},n):i.jsx("p",{style:{margin:"3px 0",fontSize:12},children:e},n))})}function Cn(){const[t,e]=C.useState([]),[n,r]=C.useState(!1),[o,s]=C.useState(null),[c,a]=C.useState(!1),[d,f]=C.useState(!1),[l,u]=C.useState(null);function h(){fetch("/api/weekly-reports").then(m=>m.json()).then(e).catch(()=>{})}C.useEffect(()=>{h()},[]);async function y(){a(!0),u(null);try{const m=await fetch("/api/weekly-reports/generate-now",{method:"POST"}).then(g=>g.json());u(m.skipped?`Already exists: ${m.date}`:`Generated: ${m.date}`),m.skipped||h()}catch{u("Error generating")}a(!1)}async function S(){f(!0),u(null);try{const m=await fetch("/api/weekly-reports/import-local",{method:"POST"}).then(g=>g.json());u(`${m.imported} imported, ${m.skipped} already existed`),m.imported>0&&h()}catch{u("Error importing")}f(!1)}async function x(m){const g=await fetch(`/api/weekly-reports/${m}`);g.ok&&(s(await g.json()),r(!1))}async function v(m,g){g.stopPropagation(),await fetch(`/api/weekly-reports/${m}`,{method:"DELETE"}).catch(()=>{}),(o==null?void 0:o.date)===m&&s(null),h()}const b={display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid #30363d",background:"none",color:"#8b949e",transition:"color 0.15s, border-color 0.15s"};return i.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,marginBottom:0},children:[i.jsxs("div",{style:{padding:"10px 14px",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[i.jsx(Qe,{size:12,color:"#6e7681"}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#8b949e"},children:"Weekly reports"}),l&&i.jsx("span",{style:{fontSize:11,color:"#3fb950"},children:l}),i.jsx("div",{style:{flex:1}}),i.jsxs("button",{style:{...b,color:c?"#484f58":"#58a6ff",borderColor:c?"#30363d":"#58a6ff30"},onClick:y,disabled:c,children:[i.jsx(Fe,{size:11}),c?"Generating…":"Generate"]}),i.jsx("button",{style:b,onClick:S,disabled:d,children:d?"Importing…":"Import"}),i.jsxs("button",{style:{...b,color:n?"#e6edf3":"#6e7681",borderColor:n?"#30363d":"#21262d"},onClick:()=>r(m=>!m),children:[t.length," reports",n?i.jsx(si,{size:11}):i.jsx(ai,{size:11})]})]}),n&&i.jsx("div",{style:{borderTop:"1px solid #21262d",padding:"8px 10px",display:"flex",flexDirection:"column",gap:4,maxHeight:200,overflowY:"auto"},children:t.length===0?i.jsx("span",{style:{fontSize:11,color:"#484f58",padding:"4px 4px"},children:'No reports — use "Generate" to create one'}):t.map(m=>i.jsxs("div",{style:{border:"1px solid #21262d",borderRadius:5,display:"flex",alignItems:"center",transition:"background 0.1s"},onMouseEnter:g=>{g.currentTarget.style.background="#21262d"},onMouseLeave:g=>{g.currentTarget.style.background="none"},children:[i.jsxs("button",{onClick:()=>x(m.date),style:{background:"none",border:"none",padding:"7px 10px",cursor:"pointer",textAlign:"left",display:"flex",gap:10,alignItems:"center",color:"inherit",flex:1,minWidth:0},children:[i.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#58a6ff",minWidth:90,flexShrink:0},children:m.date}),i.jsx("span",{style:{fontSize:11,color:"#6e7681",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.preview})]}),i.jsx("button",{onClick:g=>v(m.date,g),title:"Delete report",style:{background:"none",border:"none",cursor:"pointer",padding:"7px 10px",display:"flex",alignItems:"center",color:"#6e7681",flexShrink:0},onMouseEnter:g=>{g.currentTarget.style.color="#f85149"},onMouseLeave:g=>{g.currentTarget.style.color="#6e7681"},children:i.jsx(li,{size:12})})]},m.id))}),o&&i.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"#00000088",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>s(null),children:i.jsxs("div",{style:{background:"#161b22",border:"1px solid #30363d",borderRadius:10,width:"80%",maxWidth:820,maxHeight:"82vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px #00000088"},onClick:m=>m.stopPropagation(),children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #21262d",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx(Qe,{size:13,color:"#58a6ff"}),i.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"#e6edf3"},children:["Weekly report — ",o.date]})]}),i.jsx("button",{onClick:()=>s(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",padding:4},children:i.jsx(ci,{size:16})})]}),i.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 24px"},children:i.jsx(On,{content:o.report_markdown})})]})})]})}function Rn({quota:t,cost:e,events:n,prompts:r,claudeStats:o}){const[s,c]=C.useState("30"),[a,d]=C.useState("all"),[f,l]=C.useState([]),[u,h]=C.useState([]),[y,S]=C.useState([]),[x,v]=C.useState(null),[b,m]=C.useState(!0);C.useEffect(()=>{m(!0),fetch(`/api/analytics?days=${s}&project_days=${s}`).then(p=>p.json()).then(p=>{l(p.daily??[]),h(p.by_model??[]),S(p.project_hours??[]),v(p.kpis??null)}).catch(()=>{}).finally(()=>m(!1))},[s]);const g=a==="all"?f:f.filter(p=>p.source===a),k=a==="all"?u:u.filter(p=>p.source===a),w=a==="all"?y:y.filter(p=>p.source===a);zn(k);const z=An(k),A=g.reduce((p,O)=>p+O.input_tokens,0),P=g.reduce((p,O)=>p+O.output_tokens,0),_=g.reduce((p,O)=>p+O.cache_read,0),$=A+P+_,T=A+_>0?Math.round(_/(A+_)*100):0,W=Pn(w),J=W.reduce((p,O)=>p+O.total_hours,0),xe=g.map(p=>({date:p.date,tokens:p.input_tokens+p.output_tokens+p.cache_read,sessions:p.sessions})),B=C.useMemo(()=>{if(a==="all"||!x)return x;const p=Date.now()-7*864e5,O=Date.now()-30*864e5,R=g.filter(I=>new Date(I.date+"T12:00:00").getTime()>=p),ge=g.filter(I=>new Date(I.date+"T12:00:00").getTime()>=O);return{week_cost:R.reduce((I,F)=>I+F.cost,0),month_cost:ge.reduce((I,F)=>I+F.cost,0),week_sessions:R.reduce((I,F)=>I+F.sessions,0),month_sessions:ge.reduce((I,F)=>I+F.sessions,0),week_loops:R.reduce((I,F)=>I+F.loops,0),avg_efficiency:R.length?Math.round(R.reduce((I,F)=>I+F.avg_efficiency,0)/R.length):0}},[a,x,g]);return i.jsxs("div",{style:{height:"100%",overflowY:"auto",background:"#0d1117"},children:[i.jsx("div",{style:{padding:"16px 20px 12px"},children:i.jsx(Cn,{})}),i.jsx("div",{style:{padding:"0 20px 2px"},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#484f58",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Real time"}),i.jsx("div",{style:{flex:1,height:1,background:"#21262d"}})]})}),i.jsx(jn,{quota:t,cost:e,events:n,prompts:r,claudeStats:o,weeklyModels:z}),i.jsxs("div",{style:{padding:"0 20px 20px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0 16px",borderTop:"1px solid #21262d"},children:[i.jsx(jt,{size:12,color:"#484f58"}),i.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#484f58",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Historical analysis"}),i.jsx("div",{style:{flex:1}}),i.jsx("div",{style:{display:"flex",gap:4,marginRight:8},children:["all","claude-code","opencode"].map(p=>i.jsx("button",{onClick:()=>d(p),style:{padding:"3px 9px",borderRadius:4,fontSize:11,cursor:"pointer",background:a===p?"#21262d":"none",border:`1px solid ${a===p?"#58a6ff":"#30363d"}`,color:a===p?"#58a6ff":"#6e7681",transition:"all 0.15s"},children:Sn[p]},p))}),i.jsx("div",{style:{display:"flex",gap:4},children:["7","30","90"].map(p=>i.jsx("button",{onClick:()=>c(p),style:{padding:"3px 9px",borderRadius:4,fontSize:11,cursor:"pointer",background:s===p?"#1f6feb":"none",border:`1px solid ${s===p?"#1f6feb":"#30363d"}`,color:s===p?"#fff":"#8b949e",transition:"all 0.15s"},children:Ee[p]},p))})]}),b&&i.jsx("div",{style:{color:"#484f58",fontSize:12,textAlign:"center",padding:"20px 0"},children:"Loading…"}),!b&&B&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap"},children:[i.jsx(ae,{icon:i.jsx(Ze,{size:13}),label:"Real spend 7d",value:be(B.week_cost),sub:`${B.week_sessions} sessions · DB`,color:"#58a6ff",tip:"Real spend in the last 7 days from the claudestat database. Complements the projection above that uses stats-cache."}),i.jsx(ae,{icon:i.jsx(Ze,{size:13}),label:"Real spend 30d",value:be(B.month_cost),sub:`${B.month_sessions} sessions`,color:"#a371f7",tip:"Real spend in the last 30 days recorded in the claudestat database."}),i.jsx(ae,{icon:i.jsx(ce,{size:13}),label:`Tokens ${Ee[s]}`,value:pe($),sub:`In+Out: ${pe(A+P)}`,color:"#d29922",tip:"Total tokens for the period (input + output + cache read). Cache is ~10× cheaper than fresh tokens."}),i.jsx(ae,{icon:i.jsx(He,{size:13}),label:`Hours ${Ee[s]}`,value:$e(J),sub:`${W.length} projects`,color:"#3fb950",tip:"Total estimated work time (sum of durations of all sessions in the period)."}),i.jsx(ae,{icon:i.jsx(ri,{size:13}),label:"Loops 7d",value:String(B.week_loops),sub:B.week_loops>20?"High — review":"Normal",color:B.week_loops>20?"#f85149":"#3fb950",tip:"Loops detected in the last week (same tool repeated ≥4 times without progress). Each loop wastes tokens and cost."}),i.jsx(ae,{icon:i.jsx(Fe,{size:13}),label:"Avg efficiency",value:`${B.avg_efficiency}%`,sub:`Cache: ${T}%`,color:B.avg_efficiency>=80?"#3fb950":B.avg_efficiency>=60?"#d29922":"#f85149",tip:`Average efficiency for the period (100% = no loops or redundancy). Cache: ${T}% of tokens come from cache (cheaper).`})]}),i.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px",marginBottom:14},children:[i.jsx("div",{style:Se,children:"Daily cost (USD)"}),i.jsx(Ye,{width:"100%",height:130,children:i.jsxs(di,{data:g,margin:{top:4,right:4,left:-24,bottom:0},children:[i.jsx(Be,{strokeDasharray:"3 3",stroke:"#21262d"}),i.jsx(Re,{dataKey:"date",tick:{fontSize:9,fill:"#6e7681"},tickFormatter:p=>p.slice(5),axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),i.jsx(we,{tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1,tickFormatter:p=>`$${p.toFixed(1)}`}),i.jsx(Ue,{...ct,cursor:{stroke:"#30363d"},formatter:p=>[be(p),"Cost"]}),i.jsx(Ie,{type:"monotone",dataKey:"cost",stroke:"#58a6ff",dot:!1,strokeWidth:2})]})})]}),i.jsxs("div",{style:{display:"flex",gap:14,marginBottom:14},children:[i.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[i.jsx("div",{style:Se,children:"Tokens per day · fluctuation"}),i.jsx(Ye,{width:"100%",height:130,children:i.jsxs(qi,{data:xe,margin:{top:4,right:14,left:-24,bottom:0},children:[i.jsx(Be,{strokeDasharray:"3 3",stroke:"#21262d"}),i.jsx(Re,{dataKey:"date",tick:{fontSize:9,fill:"#6e7681"},tickFormatter:p=>p.slice(5),axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),i.jsx(we,{yAxisId:"left",tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1,tickFormatter:pe}),i.jsx(we,{yAxisId:"right",orientation:"right",tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1}),i.jsx(Ue,{...ct,cursor:{fill:"#21262d"},formatter:(p,O)=>[O==="Tokens"?pe(p):p,O]}),i.jsx(Jt,{iconSize:8,wrapperStyle:{fontSize:10,color:"#8b949e"}}),i.jsx(vt,{yAxisId:"left",dataKey:"tokens",name:"Tokens",fill:"#1f6feb88",radius:[2,2,0,0]}),i.jsx(Ie,{yAxisId:"right",dataKey:"sessions",name:"Sessions",stroke:"#3fb950",dot:!1,strokeWidth:2})]})})]}),i.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[i.jsx("div",{style:Se,children:"Token share by model"}),(()=>{const p=z.reduce((O,R)=>O+R.tokens,0);return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:z.map(O=>{const R=p>0?O.tokens/p*100:0;return i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[i.jsx("span",{style:{fontSize:11,fontWeight:600,color:lt(O.key)},children:O.label}),i.jsxs("span",{style:{fontSize:11,color:"#8b949e"},children:[pe(O.tokens)," · ",R.toFixed(1),"%"]})]}),i.jsx("div",{style:{height:6,background:"#21262d",borderRadius:3},children:i.jsx("div",{style:{height:"100%",width:`${R}%`,background:lt(O.key),borderRadius:3,minWidth:R>0?3:0}})})]},O.key)})})})()]})]}),W.length>0&&i.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:14},children:[i.jsx(oi,{size:11,color:"#6e7681"}),i.jsx(D,{content:"Only includes sessions tracked by claudestat (since install). Full project history available in the Projects tab.",children:i.jsx("span",{style:Se,children:"Hours by project ⓘ"})}),a==="all"&&i.jsxs("div",{style:{display:"flex",gap:8,marginLeft:6},children:[i.jsxs("span",{style:{fontSize:9,color:"#58a6ff",display:"flex",alignItems:"center",gap:3},children:[i.jsx("span",{style:{width:8,height:8,background:"#58a6ff",borderRadius:2,display:"inline-block"}}),"CC"]}),i.jsxs("span",{style:{fontSize:9,color:"#3fb950",display:"flex",alignItems:"center",gap:3},children:[i.jsx("span",{style:{width:8,height:8,background:"#3fb950",borderRadius:2,display:"inline-block"}}),"OC"]})]}),i.jsx("div",{style:{flex:1}})]}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:W.map(p=>{const O=J>0?p.total_hours/J*100:0,R=p.total_hours>0?p.cc_hours/p.total_hours*100:0,ge=a==="opencode"?"#3fb950":"#58a6ff";return i.jsxs("div",{children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[i.jsx("span",{style:{fontSize:11,color:"#c9d1d9",fontWeight:500},children:wn(p.project)}),i.jsxs("div",{style:{display:"flex",gap:12},children:[a==="all"&&p.oc_hours>0&&i.jsxs("span",{style:{fontSize:10,color:"#3fb950"},children:["OC: ",$e(p.oc_hours)]}),i.jsxs("span",{style:{fontSize:10,color:"#6e7681"},children:[p.sessions," sessions"]}),i.jsx("span",{style:{fontSize:10,color:"#d29922",minWidth:40,textAlign:"right"},children:be(p.cc_cost+p.oc_cost)}),i.jsx("span",{style:{fontSize:11,color:"#e6edf3",fontWeight:600,minWidth:36,textAlign:"right"},children:$e(p.total_hours)})]})]}),i.jsx("div",{style:{height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:a==="all"?i.jsxs("div",{style:{height:"100%",width:`${O}%`,display:"flex"},children:[p.cc_hours>0&&i.jsx("div",{style:{height:"100%",width:`${R}%`,background:"#58a6ff",minWidth:2}}),p.oc_hours>0&&i.jsx("div",{style:{height:"100%",width:`${100-R}%`,background:"#3fb950",minWidth:2}})]}):i.jsx("div",{style:{height:"100%",width:`${O}%`,background:ge,borderRadius:2,transition:"width 0.3s"}})})]},p.project)})})]})]}),!b&&g.length===0&&i.jsx("div",{style:{color:"#484f58",fontSize:12,textAlign:"center",padding:"40px 0"},children:"No data for the selected period"})]})]})}export{Rn as AnalyticsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,T as a,R as G,X as N,Y,a as V,b as K}from"./index-CMhe3KaT.js";import{a as m,E as q,c as Q,J as X,d as J,K as U,N as H,X as w,O as Z,Q as ee,H as te,j as D,U as oe,V as ie,Y as F}from"./vendor-lucide-ClCW-axQ.js";import{M as C,f as W,s as se,a as ne,b as $,c as le,d as S}from"./shared-BbBtsdh1.js";import{L as re,a as de}from"./LineChart-BOWYkkEW.js";import"./vendor-react-gHSHIE2L.js";const k={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"};function A(t){return new Date(t).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})}const p={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 ae({session:t,isActive:o,selectable:i,selected:r=!1,onSelect:c,onReplay:x}){const d=C[t.mode]??"#7d8590",f=t.efficiency_score>=90?"#3fb950":t.efficiency_score>=70?"#d29922":"#f85149";return e.jsxs("div",{style:p.card(!!o,r),onClick:()=>i&&(c==null?void 0:c(t.id)),children:[e.jsxs("div",{style:p.row,children:[i&&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(q,{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(a,{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:p.dim,children:[A(t.started_at)," → ",A(t.last_event_at)]})}),e.jsx("span",{style:p.dim,children:"·"}),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:"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:{...p.dim,fontWeight:600},children:W(t.duration_ms)})}),t.project_name&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:p.sep,children:"│"}),e.jsxs("span",{style:{color:"#79c0ff",fontSize:11,display:"inline-flex",alignItems:"center",gap:3},children:[e.jsx(Q,{size:10})," ",t.project_name]})]}),e.jsx("div",{style:{flex:1}}),x&&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:"Session Replay"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:"Turn-by-turn replay · context decay curve · agent tree"})]}),children:e.jsxs("button",{onClick:h=>{h.stopPropagation(),x()},style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:4,cursor:"pointer",fontSize:10,fontWeight:600,background:"#1c2128",border:"1px solid #58a6ff50",color:"#58a6ff"},children:[e.jsx(X,{size:9}),"Replay"]})}),t.source&&e.jsx("span",{style:p.badge(ne(t.source)),children:se(t.source)}),e.jsx(a,{position:"top",align:"right",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:d,fontWeight:700,fontSize:12,marginBottom:4},children:$[t.mode]??t.mode}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:le[t.mode]??t.mode})]}),children:e.jsx("span",{style:p.badge(d),children:$[t.mode]??t.mode})})]}),e.jsxs("div",{style:p.row,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:"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:p.badge("#3fb950"),children:["$",t.total_cost_usd.toFixed(4)]})}),e.jsx("span",{style:p.dim,children:"·"}),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.",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:[S(t.total_tokens)," tok"]})}),e.jsx("span",{style:p.sep,children:"│"}),e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:f,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:p.badge(f),children:["efficiency ",t.efficiency_score,"/100"]})}),t.loops_detected>0&&e.jsx(a,{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:p.badge("#f85149"),children:[e.jsx(J,{size:9})," ",t.loops_detected," loops"]})}),e.jsx("span",{style:p.sep,children:"│"}),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:"Tool calls"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:t.is_sub_agent?"Sub-agent sessions have no separate tool events — they are background tasks managed by the parent session":t.done_count===0&&t.total_cost_usd>0?"Session has cost/token data from JSONL but no tool events were recorded (hooks may not be installed)":"Number of tools that completed execution (Done type) in this session"})]}),children:e.jsx("span",{style:p.dim,children:t.is_sub_agent||t.done_count===0&&t.total_cost_usd>0?"—":`${t.done_count} tools`})})]}),t.top_tools.length>0&&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:"Most used tools"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:t.top_tools.map((h,n)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:k[h]??k.default,flexShrink:0}}),e.jsx("span",{style:{color:"#c9d1d9",fontSize:10},children:h}),n===0&&e.jsx("span",{style:{color:"#484f58",fontSize:9},children:"— most frequent"})]},n))})]}),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[t.top_tools.slice(0,12).map((h,n)=>e.jsx("span",{style:{width:12,height:4,borderRadius:2,flexShrink:0,background:k[h]??k.default,opacity:Math.max(.2,1-n*.07)}},n)),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:p.row,children:e.jsx(a,{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:p.badge("#8b949e"),children:[e.jsx(U,{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(a,{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(H,{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 ce=m.memo(ae);function fe(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function O({node:t,depth:o=0}){const[i,r]=m.useState(o===0),c=t.children.length>0;return e.jsxs("div",{style:{marginLeft:o*16},children:[e.jsxs("div",{onClick:()=>c&&r(x=>!x),style:{display:"flex",alignItems:"center",gap:6,padding:"3px 6px",borderRadius:4,background:o===0?"#1f2937":"transparent",cursor:c?"pointer":"default"},children:[c&&e.jsx(ee,{size:10,color:"#7d8590",style:{transform:i?"rotate(90deg)":void 0,transition:"transform 0.15s"}}),!c&&e.jsx("div",{style:{width:10}}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:10,color:"#79c0ff"},children:t.id.slice(0,8)}),t.dominant_model&&e.jsx("span",{style:{fontSize:9,color:"#7d8590"},children:t.dominant_model.replace("claude-","")}),t.total_cost_usd!=null&&e.jsxs("span",{style:{fontSize:10,color:"#3fb950",marginLeft:"auto"},children:["$",t.total_cost_usd.toFixed(4)]})]}),i&&t.children.map(x=>e.jsx(O,{node:x,depth:o+1},x.id))]})}function he({sessionId:t,onClose:o}){const[i,r]=m.useState(null),[c,x]=m.useState(null),[d,f]=m.useState(!0);m.useEffect(()=>{Promise.all([fetch(`/session/${t}/replay`).then(n=>n.json()),fetch(`/session/${t}/agent-tree`).then(n=>n.json())]).then(([n,j])=>{r(n),x(j),f(!1)}).catch(()=>f(!1))},[t]);const h=((i==null?void 0:i.turns)??[]).map(n=>({turn:n.turn_index,ctx:n.context_used,pct:i?Math.round(n.context_used/i.context_window*100):0}));return i&&Math.round(i.context_window*.9/1e3),e.jsx("div",{onClick:o,style:{position:"fixed",inset:0,zIndex:1e3,background:"#00000099",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{width:"92vw",maxWidth:1e3,maxHeight:"88vh",background:"#0d1117",border:"1px solid #30363d",borderRadius:10,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid #21262d"},children:[e.jsx("span",{style:{color:"#e6edf3",fontWeight:700,fontSize:13},children:"Session Replay"}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:"#7d8590"},children:t.slice(0,8)}),i&&e.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:[i.turns.length," turn",i.turns.length!==1?"s":""]}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:o,style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(w,{size:14})})]}),d&&e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#7d8590",fontSize:12},children:"Loading…"}),!d&&i&&e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden",minHeight:0},children:[e.jsxs("div",{style:{flex:1,overflowY:"auto",borderRight:"1px solid #21262d",padding:"8px 0"},children:[i.turns.length===0&&e.jsx("div",{style:{padding:24,color:"#484f58",fontSize:12,textAlign:"center"},children:"No turns recorded yet — semantic extraction runs 3s after the last assistant response."}),i.turns.map(n=>{const j=Math.round(n.context_used/i.context_window*100),_=j>=90?"#f85149":j>=70?"#d29922":"#3fb950";return e.jsxs("div",{style:{padding:"8px 14px",borderBottom:"1px solid #161b22"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsxs("span",{style:{fontSize:9,color:"#484f58",fontFamily:"monospace",minWidth:20},children:["#",n.turn_index]}),n.error_count>0&&e.jsx(Z,{size:10,color:"#f85149"}),e.jsx("div",{style:{flex:1,display:"flex",flexWrap:"wrap",gap:3},children:n.tool_calls.map((v,z)=>e.jsx("span",{style:{fontSize:9,color:"#58a6ff",background:"#58a6ff18",border:"1px solid #58a6ff30",borderRadius:3,padding:"1px 5px"},children:v},z))}),e.jsxs("span",{style:{fontSize:9,color:_,fontFamily:"monospace",flexShrink:0},children:[fe(n.context_used)," · ",j,"%"]})]}),n.text_preview&&e.jsx("div",{style:{fontSize:10,color:"#8b949e",lineHeight:1.5,fontFamily:"monospace",whiteSpace:"pre-wrap",overflow:"hidden",maxHeight:48},children:n.text_preview})]},n.turn_index)})]}),e.jsxs("div",{style:{width:320,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px 4px",borderBottom:"1px solid #21262d"},children:[e.jsx("div",{style:{fontSize:10,color:"#7d8590",marginBottom:6,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Context Decay"}),h.length>=2?e.jsx(G,{width:"100%",height:140,children:e.jsxs(re,{data:h,margin:{top:4,right:8,bottom:0,left:-20},children:[e.jsx(N,{dataKey:"turn",tick:{fontSize:9,fill:"#484f58"},tickLine:!1,axisLine:!1}),e.jsx(Y,{tick:{fontSize:9,fill:"#484f58"},tickLine:!1,axisLine:!1,tickFormatter:n=>`${n}%`,domain:[0,100]}),e.jsx(V,{contentStyle:{background:"#161b22",border:"1px solid #30363d",borderRadius:6,fontSize:10},labelFormatter:n=>`Turn ${n}`,formatter:n=>[`${n}%`,"Context"]}),e.jsx(K,{y:90,stroke:"#f8514940",strokeDasharray:"3 3"}),e.jsx(de,{type:"monotone",dataKey:"pct",stroke:"#58a6ff",dot:!1,strokeWidth:1.5})]})}):e.jsx("div",{style:{height:140,display:"flex",alignItems:"center",justifyContent:"center",color:"#484f58",fontSize:11},children:"Need ≥2 turns for chart"})]}),c&&e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"10px 14px"},children:[e.jsx("div",{style:{fontSize:10,color:"#7d8590",marginBottom:8,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Agent Tree"}),e.jsx(O,{node:c})]})]})]})]})})}function M(t){const o=new Date(t+"T12:00:00"),i=new Date().toISOString().slice(0,10),r=new Date(Date.now()-864e5).toISOString().slice(0,10);return t===i?"Today":t===r?"Yesterday":o.toLocaleDateString("en",{weekday:"long",day:"numeric",month:"long"})}function y(t,o,i=!1){return t===o?{color:"#8b949e"}:{color:(i?t<o:t>o)?"#3fb950":"#f85149",fontWeight:700}}function pe({a:t,b:o,onClose:i}){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:y(t.total_cost_usd,o.total_cost_usd,!0),styleB:y(o.total_cost_usd,t.total_cost_usd,!0)},{label:"Tokens",tooltip:"Input + Output + Cache read. Green = fewer tokens consumed (better).",va:S(t.total_tokens),vb:S(o.total_tokens),styleA:y(t.total_tokens,o.total_tokens,!0),styleB:y(o.total_tokens,t.total_tokens,!0)},{label:"Duration",tooltip:"Time between first and last event. Green = shorter session (better).",va:W(t.duration_ms),vb:W(o.duration_ms),styleA:y(t.duration_ms,o.duration_ms,!0),styleB:y(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:y(t.efficiency_score,o.efficiency_score,!1),styleB:y(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:y(t.done_count,o.done_count,!0),styleB:y(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:y(t.loops_detected,o.loops_detected,!0),styleB:y(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:C[t.mode]??"#7d8590",fontWeight:600},styleB:{color:C[o.mode]??"#7d8590",fontWeight:600}}],c=t.project_name||t.id.slice(0,8),x=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(a,{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(F,{size:14,color:"#58a6ff",style:{cursor:"default"}})}),e.jsx("span",{style:{color:"#e6edf3",fontWeight:700,fontSize:13},children:"Session comparison"}),e.jsx(a,{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(a,{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:i,style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(w,{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.jsxs("span",{style:{color:"#58a6ff",fontSize:10,fontWeight:700},children:[c," · ",new Date(t.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})]}),e.jsxs("span",{style:{color:"#bc8cff",fontSize:10,fontWeight:700},children:[x," · ",new Date(o.started_at).toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit"})]})]}),r.map((d,f)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr 1fr",padding:"5px 16px",background:f%2===0?"transparent":"#ffffff08"},children:[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: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})]},f)),(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(a,{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,f)=>e.jsx("span",{style:{color:"#8b949e",fontSize:10,background:"#ffffff08",borderRadius:3,padding:"1px 5px"},children:d},f))}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3},children:(o.top_tools.length>0?o.top_tools:["—"]).map((d,f)=>e.jsx("span",{style:{color:"#8b949e",fontSize:10,background:"#ffffff08",borderRadius:3,padding:"1px 5px"},children:d},f))})]})]}),(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:f})=>e.jsxs("div",{style:{background:f+"08",border:`1px solid ${f}20`,borderRadius:6,padding:"7px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:4},children:[e.jsx(H,{size:10,color:f}),e.jsx("span",{style:{color:f,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 g={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 xe({days:t,activeSessionId:o}){return e.jsx("div",{style:{paddingLeft:8},children:t.map(i=>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:M(i.date)}),e.jsxs("span",{style:{color:"#484f58",fontSize:11},children:[i.sessions.length," sess. · $",i.total_cost.toFixed(3)," · ",S(i.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:i.sessions.map(r=>{const c=r.efficiency_score>=90?"#3fb950":r.efficiency_score>=70?"#d29922":"#f85149",x=r.id===o;return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:c,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:c,border:"2px solid #0d1117",boxShadow:`0 0 6px ${c}66`,position:"relative",zIndex:1,animation:x?"livePulse 1.5s ease-in-out infinite":void 0,cursor:"default"}})}),e.jsx("div",{style:{flex:1,background:"#161b22",border:`1px solid ${x?"#1f6feb":"#21262d"}`,borderRadius:7,padding:"7px 12px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[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:"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(a,{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(a,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:c,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:c,fontSize:10,cursor:"default"},children:[r.efficiency_score,"/100"]})}),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.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Input + Output + Cache read"})]}),children:e.jsxs("span",{style:{color:"#484f58",fontSize:10,cursor:"default"},children:["· ",S(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)})})]})]},i.date))})}const B=[{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 be({days:t,activeSessionId:o}){const[i,r]=m.useState([]),[c,x]=m.useState("list"),[d,f]=m.useState(""),[h,n]=m.useState(0),[j,_]=m.useState(null),v=m.useMemo(()=>{const s=d.trim().toLowerCase(),l=B[h];return t.map(u=>({...u,sessions:u.sessions.filter(b=>{var R,I;return l.min!==null&&b.total_cost_usd<l.min||l.max!==null&&b.total_cost_usd>=l.max?!1:s?((R=b.project_name)==null?void 0:R.toLowerCase().includes(s))||b.top_tools.some(E=>E.toLowerCase().includes(s))||((I=b.ai_summary)==null?void 0:I.toLowerCase().includes(s))||b.id.includes(s):!0})})).filter(u=>u.sessions.length>0)},[t,d,h]),z=t.flatMap(s=>s.sessions),T=z.find(s=>s.id===i[0]),L=z.find(s=>s.id===i[1]);function P(s){r(l=>l.includes(s)?l.filter(u=>u!==s):l.length>=2?[l[1],s]:[...l,s])}return t.length===0?e.jsxs("div",{style:{...g.empty,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[e.jsx(te,{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:g.wrap,children:[e.jsx("style",{children:"@keyframes livePulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(1.5)} }"}),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(D,{size:12,color:"#484f58"}),e.jsx("input",{type:"text",placeholder:"Search by project, tool or summary…",value:d,onChange:s=>f(s.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",color:"#c9d1d9",fontSize:12,fontFamily:"inherit"}}),d&&e.jsx("button",{onClick:()=>f(""),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex"},children:e.jsx(w,{size:12})}),e.jsx("div",{style:{width:1,height:16,background:"#21262d"}}),e.jsx("div",{style:{display:"flex",gap:3},children:B.map((s,l)=>{const u=l===0?"Show all sessions without filtering by cost":l===1?"Only sessions with cost under $0.01 — very short conversations":l===2?"Sessions with cost of $0.01 or more — real work":l===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(a,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#3fb950",fontWeight:700,fontSize:12,marginBottom:4},children:["Filter: ",s.label]}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:u})]}),children:e.jsx("button",{onClick:()=>n(l),style:{padding:"2px 7px",borderRadius:4,border:`1px solid ${h===l?"#3fb95060":"#21262d"}`,background:h===l?"#1a2d1a":"transparent",color:h===l?"#3fb950":"#6e7681",fontSize:10,fontWeight:600,cursor:"pointer"},children:s.label})},l)})}),(d||h>0)&&e.jsxs("span",{style:{color:"#484f58",fontSize:10},children:[v.reduce((s,l)=>s+l.sessions.length,0)," result",v.reduce((s,l)=>s+l.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",oe,"List","Card view grouped by day. Shows all details for each session."],["timeline",ie,"Timeline","Chronological view with a timeline. Shows the session flow for the day."]].map(([s,l,u,b])=>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:u}),e.jsx("div",{style:{color:"#7d8590",fontSize:10,lineHeight:1.5},children:b})]}),children:e.jsxs("button",{onClick:()=>x(s),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:4,border:"none",cursor:"pointer",fontSize:10,fontWeight:600,background:c===s?"#21262d":"transparent",color:c===s?"#e6edf3":"#6e7681",transition:"all 0.15s"},children:[e.jsx(l,{size:10}),u]})},s))}),e.jsx("div",{style:{width:1,height:16,background:"#21262d"}}),e.jsx(a,{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(F,{size:12,color:"#58a6ff",style:{cursor:"default"}})}),e.jsx("span",{style:{color:"#6e7681",fontSize:11},children:i.length===0?"Select 2 sessions to compare":i.length===1?"Select 1 more":"Comparing 2 sessions"}),i.length>0&&e.jsx("button",{onClick:()=>r([]),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",display:"flex",marginLeft:"auto"},children:e.jsx(w,{size:12})})]}),T&&L&&e.jsx(pe,{a:T,b:L,onClose:()=>r([])}),v.length===0&&(d||h>0)&&e.jsxs("div",{style:{...g.empty},children:[e.jsx(D,{size:32,color:"#30363d",style:{marginBottom:8}}),e.jsxs("div",{style:{color:"#6e7681",fontSize:13},children:['No results for "',d||B[h].label,'"']})]}),c==="timeline"?e.jsx(xe,{days:v,activeSessionId:o}):v.map(s=>e.jsxs("div",{style:g.dayWrap,children:[e.jsxs("div",{style:g.dayHead,children:[e.jsx("span",{style:g.dayLabel,children:M(s.date)}),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:"Day sessions"}),e.jsx("div",{style:{color:"#7d8590",fontSize:10},children:"Number of Claude Code sessions recorded this day"})]}),children:e.jsxs("span",{style:{...g.dayStat,cursor:"default"},children:[s.sessions.length," session",s.sessions.length>1?"s":""]})}),e.jsx("span",{style:g.dayStat,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:"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:{...g.dayStat,cursor:"default"},children:W(s.total_duration_ms)})}),e.jsx("span",{style:g.dayStat,children:"·"}),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:"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:{...g.badge("#3fb950"),cursor:"default"},children:["$",s.total_cost.toFixed(3)]})}),e.jsx("span",{style:g.dayStat,children:"·"}),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:"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:{...g.dayStat,cursor:"default"},children:[S(s.total_tokens)," tokens"]})})]}),e.jsx("div",{style:g.sessions,children:s.sessions.map(l=>e.jsx(ce,{session:l,isActive:l.id===o,selectable:!0,selected:i.includes(l.id),onSelect:P,onReplay:()=>_(l.id)},l.id))})]},s.date)),j&&e.jsx(he,{sessionId:j,onClose:()=>_(null)})]})}export{be as HistoryView};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{g as at,t as G,D as it,H as ot,I as st,L as M,m as W,o as lt,A as ut,p as N,s as ct,q as V,v as pt,x as ft,y as Q,B as ht,G as vt,z as X,M as yt,X as dt,Y as mt,O as gt}from"./index-CMhe3KaT.js";import{x as d,a as At}from"./vendor-lucide-ClCW-axQ.js";var bt=["type","layout","connectNulls","ref"],xt=["key"];function E(t){"@babel/helpers - typeof";return E=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},E(t)}function Y(t,r){if(t==null)return{};var n=Pt(t,r),e,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(a=0;a<o.length;a++)e=o[a],!(r.indexOf(e)>=0)&&Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}function Pt(t,r){if(t==null)return{};var n={};for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)){if(r.indexOf(e)>=0)continue;n[e]=t[e]}return n}function B(){return B=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},B.apply(this,arguments)}function H(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,e)}return n}function g(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?H(Object(n),!0).forEach(function(e){b(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _(t){return wt(t)||Dt(t)||St(t)||Ot()}function Ot(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function St(t,r){if(t){if(typeof t=="string")return U(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return U(t,r)}}function Dt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function wt(t){if(Array.isArray(t))return U(t)}function U(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function _t(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function J(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,tt(e.key),e)}}function Et(t,r,n){return r&&J(t.prototype,r),n&&J(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function jt(t,r,n){return r=R(r),kt(t,Z()?Reflect.construct(r,n||[],R(t).constructor):r.apply(t,n))}function kt(t,r){if(r&&(E(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Lt(t)}function Lt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Z(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Z=function(){return!!t})()}function R(t){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},R(t)}function Ct(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&q(t,r)}function q(t,r){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,a){return e.__proto__=a,e},q(t,r)}function b(t,r,n){return r=tt(r),r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function tt(t){var r=Tt(t,"string");return E(r)=="symbol"?r:r+""}function Tt(t,r){if(E(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var e=n.call(t,r);if(E(e)!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var z=(function(t){function r(){var n;_t(this,r);for(var e=arguments.length,a=new Array(e),o=0;o<e;o++)a[o]=arguments[o];return n=jt(this,r,[].concat(a)),b(n,"state",{isAnimationFinished:!0,totalLength:0}),b(n,"generateSimpleStrokeDasharray",function(i,s){return"".concat(s,"px ").concat(i-s,"px")}),b(n,"getStrokeDasharray",function(i,s,l){var c=l.reduce(function(x,O){return x+O});if(!c)return n.generateSimpleStrokeDasharray(s,i);for(var f=Math.floor(i/c),h=i%c,p=s-i,v=[],u=0,y=0;u<l.length;y+=l[u],++u)if(y+l[u]>h){v=[].concat(_(l.slice(0,u)),[h-y]);break}var A=v.length%2===0?[0,p]:[p];return[].concat(_(r.repeat(l,f)),_(v),A).map(function(x){return"".concat(x,"px")}).join(", ")}),b(n,"id",ht("recharts-line-")),b(n,"pathRef",function(i){n.mainCurve=i}),b(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),b(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Ct(r,t),Et(r,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();this.setState({totalLength:e})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();e!==this.state.totalLength&&this.setState({totalLength:e})}}},{key:"getTotalLength",value:function(){var e=this.mainCurve;try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(e,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.points,s=o.xAxis,l=o.yAxis,c=o.layout,f=o.children,h=ot(f,st);if(!h)return null;var p=function(y,A){return{x:y.x,y:y.y,value:y.value,errorVal:Q(y.payload,A)}},v={clipPath:e?"url(#clipPath-".concat(a,")"):null};return d.createElement(M,v,h.map(function(u){return d.cloneElement(u,{key:"bar-".concat(u.props.dataKey),data:i,xAxis:s,yAxis:l,layout:c,dataPointFormatter:p})}))}},{key:"renderDots",value:function(e,a,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var s=this.props,l=s.dot,c=s.points,f=s.dataKey,h=W(this.props,!1),p=W(l,!0),v=c.map(function(y,A){var x=g(g(g({key:"dot-".concat(A),r:3},h),p),{},{index:A,cx:y.x,cy:y.y,value:y.value,dataKey:f,payload:y.payload,points:c});return r.renderDotItem(l,x)}),u={clipPath:e?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return d.createElement(M,B({className:"recharts-line-dots",key:"dots"},u),v)}},{key:"renderCurveStatically",value:function(e,a,o,i){var s=this.props,l=s.type,c=s.layout,f=s.connectNulls;s.ref;var h=Y(s,bt),p=g(g(g({},W(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(o,")"):null,points:e},i),{},{type:l,layout:c,connectNulls:f});return d.createElement(lt,B({},p,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(e,a){var o=this,i=this.props,s=i.points,l=i.strokeDasharray,c=i.isAnimationActive,f=i.animationBegin,h=i.animationDuration,p=i.animationEasing,v=i.animationId,u=i.animateNewValues,y=i.width,A=i.height,x=this.state,O=x.prevPoints,j=x.totalLength;return d.createElement(ut,{begin:f,duration:h,isActive:c,easing:p,from:{t:0},to:{t:1},key:"line-".concat(v),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(D){var P=D.t;if(O){var k=O.length/s.length,S=s.map(function(m,K){var T=Math.floor(K*k);if(O[T]){var I=O[T],w=N(I.x,m.x),et=N(I.y,m.y);return g(g({},m),{},{x:w(P),y:et(P)})}if(u){var rt=N(y*2,m.x),nt=N(A/2,m.y);return g(g({},m),{},{x:rt(P),y:nt(P)})}return g(g({},m),{},{x:m.x,y:m.y})});return o.renderCurveStatically(S,e,a)}var F=N(0,j),L=F(P),C;if(l){var $="".concat(l).split(/[,\s]+/gim).map(function(m){return parseFloat(m)});C=o.getStrokeDasharray(L,j,$)}else C=o.generateSimpleStrokeDasharray(j,L);return o.renderCurveStatically(s,e,a,{strokeDasharray:C})})}},{key:"renderCurve",value:function(e,a){var o=this.props,i=o.points,s=o.isAnimationActive,l=this.state,c=l.prevPoints,f=l.totalLength;return s&&i&&i.length&&(!c&&f>0||!ct(c,i))?this.renderCurveWithAnimation(e,a):this.renderCurveStatically(i,e,a)}},{key:"render",value:function(){var e,a=this.props,o=a.hide,i=a.dot,s=a.points,l=a.className,c=a.xAxis,f=a.yAxis,h=a.top,p=a.left,v=a.width,u=a.height,y=a.isAnimationActive,A=a.id;if(o||!s||!s.length)return null;var x=this.state.isAnimationFinished,O=s.length===1,j=G("recharts-line",l),D=c&&c.allowDataOverflow,P=f&&f.allowDataOverflow,k=D||P,S=V(A)?this.id:A,F=(e=W(i,!1))!==null&&e!==void 0?e:{r:3,strokeWidth:2},L=F.r,C=L===void 0?3:L,$=F.strokeWidth,m=$===void 0?2:$,K=pt(i)?i:{},T=K.clipDot,I=T===void 0?!0:T,w=C*2+m;return d.createElement(M,{className:j},D||P?d.createElement("defs",null,d.createElement("clipPath",{id:"clipPath-".concat(S)},d.createElement("rect",{x:D?p:p-v/2,y:P?h:h-u/2,width:D?v:v*2,height:P?u:u*2})),!I&&d.createElement("clipPath",{id:"clipPath-dots-".concat(S)},d.createElement("rect",{x:p-w/2,y:h-w/2,width:v+w,height:u+w}))):null,!O&&this.renderCurve(k,S),this.renderErrorBar(k,S),(O||i)&&this.renderDots(k,I,S),(!y||x)&&ft.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(e,a){return e.animationId!==a.prevAnimationId?{prevAnimationId:e.animationId,curPoints:e.points,prevPoints:a.curPoints}:e.points!==a.curPoints?{curPoints:e.points}:null}},{key:"repeat",value:function(e,a){for(var o=e.length%2!==0?[].concat(_(e),[0]):e,i=[],s=0;s<a;++s)i=[].concat(_(i),_(o));return i}},{key:"renderDotItem",value:function(e,a){var o;if(d.isValidElement(e))o=d.cloneElement(e,a);else if(at(e))o=e(a);else{var i=a.key,s=Y(a,xt),l=G("recharts-line-dot",typeof e!="boolean"?e.className:"");o=d.createElement(it,B({key:i},s,{className:l}))}return o}}])})(At.PureComponent);b(z,"displayName","Line");b(z,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!vt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});b(z,"getComposedData",function(t){var r=t.props,n=t.xAxis,e=t.yAxis,a=t.xAxisTicks,o=t.yAxisTicks,i=t.dataKey,s=t.bandSize,l=t.displayedData,c=t.offset,f=r.layout,h=l.map(function(p,v){var u=Q(p,i);return f==="horizontal"?{x:X({axis:n,ticks:a,bandSize:s,entry:p,index:v}),y:V(u)?null:e.scale(u),value:u,payload:p}:{x:V(u)?null:n.scale(u),y:X({axis:e,ticks:o,bandSize:s,entry:p,index:v}),value:u,payload:p}});return g({points:h,layout:f},c)});var Bt=yt({chartName:"LineChart",GraphicalChild:z,axisComponents:[{axisType:"xAxis",AxisComp:dt},{axisType:"yAxis",AxisComp:mt}],formatAxisMap:gt});export{Bt as L,z as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{j as e,T as a}from"./index-CMhe3KaT.js";import{a as m,c as b,d as y,_ as v,$ as S,a0 as k,f as z,F as w}from"./vendor-lucide-ClCW-axQ.js";import{e as j,d as p,g as u}from"./shared-BbBtsdh1.js";import"./vendor-react-gHSHIE2L.js";function T(t){if(!t)return null;const{opusTokens:o,sonnetTokens:r,haikuTokens:i}=t;return o===0&&r===0&&i===0?null:o>=r&&o>=i?{label:"Opus",color:"#d29922"}:r>=i?{label:"Sonnet",color:"#58a6ff"}:{label:"Haiku",color:"#3fb950"}}function W(t){if(!t)return"never";const o=Date.now()-t;return o<6e4?"just now":o<36e5?`${Math.round(o/6e4)}m ago`:o<864e5?`${Math.round(o/36e5)}h ago`:o<7*864e5?`${Math.round(o/864e5)}d ago`:new Date(t).toLocaleDateString("en",{day:"numeric",month:"short"})}function C({cliHours:t}){const o=Object.entries(t).filter(([,s])=>s>0);if(o.length===0)return null;const r=o.reduce((s,[,c])=>s+c,0),i={"claude-code":"#58a6ff",opencode:"#3fb950"},f={"claude-code":"Claude Code",opencode:"OpenCode"};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 tool"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:o.map(([s,c])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:i[s]??"#7d8590",flexShrink:0}}),e.jsx("span",{style:{color:i[s]??"#7d8590",fontSize:10,fontWeight:700,width:66},children:f[s]??s}),e.jsx("span",{style:{color:"#c9d1d9",fontSize:10},children:u(c)}),e.jsxs("span",{style:{color:"#484f58",fontSize:9},children:[Math.round(c/r*100),"%"]})]},s))})]}),children:e.jsx("span",{style:{color:"#7d8590",fontSize:10,marginBottom:1},children:"tool usage"})}),e.jsx("div",{style:{display:"flex",height:5,borderRadius:3,overflow:"hidden",gap:1},children:o.map(([s,c])=>{const h=c/r*100;return e.jsx("div",{style:{height:"100%",width:`${Math.round(h)}%`,background:i[s]??"#7d8590",minWidth:c>0?2:0}},s)})}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:o.map(([s,c])=>e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:i[s]??"#7d8590",flexShrink:0}}),e.jsx("span",{style:{color:i[s]??"#7d8590",fontSize:9,fontWeight:700},children:f[s]??s}),e.jsx("span",{style:{color:"#7d8590",fontSize:9},children:u(c)})]},s))})]})}const H={tip:"#58a6ff",warning:"#d29922",positive:"#3fb950"},I={tip:v,warning:y,positive:z};function L({insights:t}){const[o,r]=m.useState(!1);if(t.length===0)return null;const i=t.filter(s=>s.level==="warning").length,f=i>0?"#d29922":"#58a6ff";return e.jsxs("div",{style:{borderTop:"1px solid #21262d",paddingTop:8},children:[e.jsxs("button",{onClick:()=>r(s=>!s),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:f,fontSize:11,fontWeight:700,display:"flex",alignItems:"center",gap:5},children:[i>0?e.jsx(y,{size:12}):e.jsx(v,{size:12}),t.length," insight",t.length>1?"s":"",i>0&&e.jsxs("span",{style:{color:"#d29922",fontSize:10},children:["· ",i," warning",i>1?"s":""]})]}),o?e.jsx(S,{size:14,color:"#484f58"}):e.jsx(k,{size:14,color:"#484f58"})]}),o&&e.jsx("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:t.map((s,c)=>{const h=H[s.level];return e.jsxs("div",{style:{background:h+"0d",border:`1px solid ${h}30`,borderRadius:6,padding:"7px 10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:3},children:[(()=>{const g=I[s.level];return e.jsx(g,{size:11,color:h})})(),e.jsx("span",{style:{color:h,fontSize:11,fontWeight:700},children:s.title}),s.metric&&e.jsx("span",{style:{color:"#7d8590",fontSize:9,marginLeft:"auto"},children:s.metric})]}),e.jsx("p",{style:{color:"#8b949e",fontSize:10,margin:0,lineHeight:1.5},children:s.description})]},c)})})]})}const n={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",overflow:"hidden",minWidth:0}),header:{display:"flex",alignItems:"center",gap:8},name:{color:"#e6edf3",fontWeight:700,fontSize:15,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},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,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},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(2, 1fr)",gap:10,marginTop:2},stat:{display:"flex",flexDirection:"column",gap:1},statVal:{color:"#e6edf3",fontWeight:700,fontSize:12},statLbl:{color:"#7d8590",fontSize:10}};function _({project:t,isActive:o}){const r=!!t.auto_handoff,i=T(t.model_usage);return e.jsxs("div",{style:n.card(!!o),children:[e.jsxs("div",{children:[e.jsxs("div",{style:n.header,children:[e.jsxs("span",{style:{...n.name,display:"flex",alignItems:"center",gap:6},children:[e.jsx(b,{size:14,color:"#6e7681",style:{flexShrink:0}}),t.name]}),o&&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:n.activeBadge,children:"● active"})}),r&&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:n.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:n.path,children:t.path.split("/").slice(-3).join("/")})})]}),t.has_handoff?e.jsx("div",{style:n.progressWrap,children:t.progress.total===0?e.jsx("span",{style:{...n.progressLabel,fontStyle:"italic"},children:r?"→ 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:n.progressLabel,children:[t.progress.total," pending task",t.progress.total>1?"s":""]}),t.progress.nextTask&&e.jsxs("div",{style:n.nextTask,children:["→ next: ",t.progress.nextTask]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:n.progressRow,children:[e.jsxs("span",{style:n.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:n.progressPct(t.progress.pct),children:[t.progress.pct,"%"]})})]}),e.jsx("div",{style:n.barTrack,children:e.jsx("div",{style:n.barFill(t.progress.pct)})}),t.progress.nextTask&&e.jsxs("div",{style:n.nextTask,children:["→ next: ",t.progress.nextTask]})]})}):null,t.cli_hours&&Object.keys(t.cli_hours).length>0&&e.jsx(C,{cliHours:t.cli_hours}),e.jsxs("div",{style:n.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:n.stat,children:[e.jsx("span",{style:n.statVal,children:j(t.total_cost_usd)}),e.jsxs("span",{style:n.statLbl,children:["total cost",t.session_count>1&&e.jsxs("span",{style:{color:"#484f58",marginLeft:3},children:["· ",j(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",{}),i?e.jsxs(e.Fragment,{children:["Dominant model: ",e.jsx("span",{style:{color:i.color,fontWeight:700},children:i.label})]}):"No model data"]})]}),children:e.jsxs("div",{style:n.stat,children:[e.jsx("span",{style:n.statVal,children:p(t.total_tokens)}),e.jsxs("span",{style:n.statLbl,children:["tokens",i&&e.jsxs("span",{style:{color:i.color,marginLeft:3},children:["· ",i.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 (recorded from tool activity)."})]}),children:e.jsxs("div",{style:n.stat,children:[e.jsx("span",{style:n.statVal,children:t.session_count}),e.jsx("span",{style:n.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:n.stat,children:[e.jsx("span",{style:n.statVal,children:W(t.last_active)}),e.jsx("span",{style:n.statLbl,children:"last seen"})]})})]}),t.insights&&t.insights.length>0&&e.jsx(L,{insights:t.insights})]})}const B=m.memo(_),F=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function O({data:t}){if(t.length===0)return null;const o=Math.max(...t.map(r=>r.tokens),1);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((r,i)=>{const f=r.tokens/o,s=f<.05?"#1c2128":f<.3?"#0e4429":f<.6?"#006d32":f<.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:r.date}),e.jsxs("div",{style:{color:"#7d8590",fontSize:10},children:[p(r.tokens)," tokens that day"]})]}),children:e.jsx("div",{style:{width:12,height:12,borderRadius:2,background:s,border:"1px solid #21262d"}})},i)})}),e.jsx("div",{style:{display:"flex",gap:3},children:t.slice(-7).map((r,i)=>e.jsx("span",{style:{width:12,fontSize:8,color:"#484f58",textAlign:"center"},children:F[new Date(r.date+"T12:00:00").getDay()]},i))})]})}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 l={wrap:{padding:"16px 24px",overflowY:"auto",overflowX:"hidden",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, minmax(0, 1fr))",gap:12},sep:{width:1,height:32,background:"#21262d",flexShrink:0}};function P({projects:t,activeProject:o,weeklyData:r=[],loading:i=!1}){const f=t.reduce((d,x)=>d+x.total_cost_usd,0),s=t.reduce((d,x)=>d+x.total_tokens,0),c=t.reduce((d,x)=>d+x.session_count,0),h=t.filter(d=>d.has_handoff&&!d.auto_handoff),g=h.length>0?Math.round(h.reduce((d,x)=>d+x.progress.pct,0)/h.length):0;return e.jsxs("div",{style:l.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:l.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:l.sumItem,children:[e.jsx("span",{style:l.sumVal,children:t.length}),e.jsx("span",{style:l.sumLbl,children:"projects"})]})}),e.jsx("div",{style:l.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:l.sumItem,children:[e.jsxs("span",{style:l.sumVal,children:["$",f.toFixed(2)]}),e.jsx("span",{style:l.sumLbl,children:"total cost"})]})}),e.jsx("div",{style:l.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:l.sumItem,children:[e.jsx("span",{style:l.sumVal,children:p(s)}),e.jsx("span",{style:l.sumLbl,children:"total tokens"})]})}),e.jsx("div",{style:l.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:l.sumItem,children:[e.jsx("span",{style:l.sumVal,children:c}),e.jsx("span",{style:l.sumLbl,children:"historical sessions"})]})}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:l.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 ",h.length," project",h.length!==1?"s":""," with HANDOFF.md"]})]}),children:e.jsxs("div",{style:l.sumItem,children:[e.jsx("span",{style:{...l.sumVal,color:g>=70?"#3fb950":"#d29922"},children:g>0?`${g}%`:"—"}),e.jsx("span",{style:l.sumLbl,children:"average progress"})]})})]}),r.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:l.sep}),e.jsx(O,{data:r})]})]}),i&&e.jsx("div",{style:l.grid,children:[0,1,2].map(d=>e.jsx(D,{},d))}),!i&&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."]})]})]}),!i&&t.length>0&&e.jsx("div",{style:l.grid,children:t.map(d=>e.jsx(B,{project:d,isActive:d.path===o},d.path))})]})}export{P as ProjectsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,T as c}from"./index-CMhe3KaT.js";import{L as E,n as O,a as x,ab as $,B as k,f as z,G as I,Z as C,ac as M,S as W,s as B,ad as N,a0 as A,Q as H}from"./vendor-lucide-ClCW-axQ.js";import"./vendor-react-gHSHIE2L.js";function P(o,l){return l>0?Math.round(o/l*100):0}function T(o){if(!o)return"";const l=o.match(/(?:node|python3?|bash|sh|deno|bun)\s+[~\w/.]+\/([\w.-]+)/);return l?`…/${l[1]}`:o.slice(0,50)}function p({children:o,style:l}){return e.jsx("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",...l},children:o})}function g({icon:o,title:l,subtitle:i,color:t="#58a6ff",open:n,onToggle:s,badge:r}){return e.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:8,width:"100%",background:"none",border:"none",cursor:"pointer",padding:0,marginBottom:n?12:0},children:[e.jsx(o,{size:13,color:t}),e.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700,flex:1,textAlign:"left"},children:l}),i&&e.jsx("span",{style:{fontSize:10,color:"#484f58"},children:i}),r,n?e.jsx(A,{size:12,color:"#484f58"}):e.jsx(H,{size:12,color:"#484f58"})]})}function f({label:o,value:l,last:i=!1,color:t="#8b949e",tip:n}){const s=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:i?"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:t,fontWeight:500},children:o}),l!==void 0&&e.jsx("span",{style:{fontSize:10,color:"#484f58",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:l})]});return n?e.jsx(c,{position:"top",align:"left",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:n}),children:s}):s}function u({text:o,color:l}){return e.jsx("span",{style:{fontSize:10,fontWeight:600,color:l,background:l+"18",border:`1px solid ${l}35`,borderRadius:4,padding:"1px 6px"},children:o})}const D={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 F({hooks:o}){const[l,i]=x.useState(!0),t=Object.keys(o),n=t.length;return e.jsxs(p,{children:[e.jsx(g,{icon:C,title:"Active hooks",color:"#d29922",subtitle:n>0?void 0:"none configured",badge:n>0?e.jsx(u,{text:`${n} hooks`,color:"#d29922"}):void 0,open:l,onToggle:()=>i(s=>!s)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No hooks in ~/.claude/settings.json — claudestat is not active"}):t.map((s,r)=>{var m;const h=o[s],a=D[s];return e.jsx(c,{position:"bottom",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:(a==null?void 0:a.label)??s}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:(a==null?void 0:a.tip)??""}),h.map((b,d)=>e.jsx("div",{style:{color:"#3d444d",fontFamily:"monospace",fontSize:9,marginTop:4},children:T(b.command)},d))]}),children:e.jsx(f,{label:(a==null?void 0:a.label)??s,value:e.jsx("span",{style:{fontFamily:"monospace",color:"#3d444d"},children:T(((m=h[0])==null?void 0:m.command)??"")}),last:r===t.length-1,color:"#d29922"})},s)})})]})}function _({agents:o}){const[l,i]=x.useState(!0);return e.jsxs(p,{children:[e.jsx(g,{icon:k,title:"Available agents",color:"#bc8cff",subtitle:"~/.claude/agents/",badge:o.length>0?e.jsx(u,{text:`${o.length}`,color:"#bc8cff"}):void 0,open:l,onToggle:()=>i(t=>!t)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No agents in ~/.claude/agents/"}):o.map((t,n)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:t.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:t.description||"No description in the .md file frontmatter"})]}),children:e.jsx(f,{label:t.name,last:n===o.length-1,color:"#bc8cff",value:t.description?e.jsxs("span",{style:{color:"#3d444d",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block"},children:[t.description.slice(0,40),t.description.length>40?"…":""]}):void 0})},t.name))})]})}const v=500;function K({skills:o}){const[l,i]=x.useState(!0),t=o.filter(n=>n.lines>=v*.9).length;return e.jsxs(p,{children:[e.jsx(g,{icon:C,title:"Available skills",color:"#3fb950",subtitle:"~/.claude/commands/",badge:o.length>0?e.jsx(u,{text:`${o.length}${t>0?` · ${t} ⚠`:""}`,color:t>0?"#d29922":"#3fb950"}):void 0,open:l,onToggle:()=>i(n=>!n)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No skills in ~/.claude/commands/"}):o.map((n,s)=>{const r=n.lines/v,h=R(r),a=r>=.7;return e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#3fb950",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"}),e.jsxs("div",{style:{color:h,fontSize:9,marginTop:4},children:[n.lines," lines ",a?`— recommended limit: ${v}`:`/ ${v} recommended`]})]}),children:e.jsx(f,{label:`/${n.name}`,last:s===o.length-1,color:"#3fb950",value:e.jsxs("span",{style:{color:h,fontVariantNumeric:"tabular-nums"},children:[n.lines," ln ",a?"⚠":""]})})},n.name)})})]})}function U({memoryFiles:o}){const[l,i]=x.useState(!0),t=o.length>0,n={"MEMORY.md":"Auto-loaded index — every session reads this file automatically."};return e.jsxs(p,{children:[e.jsx(g,{icon:N,title:"Memory system",color:"#58a6ff",badge:t?e.jsx(u,{text:`${o.length} files`,color:"#58a6ff"}):void 0,open:l,onToggle:()=>i(s=>!s)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t?o.map((s,r)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:s==="MEMORY.md"?"#79c0ff":"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:s}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:n[s]||`Memory file: ~/.claude/projects/…/memory/${s}`})]}),children:e.jsx(f,{label:s,last:r===o.length-1,color:s==="MEMORY.md"?"#79c0ff":"#58a6ff"})},s)):e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"Engram not detected. Optional MCP plugin for persistent memory between sessions."})})]})}function G({workflows:o}){const[l,i]=x.useState(!0);return e.jsxs(p,{children:[e.jsx(g,{icon:M,title:"Workflows / pipelines",color:"#56d364",subtitle:"~/.claude/agents/workflows/",badge:o.length>0?e.jsx(u,{text:`${o.length}`,color:"#56d364"}):void 0,open:l,onToggle:()=>i(t=>!t)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No workflows in ~/.claude/agents/workflows/"}):o.map((t,n)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#56d364",fontWeight:700,fontSize:11,marginBottom:3},children:t.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:t.description||"No description in the .md file frontmatter"})]}),children:e.jsx(f,{label:t.name,last:n===o.length-1,color:"#56d364",value:t.description?e.jsxs("span",{style:{color:"#3d444d"},children:[t.description.slice(0,40),t.description.length>40?"…":""]}):void 0})},t.name))})]})}const Y={"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."},L={"CLAUDE.md global":{lines:200},"MEMORY.md":{lines:200}};function R(o){return o>=.9?"#f85149":o>=.7?"#d29922":"#3fb950"}function q(o,l,i){const t=L[i];if(!t)return null;const n=t.lines?o/t.lines:0,s=t.kb?l/t.kb:0;return R(Math.max(n,s))}function V({f:o}){if(!o.exists)return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:"#f85149"},children:[e.jsx(B,{size:9})," not found"]});const l=q(o.lines,o.sizeKb,o.key),i=l??"#3fb950",t=L[o.key],n=t!=null&&t.lines?`${o.lines} ln / ${t.lines}`:o.sizeKb>0?`${o.sizeKb} KB`:"< 1 KB";return e.jsxs("span",{style:{color:i},children:[n," ",l?"⚠":"✓"]})}function X({files:o}){const[l,i]=x.useState(!0),t=o.filter(n=>n.exists).length;return e.jsxs(p,{children:[e.jsx(g,{icon:O,title:"Context files",color:"#3fb950",badge:e.jsx(u,{text:`${t}/${o.length}`,color:"#3fb950"}),open:l,onToggle:()=>i(n=>!n)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.map((n,s)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#3fb950",fontWeight:700,fontSize:11,marginBottom:3},children:n.key}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:Y[n.key]??"System configuration file."})]}),children:e.jsx(f,{label:n.key,last:s===o.length-1,color:n.exists?"#e6edf3":"#484f58",value:e.jsx(V,{f:n})})},n.key))})]})}const Q={free:"Free",pro:"Pro",max5:"Max 5×",max20:"Max 20×"},S=[{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 Z({dist:o}){const[l,i]=x.useState(!0),t=o.total>0?S.reduce((n,s)=>o[s.key]>o[n.key]?s:n,S[0]):null;return e.jsxs(p,{children:[e.jsx(g,{icon:M,title:"Work modes",color:"#f0883e",subtitle:"last 7 days",badge:t&&o.total>0?e.jsx(u,{text:`most used: ${t.label}`,color:t.color}):void 0,open:l,onToggle:()=>i(n=>!n)}),l&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[S.map(n=>{const s=o[n.key],r=P(s,o.total);return e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:n.color,fontWeight:700,fontSize:11,marginBottom:3},children:n.label}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:[e.jsx("span",{style:{color:"#6e7681"},children:"When: "}),n.when,e.jsx("br",{}),n.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:n.color,fontWeight:600,width:130,flexShrink:0},children:n.label}),e.jsx("span",{style:{fontSize:10,color:"#484f58",flex:1},children:n.when}),e.jsx("span",{style:{fontSize:11,color:"#e6edf3",fontVariantNumeric:"tabular-nums",fontWeight:600},children:o.total>0?`${s} (${r}%)`:"—"})]}),e.jsx("div",{style:{height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:e.jsx("div",{style:{width:`${r}%`,height:"100%",background:n.color,borderRadius:2,transition:"width 0.5s"}})})]})},n.key)}),o.total===0&&e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No sessions recorded in the last 7 days"}),o.total>0&&e.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:2},children:[o.total," sessions analyzed · Mode inferred by number of Agent tool calls per session"]})]})]})}function J({config:o}){var m,b;const[l,i]=x.useState([]),[t,n]=x.useState(!0);function s(){fetch("/api/intent/active").then(d=>d.json()).then(d=>i(d.intents??[])).catch(()=>{})}x.useEffect(()=>{s();const d=setInterval(s,5e3);return()=>clearInterval(d)},[]);const r=!!(o!=null&&o.opencode),h=r?2:1,a=(()=>{const d=new Map;for(const j of l)d.has(j.tool)||d.set(j.tool,new Set),d.get(j.tool).add(j.file_path);const y=d.get("claude-code"),w=d.get("opencode");return!y||!w?!1:[...y].some(j=>w.has(j))})();return e.jsxs(p,{children:[e.jsx(g,{icon:$,title:"Active tools",color:"#58a6ff",badge:e.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"#3fb950",background:"#3fb95018",border:"1px solid #3fb95035",borderRadius:4,padding:"1px 6px"},children:[h," tool",h>1?"s":""]}),open:t,onToggle:()=>n(d=>!d)}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:10},children:[e.jsxs("div",{style:{flex:1,background:"#0d1117",borderRadius:6,padding:"10px 12px",border:"1px solid #21262d"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx(k,{size:12,color:"#d29922"}),e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#d29922"},children:"Claude Code"}),e.jsx(z,{size:10,color:"#3fb950",style:{marginLeft:"auto"}})]}),e.jsx("div",{style:{fontSize:9,color:"#484f58"},children:o!=null&&o.hooks?`${Object.keys(o.hooks).length} hooks`:"checking..."})]}),e.jsxs("div",{style:{flex:1,background:"#0d1117",borderRadius:6,padding:"10px 12px",border:"1px solid #21262d"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx(I,{size:12,color:"#bc8cff"}),e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#bc8cff"},children:"OpenCode"}),r?e.jsx(z,{size:10,color:"#3fb950",style:{marginLeft:"auto"}}):e.jsx("span",{style:{marginLeft:"auto",fontSize:9,color:"#484f58"},children:"inactive"})]}),e.jsx("div",{style:{fontSize:9,color:"#484f58"},children:r?`${((b=(m=o==null?void 0:o.opencode)==null?void 0:m.skills)==null?void 0:b.length)??0} skills`:"not detected"})]})]}),l.length>0&&e.jsxs("div",{style:{background:"#0d1117",borderRadius:6,padding:"8px 10px"},children:[e.jsx("div",{style:{fontSize:10,color:"#484f58",fontWeight:600,marginBottom:6},children:"Active coordination"}),l.map((d,y)=>e.jsxs("div",{style:{display:"flex",gap:6,fontSize:10,color:"#8b949e",padding:"2px 0"},children:[e.jsx("span",{style:{color:d.tool==="opencode"?"#bc8cff":"#d29922",fontWeight:600},children:d.tool}),e.jsx("span",{style:{color:"#484f58"},children:"editing"}),e.jsx("span",{style:{color:"#e6edf3"},children:d.file_path.split("/").pop()})]},y)),a&&e.jsx("div",{style:{fontSize:9,color:"#f85149",marginTop:4},children:"⚠ Collision detected — tools editing same file"})]})]})}function ee({oc:o}){var s,r,h;const[l,i]=x.useState(!0),t=((s=o.config)==null?void 0:s.small_model)??((r=o.config)==null?void 0:r.model)??"unknown",n=(h=o.config)==null?void 0:h.large_model;return e.jsxs(p,{children:[e.jsx(g,{icon:W,title:"OpenCode config",color:"#bc8cff",subtitle:"~/.config/opencode/opencode.json",open:l,onToggle:()=>i(a=>!a)}),l&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:"Model"}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"small_model from opencode.json"})]}),children:e.jsx(f,{label:"Model",value:e.jsx("span",{style:{color:"#bc8cff",fontSize:10},children:t})})}),n&&e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:"Large model"}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"large_model from opencode.json"})]}),children:e.jsx(f,{label:"Large model",value:e.jsx("span",{style:{color:"#bc8cff",fontSize:10},children:n})})}),e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:"AGENTS.md"}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"Global instructions loaded every session"})]}),children:e.jsx(f,{label:"AGENTS.md",value:o.agentsMd?`${o.agentsMd.lines} ln · ${o.agentsMd.sizeKb} KB`:"not found"})}),e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:"Projects"}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"Registered in ~/.config/opencode/projects.json"})]}),children:e.jsx(f,{label:"Projects",value:e.jsx("span",{style:{color:"#e6edf3"},children:o.projects})})}),e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:"Plugins"}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"MCP plugins in ~/.config/opencode/plugins/"})]}),children:e.jsx(f,{label:"Plugins",last:!0,value:o.plugins.length>0?o.plugins.join(", "):e.jsx("span",{style:{color:"#484f58"},children:"none"})})})]})]})}function oe({skills:o}){const[l,i]=x.useState(!1);return e.jsxs(p,{children:[e.jsx(g,{icon:C,title:"OpenCode skills",color:"#bc8cff",subtitle:"~/.config/opencode/skills/",badge:o.length>0?e.jsx(u,{text:`${o.length}`,color:"#bc8cff"}):void 0,open:l,onToggle:()=>i(t=>!t)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No skills"}):o.map((t,n)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:t.name}),e.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:t.description||"No description in SKILL.md frontmatter"}),e.jsxs("div",{style:{color:"#3d444d",fontSize:9,marginTop:4},children:[t.lines," lines"]})]}),children:e.jsx(f,{label:t.name,last:n===o.length-1,color:"#bc8cff",value:e.jsxs("span",{style:{color:"#3d444d"},children:[t.lines," ln"]})})},t.name))})]})}function te({agents:o}){const[l,i]=x.useState(!1);return e.jsxs(p,{children:[e.jsx(g,{icon:k,title:"OpenCode agents",color:"#bc8cff",subtitle:"~/.config/opencode/agents/",badge:o.length>0?e.jsx(u,{text:`${o.length}`,color:"#bc8cff"}):void 0,open:l,onToggle:()=>i(t=>!t)}),l&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.length===0?e.jsx("span",{style:{fontSize:11,color:"#484f58"},children:"No agents"}):o.map((t,n)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#bc8cff",fontWeight:700,fontSize:11,marginBottom:3},children:t.replace(".md","")}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Agent file: ~/.config/opencode/agents/",t]})]}),children:e.jsx(f,{label:t.replace(".md",""),last:n===o.length-1,color:"#bc8cff"},t)},t))})]})}function ne({cfg:o}){const[l,i]=x.useState(!0),t=o.plan??null,n=o.killSwitchEnabled??!0,[s,r,h]=o.warnThresholds??[70,85,95];return e.jsxs(p,{children:[e.jsx(g,{icon:W,title:"claudestat config",color:"#8b949e",subtitle:"~/.claudestat/config.json",open:l,onToggle:()=>i(a=>!a)}),l&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsx(f,{label:"Plan",value:t?e.jsx(u,{text:Q[t]??t,color:"#58a6ff"}):e.jsx("span",{style:{color:"#484f58"},children:"—"}),tip:"Claude Max plan that determines weekly hour limits per model."}),e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsxs("div",{style:{color:n?"#3fb950":"#f85149",fontWeight:700,fontSize:11,marginBottom:3},children:["Kill switch ",n?"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(f,{label:"Kill switch",value:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:n?"#3fb950":"#f85149"},children:[n?e.jsx(z,{size:10}):e.jsx(B,{size:10}),n?"ON":"OFF"]}),color:n?"#3fb950":"#f85149"})}),e.jsx(c,{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",{}),"yellow warning → orange → red (kill switch)"]})]}),children:e.jsx(f,{label:"Thresholds",last:!0,value:e.jsxs("span",{style:{display:"inline-flex",gap:6},children:[e.jsxs("span",{style:{color:"#d29922"},children:[s,"%"]}),e.jsxs("span",{style:{color:"#f0883e"},children:[r,"%"]}),e.jsxs("span",{style:{color:"#f85149"},children:[h,"%"]})]})})})]})]})}function re({config:o,error:l,onRetry:i}){var t,n;return o?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(E,{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:"Claude Code + OpenCode configuration overview"})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center"},children:[e.jsx(c,{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(o.hooks).length," hooks"]})}),e.jsx(c,{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:[o.agents.length," agents"]})}),e.jsx(c,{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:[o.workflows.length," workflows"]})}),e.jsx(c,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Skills (CC + OC)"}),children:e.jsxs("span",{style:{fontSize:10,color:"#3fb950",background:"#3fb95015",border:"1px solid #3fb95035",borderRadius:4,padding:"2px 7px",cursor:"help"},children:[o.skills.length+(((n=(t=o.opencode)==null?void 0:t.skills)==null?void 0:n.length)??0)," skills"]})}),e.jsx(c,{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:[o.memoryFiles.length," memories"]})}),o.opencode&&e.jsx(c,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"OpenCode config detected"}),children:e.jsxs("span",{style:{fontSize:10,color:"#bc8cff",background:"#bc8cff15",border:"1px solid #bc8cff35",borderRadius:4,padding:"2px 7px",cursor:"help"},children:["OC ",o.opencode.skills.length," skills"]})}),i&&e.jsx(c,{position:"bottom",align:"right",content:e.jsx("div",{style:{color:"#8b949e",fontSize:10},children:"Refresh system configuration"}),children:e.jsx("button",{onClick:i,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:s=>{s.currentTarget.style.color="#e6edf3",s.currentTarget.style.borderColor="#6e7681"},onMouseLeave:s=>{s.currentTarget.style.color="#6e7681",s.currentTarget.style.borderColor="#30363d"},children:"↺"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,maxWidth:1200,margin:"0 auto"},children:[e.jsx(J,{config:o}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#8b949e",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Claude Code"})}),e.jsx(K,{skills:o.skills}),e.jsx(_,{agents:o.agents}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(G,{workflows:o.workflows??[]})}),e.jsx(Z,{dist:o.modeDistribution}),e.jsx(F,{hooks:o.hooks}),e.jsx(X,{files:o.contextFiles}),e.jsx(ne,{cfg:o.claudestatConfig}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(U,{memoryFiles:o.memoryFiles})}),(()=>{const s=o.opencode;return s?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#8b949e",letterSpacing:"0.06em",textTransform:"uppercase"},children:"OpenCode"})}),e.jsx(ee,{oc:s}),e.jsx(oe,{skills:s.skills}),e.jsx(te,{agents:s.agents}),e.jsxs(p,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[e.jsx(O,{size:11,color:"#3d444d"}),e.jsx("span",{style:{fontSize:11,color:"#8b949e"},children:"Commands"}),e.jsxs("span",{style:{fontSize:10,color:"#484f58",marginLeft:"auto"},children:[s.commands.length," files"]})]}),s.commands.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:s.commands.map((r,h)=>e.jsx(c,{position:"top",align:"left",content:e.jsxs("div",{children:[e.jsx("div",{style:{color:"#8b949e",fontWeight:700,fontSize:11,marginBottom:3},children:r.replace(".md","")}),e.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Command file: ~/.config/opencode/commands/",r]})]}),children:e.jsx(f,{label:r.replace(".md",""),last:h===s.commands.length-1,color:"#8b949e"})},r))})]})]}):null})()]})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:12},children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#f85149",fontSize:13},children:"Error loading system configuration"}),i&&e.jsx("button",{onClick:i,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{re as SystemView};
|