(stats: SessionStats, daysToShow: number, dateFilter?: DateFilter)
| 350 | } |
| 351 | |
| 352 | function renderCostOverview(stats: SessionStats, daysToShow: number, dateFilter?: DateFilter) { |
| 353 | console.log(`${colors.bold}Cost Summary${colors.reset}`) |
| 354 | console.log() |
| 355 | |
| 356 | // two column layout |
| 357 | const col1 = [ |
| 358 | `${colors.bold}Total cost:${colors.reset} ${colors.yellow}${formatCurrency(stats.totalCost)}${colors.reset}`, |
| 359 | `${colors.bold}Avg cost/day:${colors.reset} ${colors.yellow}${formatCurrency(stats.costPerDay)}${colors.reset}`, |
| 360 | `${colors.bold}Avg cost/session:${colors.reset} ${colors.yellow}${formatCurrency(stats.costPerSession)}${colors.reset}`, |
| 361 | ] |
| 362 | const col2 = [ |
| 363 | `${colors.bold}Sessions:${colors.reset} ${colors.primary}${stats.totalSessions}${colors.reset}`, |
| 364 | `${colors.bold}Active days:${colors.reset} ${colors.primary}${stats.activeDays}${dateFilter ? "" : `/${daysToShow}`}${colors.reset}`, |
| 365 | "", |
| 366 | ] |
| 367 | |
| 368 | for (let i = 0; i < col1.length; i++) { |
| 369 | if (col2[i]) { |
| 370 | console.log(`${col1[i].padEnd(55)}${col2[i]}`) |
| 371 | } else { |
| 372 | console.log(col1[i]) |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | console.log() |
| 377 | console.log(`${colors.bold}Token Breakdown${colors.reset}`) |
| 378 | console.log( |
| 379 | ` ${colors.bold}Input:${colors.reset} ${colors.primary}${formatNumber(stats.tokenBreakdown.input)}${colors.reset} · ${colors.yellow}${formatCurrency(stats.costBreakdown.input)}${colors.reset}`, |
| 380 | ) |
| 381 | console.log( |
| 382 | ` ${colors.bold}Output:${colors.reset} ${colors.pink}${formatNumber(stats.tokenBreakdown.output)}${colors.reset} · ${colors.yellow}${formatCurrency(stats.costBreakdown.output)}${colors.reset}`, |
| 383 | ) |
| 384 | console.log( |
| 385 | ` ${colors.bold}Cache read:${colors.reset} ${colors.purple}${formatNumber(stats.tokenBreakdown.cacheRead)}${colors.reset} · ${colors.yellow}${formatCurrency(stats.costBreakdown.cacheRead)}${colors.reset}`, |
| 386 | ) |
| 387 | console.log( |
| 388 | ` ${colors.bold}Cache write:${colors.reset} ${colors.purple}${formatNumber(stats.tokenBreakdown.cacheWrite)}${colors.reset} · ${colors.yellow}${formatCurrency(stats.costBreakdown.cacheWrite)}${colors.reset}`, |
| 389 | ) |
| 390 | |
| 391 | console.log() |
| 392 | console.log(`${colors.bold}Top Models by Cost${colors.reset}`) |
| 393 | |
| 394 | const topByCost = Object.entries(stats.modelUsage) |
| 395 | .sort(([, a], [, b]) => b.cost - a.cost) |
| 396 | .slice(0, 5) |
| 397 | |
| 398 | if (topByCost.length === 0) { |
| 399 | console.log(`${colors.muted}No cost data available${colors.reset}`) |
| 400 | return |
| 401 | } |
| 402 | |
| 403 | const maxCost = Math.max(0.01, topByCost[0][1].cost) |
| 404 | |
| 405 | for (const [model, usage] of topByCost) { |
| 406 | const barLength = Math.max(1, Math.floor((usage.cost / maxCost) * 25)) |
| 407 | const bar = "█".repeat(barLength) |
| 408 | const truncated = truncateModel(model, 33) |
| 409 | console.log( |
no test coverage detected