Guidance for coding agents working in this repository.
- Type: TypeScript CLI (
llm-usage-metrics) - Runtime: Node.js 24+
- Package/dev workflow: pnpm (
pnpm-lock.yaml) - Core job: parse local usage data, normalize events, apply pricing, aggregate, render reports
- Install:
pnpm install - Lint:
pnpm run lint - Typecheck:
pnpm run typecheck - Tests (with coverage):
pnpm run test - Format check:
pnpm run format:check - Build:
pnpm run build
Before opening a PR, run:
pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run format:check
src/cli: command wiring and report orchestrationsrc/sources: source adapters + discovery/parsingsrc/domain: normalized data contractssrc/pricing: pricing source + cost enginesrc/aggregate: usage bucketing/totalssrc/render: terminal/markdown/json output formattingsrc/update: startup update notifier
Keep source-specific parsing logic inside adapters. Keep pricing logic in src/pricing. Keep rendering concerns in src/render.
- Follow strict TypeScript and existing ESLint rules.
- Use type imports where possible.
- Do not introduce
any. - Prefer small, explicit functions over implicit behavior.
- Normalize data at boundaries (adapter/domain constructors).
- Preserve deterministic output ordering.
- Avoid inline dynamic imports.
- Keep option semantics aligned with
docs/cli-reference.md. - Validate inputs early and fail with actionable errors.
- Keep report output data-only on
stdout(especially--json/--markdown). - Emit diagnostics to
stderr.
- Every functional change should include or update tests.
- Place tests by area:
tests/clitests/sourcestests/pricingtests/rendertests/e2e
- For new sources, add fixture-based parser tests and adapter wiring tests.
Update docs when behavior changes:
README.mdfor user-facing behavior/examplesdocs/cli-reference.mdfor option semanticsdocs/architecture.mdwhen layering or flow changes
- Use concise Conventional Commit subjects (e.g.
fix(cli): ...,feat(source): ...). - Keep commits focused and isolated by concern.
- Include a short validation summary in PR descriptions.