How getagentseal/codeburn works
Purpose and entry points
CodeBurn is a local-first AI coding-usage analytics product. It reads provider session data from disk (plus optional Vercel reporting), prices and classifies usage, then exposes reports, optimization, controls, and native surfaces. The Node CLI is the core entry point at src/main.ts and command router at src/cli.ts; default execution opens the terminal dashboard in src/dashboard.tsx. Other primary entry points are local web (src/web-dashboard.ts), MCP stdio (src/mcp/server.ts), and Electron desktop (app/electron/main.ts).
Ingestion and provider boundary
Provider adapters isolate vendor-specific discovery and parsing into one-file integrations, registered centrally in src/providers/index.ts against shared contracts in src/providers/types.ts. Examples include src/providers/claude.ts, src/providers/codex.ts, and SQLite-oriented sources such as src/providers/cursor.ts. Adapters locate local files/databases, parse records into normalized session/call data, deduplicate provider artifacts, and preserve source-quality distinctions (actual versus estimated). This boundary is the main extension point for new tools.
Parse, cache, and normalized usage pipeline
The parser coordinates multi-provider scanning, filtering, incremental hydration, and worker execution through src/parser.ts, src/parse-workers.ts, and src/parse-worker.ts. Durable local caching and concurrent-refresh coordination live in src/session-cache.ts and src/cache-refresh-lock.ts; SQLite reads are abstracted by src/sqlite.ts. Parsed calls flow into aggregation/pricing stages: src/usage-aggregator.ts computes totals and freshness, src/day-aggregator.ts produces time buckets, and src/models.ts / src/model-breakdown.ts form model views.
Pricing, classification, and analytical products
Shared pricing uses LiteLLM data with bundled fallbacks in src/data/litellm-snapshot.json and src/data/pricing-fallback.json, mediated by src/models.ts and src/fetch-utils.ts; currency conversion is handled by src/currency.ts. Deterministic task labeling and behavioral metrics originate in src/classifier.ts and src/behavioral-weight.ts. Analysis layers consume normalized sessions for model comparison (src/compare.tsx), waste detection and recommendations (src/optimize.ts), git-correlated delivery yield (src/yield.ts), and context inspection (src/context-tree.ts).
Outputs and local control plane
CLI reports, TUI panels, JSON/CSV export, and status views are generated from the same pipeline (src/dashboard.tsx, src/overview.ts, src/export.ts). The localhost web dashboard is served by src/serve.ts / src/web-dashboard.ts; its separate React prototype/client resides in dash/src/App.tsx. MCP exposes local usage and savings tools, with project-name redaction at src/mcp/redact.ts. Guard installs fail-open Claude hooks (src/guard/cli.ts, src/guard/hooks.ts). Optimize changes are transactional: backup/journal/apply/undo live under src/act/.
Desktop and ambient clients
Electron packages a cross-platform React desktop UI: main-process CLI/IPC bridge at app/electron/main.ts, secure preload at app/electron/preload.ts, renderer root at app/renderer/App.tsx. Native macOS menubar is a Swift/SwiftUI client that invokes/consumes CLI data via mac/Sources/CodeBurnMenubar/Data/DataClient.swift, renders via mac/Sources/CodeBurnMenubar/CodeBurnApp.swift, and stores credentials in Keychain-oriented code. Windows/Linux tray is Tauri/Rust plus React (windows/src-tauri/src/lib.rs, windows/src/App.tsx). GNOME uses a JavaScript extension (gnome/extension.js).
Networking, privacy, and delivery
Default operation is local disk and localhost only. Pricing refresh contacts LiteLLM; currency contacts Frankfurter. Optional device sharing uses LAN discovery/pairing and sanitized transport in src/sharing/, while preview team sync uses OIDC, consent, credential storage, OTLP encoding, and remote push under src/sync/. Releases build npm/CLI plus Snap, installers, Store, and native menubar artifacts via workflows such as .github/workflows/ci.yml, .github/workflows/build-snap.yml, and .github/workflows/build-windows-installer.yml.
Main entry points: usage-aggregator.ts Usage aggregation · main.ts Node CLI · optimize.ts Analysis products · parser.ts Parse coordinator
Components 21
Entry Points
- Node CLI · Core command entry point and router.
src/main.ts
Local Usage Pipeline
- Provider registry · Registers normalized local-data adapters.
src/providers/index.ts - Provider contracts
src/providers/types.ts - Local provider adapters · Claude, Codex, Cursor, and other disk/database readers.
src/providers/claude.ts - Parse coordinator · Scans, filters, hydrates, and dispatches parsing work.
src/parser.ts - Parse workers · Concurrent provider parsing.
src/parse-workers.ts - Session cache · Caches parsed sessions and coordinates refreshes.
src/session-cache.ts - Usage aggregation · Computes totals and freshness from parsed calls.
src/usage-aggregator.ts
Analytics & Actions
- Models & pricing · Builds model views using LiteLLM and fallback pricing.
src/models.ts - Task classification · Deterministic labels and behavioral metrics.
src/classifier.ts - Analysis products · Comparison, optimization, yield, and context analysis.
src/optimize.ts - Transactional optimize actions · Backup, journal, apply, and undo optimized changes.
Local Surfaces
- Terminal dashboard · Default CLI surface.
src/dashboard.tsx - Reports & export · Overview, JSON/CSV export, and status views.
src/export.ts - Local web dashboard · Serves the local browser dashboard.
src/web-dashboard.ts - MCP server · Exposes local usage and savings with redaction.
src/mcp/server.ts - Electron desktop · CLI/IPC bridge for the React desktop UI.
app/electron/main.ts - Ambient native clients · macOS menubar, Tauri tray, and GNOME extension consume local data.
mac/Sources/CodeBurnMenubar/Data/DataClient.swift - Claude guard hooks · Fail-open hook installation and enforcement.
src/guard/cli.ts
Optional Networked Features
- LAN device sharing · Discovery, pairing, and sanitized transport.
- Preview team sync · Consent-gated OIDC telemetry encoding and remote push.
Connections 27
- Node CLI → Parse coordinator: runs pipeline
- Node CLI → Terminal dashboard: default command
- Node CLI → Reports & export: report commands
- Node CLI → Local web dashboard: web command
- Node CLI → MCP server: MCP command
- Node CLI → Claude guard hooks: installs controls
- Provider registry → Provider contracts: implements
- Local provider adapters → Provider registry: registered by
- Provider registry → Parse coordinator: discovers and parses
- Parse coordinator → Parse workers: dispatches
- Parse coordinator → Session cache: hydrates and caches
- Parse workers → Usage aggregation: normalized calls
- Session cache → Usage aggregation: cached sessions
- Usage aggregation → Models & pricing: usage totals
- Usage aggregation → Task classification: session behavior
- Models & pricing → Analysis products: priced model views
- Task classification → Analysis products: task metrics
- Analysis products → Transactional optimize actions: recommended changes
- Usage aggregation → Terminal dashboard: local reports
- Analysis products → Terminal dashboard: insights
- Usage aggregation → Reports & export: export data
- Analysis products → Local web dashboard: dashboard data
- Usage aggregation → MCP server: usage tools
- Node CLI → Electron desktop: invoked through bridge
- Node CLI → Ambient native clients: local data source
- Usage aggregation → LAN device sharing: sanitized usage
- Usage aggregation → Preview team sync: consented telemetry