@token-damage/core
v0.6.0
Published
Parsing, dedupe, metrics, the live engine and the roast engine behind token-damage. Zero runtime dependencies.
Readme
@token-damage/core
The engine behind token-damage. It finds the logs of Claude Code, Codex, Gemini CLI and OpenCode, parses them, dedupes the usage, adds it up, prices it, estimates the electricity as a range, picks an adjuster's note, and builds the receipt that the CLI prints and the share card draws. Its live engine follows today's logs as they grow, for the CLI's live pane and Claude Code status line.
It has no runtime dependencies. It never keeps prompt text: user messages are reduced to a word count during parsing.
import { aggregate, claudeRoots, createDeduper, emptyStats, scanClaude } from "@token-damage/core";
import { homedir } from "node:os";
const deduper = createDeduper();
const stats = { ...emptyStats(), files: 0, subagentFiles: 0 };
for await (const record of scanClaude(claudeRoots(process.env, homedir()), stats)) deduper.add(record);
const { totals } = aggregate({ usage: deduper.result(), prompts: deduper.prompts() });This is 0.x. The API follows what the CLI needs and will change without ceremony. The specs are in docs/; the site is tokendamage.com.
MIT.
