Cost Tracking & Command History
Session cost tracking and command history with paste support.
Cost Tracking
cost-tracker.ts
Tracks and persists all API costs, token usage, and duration metrics.
Key Functions
TypeScript
Shared from "Claude-Code" on Inkdown
Session cost tracking and command history with paste support.
cost-tracker.tsTracks and persists all API costs, token usage, and duration metrics.
Cost and token counters are exposed as OTel metrics:
costHook.tsExit-time cost reporter:
history.ts)Manages the up-arrow / ctrl+r command history.
Each line is a JSON object:
Large pasted content is stored as references:
The actual content is stored externally via hash references (paste store).
Duplicate entries are removed, keeping the newest:
Current session entries appear first:
Concurrent writes use file locking:
| File | Purpose |
|---|---|
src/cost-tracker.ts | Session cost tracking |
src/costHook.ts | Exit-time cost reporter |
src/history.ts | Command history with paste support |