feat: add usage tracking, output mode, and cli exit mode (#7)
This commit is contained in:
34
src/cli/components/SessionStats.tsx
Normal file
34
src/cli/components/SessionStats.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Box, Text } from "ink";
|
||||
import type { SessionStatsSnapshot } from "../../agent/stats";
|
||||
|
||||
interface SessionStatsProps {
|
||||
stats: SessionStatsSnapshot;
|
||||
}
|
||||
|
||||
function formatDuration(ms: number): string {
|
||||
if (ms < 1000) {
|
||||
return `${Math.round(ms)}ms`;
|
||||
}
|
||||
return `${(ms / 1000).toFixed(1)}s`;
|
||||
}
|
||||
|
||||
function formatNumber(n: number): string {
|
||||
return n.toLocaleString();
|
||||
}
|
||||
|
||||
export function SessionStats({ stats }: SessionStatsProps) {
|
||||
const wallDuration = formatDuration(stats.totalWallMs);
|
||||
const apiDuration = formatDuration(stats.totalApiMs);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" paddingTop={1}>
|
||||
<Text dimColor>Total duration (API): {apiDuration}</Text>
|
||||
<Text dimColor>Total duration (wall): {wallDuration}</Text>
|
||||
<Text dimColor>
|
||||
Usage: {stats.usage.stepCount} steps,{" "}
|
||||
{formatNumber(stats.usage.promptTokens)} input,{" "}
|
||||
{formatNumber(stats.usage.completionTokens)} output
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user