MCPcopy
hub / github.com/codeaashu/claude-code / formatTotalCost

Function formatTotalCost

src/cost-tracker.ts:228–256  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226}
227
228export 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())}
252Total duration (wall): ${formatDuration(getTotalDuration())}
253Total code changes: ${getTotalLinesAdded()} ${getTotalLinesAdded() === 1 ? 'line' : 'lines'} added, ${getTotalLinesRemoved()} ${getTotalLinesRemoved() === 1 ? 'line' : 'lines'} removed
254${modelUsageDisplay}${x402Display}`,
255 )
256}
257
258function round(number: number, precision: number): number {
259 return Math.round(number * precision) / precision

Callers 2

fFunction · 0.85
callFunction · 0.85

Calls 10

formatCostFunction · 0.85
getTotalCostUSDFunction · 0.85
hasUnknownModelCostFunction · 0.85
formatModelUsageFunction · 0.85
formatX402CostFunction · 0.85
getTotalAPIDurationFunction · 0.85
getTotalDurationFunction · 0.85
getTotalLinesAddedFunction · 0.85
getTotalLinesRemovedFunction · 0.85
formatDurationFunction · 0.50

Tested by

no test coverage detected