🎯 Use case
React hook or adapter for surfacing cost data in the UI. On the API surface it exposes useCostSummary — mainly functions, hooks, or classes. Dependencies touch React UI. It composes internal code from cost-tracker and utils (relative imports).
Generated from folder role, exports, dependency roots, and inline comments — not hand-reviewed for every path.
🧠 Inline summary
import { useEffect } from 'react' import { formatTotalCost, saveCurrentSessionCosts } from './cost-tracker.js' import { hasConsoleBillingAccess } from './utils/billing.js' import type { FpsMetrics } from './utils/fpsTracker.js'
📤 Exports (heuristic)
useCostSummary
📚 External import roots
Package roots from from "…" (relative paths omitted).
react
🖥️ Source preview
import { useEffect } from 'react'
import { formatTotalCost, saveCurrentSessionCosts } from './cost-tracker.js'
import { hasConsoleBillingAccess } from './utils/billing.js'
import type { FpsMetrics } from './utils/fpsTracker.js'
export function useCostSummary(
getFpsMetrics?: () => FpsMetrics | undefined,
): void {
useEffect(() => {
const f = () => {
if (hasConsoleBillingAccess()) {
process.stdout.write('\n' + formatTotalCost() + '\n')
}
saveCurrentSessionCosts(getFpsMetrics?.())
}
process.on('exit', f)
return () => {
process.off('exit', f)
}
}, [])
}