()
| 226 | } |
| 227 | |
| 228 | export function formatTotalCost(): string { |
| 229 | const costDisplay = |
| 230 | formatCost(getTotalCostUSD()) + |
| 231 | (hasUnknownModelCost() |
| 232 | ? ' (costs may be inaccurate due to usage of unknown models)' |
| 233 | : '') |
| 234 | |
| 235 | const modelUsageDisplay = formatModelUsage() |
| 236 | |
| 237 | // Include x402 payment summary if any payments were made |
| 238 | let x402Display = '' |
| 239 | try { |
| 240 | const { formatX402Cost } = require('./services/x402/index.js') as typeof import('./services/x402/index.js') |
| 241 | const x402Summary = formatX402Cost() |
| 242 | if (x402Summary) { |
| 243 | x402Display = '\n' + x402Summary |
| 244 | } |
| 245 | } catch { |
| 246 | // x402 module not available, skip |
| 247 | } |
| 248 | |
| 249 | return chalk.dim( |
| 250 | `Total cost: ${costDisplay}\n` + |
| 251 | `Total duration (API): ${formatDuration(getTotalAPIDuration())} |
| 252 | Total duration (wall): ${formatDuration(getTotalDuration())} |
| 253 | Total code changes: ${getTotalLinesAdded()} ${getTotalLinesAdded() === 1 ? 'line' : 'lines'} added, ${getTotalLinesRemoved()} ${getTotalLinesRemoved() === 1 ? 'line' : 'lines'} removed |
| 254 | ${modelUsageDisplay}${x402Display}`, |
| 255 | ) |
| 256 | } |
| 257 | |
| 258 | function round(number: number, precision: number): number { |
| 259 | return Math.round(number * precision) / precision |
no test coverage detected