CodeBurn Documentation
repository·main·Indexed 27 days ago
https://github.com/getagentseal/codeburnA local-first, open-source tool for tracking AI coding token usage and costs across tools like Claude Code, Cursor, and Gemini. CodeBurn analyzes local session files to help developers identify wasted spend and optimize workflows. It includes a CLI, a desktop application, a macOS menubar app, and a GNOME extension, with support for syncing usage telemetry to shared backends via OTLP spans.
What's inside CodeBurn
- The ZCode provider integrates usage data from the ZCode CLI coding agent (z.ai), which runs GLM-5.2 over the z.ai start-plan. It reads data directly from the ZCode global SQLite database to extract token usage, model information, and tool usage for CodeBurn reporting.
Architecture of CodeBurn Desktop
mainCodeBurn Desktop is a local-first Electron application that acts as a view layer for the
codeburnCLI. It does not re-implement analytics; instead, it spawns the CLI to fetch and render JSON data.Key Architectural Components:
- Main Process: Handles the
codeburnbinary resolution, spawns CLI processes with--jsonflags, manages a 30s polling timer, and handles IPC. - Preload Script: Exposes a minimal, typed
window.codeburnsurface viacontextBridgeto the renderer. - Renderer Process: A React 19 application that runs with
contextIsolation: trueandnodeIntegration: false. It consumes data via IPC and renders the six main sections. - Data Flow: The app uses the 'menubar pattern' where the CLI is invoked per section (e.g.,
codeburn status --format menubar-json), the JSON is decoded, and the renderer displays it.
- Main Process: Handles the
Implement the CodeBurn MCP Server
mainThe CodeBurn MCP (Model Context Protocol) server is a
stdioserver that exposes CodeBurn's usage and cost data to AI agents. It provides two primary tools:get_usage: Returns usage and cost data.get_savings: Returns savings data.
Both tools return data in two formats: a markdown table for human readability and typed structured JSON for programmatic use by the agent. The server uses a long-lived in-process
McpServerthat coalesces concurrent calls and relies on a 180s parser cache for performance.Understand CodeBurn Provider Integration Architecture
mainCodeBurn uses a provider-based system to integrate with various AI coding tools and agents. Providers are categorized by their loading behavior:
- Eager Providers: Always loaded by the system. These typically read from local files like
JSON,JSONL, orSQLitedatabases (e.g., Claude, Copilot, Gemini). - Lazy Providers: Loaded only on their first call. These may use different communication methods like
protobuf over RPCorREST API(e.g., Antigravity, Vercel AI Gateway).
If you are developing for a specific provider, you should locate its source file in
src/providers/and its corresponding test file intests/providers/to understand its specific data source and edge cases.- Eager Providers: Always loaded by the system. These typically read from local files like
Understand the codeburn sync architecture
mainThe
codeburn syncprocess operates by reading local configuration and credentials to push telemetry data to a remote backend.Local Files:
- Configuration:
~/.config/codeburn/sync.json(containsbaseUrl,clientId,issuer,tracesPath) - Credentials:
~/.config/codeburn/.sync-token(managed via OS credential store) - Sent Ledger:
~/.cache/codeburn/sync-ledger.json(tracks sent calls for deduplication)
Push Workflow:
- Read config and refresh token.
- Authenticate via OIDC to get an
access_token. - Collect calls and filter against the
sent-ledgerto ensure only unsent calls are processed. - Build an OTLP/HTTP JSON payload.
- POST the payload to
{baseUrl}{tracesPath}using the Bearer token. - On success, update the ledger and
lastSyncin config.
- Configuration:
Understand the vscode-cline-parser shared helper
mainThevscode-cline-parseris a shared utility used to discover and parse task data for Cline and other VS Code extensions derived from Cline (such as IBM Bob, KiloCode, and Roo Code). It is not a standalone provider but is imported by specific provider implementations to handle task storage and data extraction.Integrate Cline task data with CodeBurn
mainCodeBurn can automatically ingest task usage and conversation data from the Cline VS Code extension. It scans two specific locations for task data:
- VS Code globalStorage: The directory for
saoudrizwan.claude-dev. - Cline home-data: The directory at
~/.cline/data.
For a task to be discovered and included, the directory must contain a
tasks/child directory and include aui_messages.jsonfile. The provider usesui_messages.jsonforapi_req_startedusage entries andapi_conversation_history.jsonfor model extraction.- VS Code globalStorage: The directory for
Replace assets on an existing GitHub Release
mainIf a release contains broken assets (like a corrupted menubar zip), you can overwrite them without creating a new tag using the GitHub CLI
--clobberflag. This ensures users running the installer pick up the fixed files automatically.gh release upload mac-v0.9.8 mac/.build/dist/CodeBurnMenubar-v0.9.8.zip --clobber gh release upload mac-v0.9.8 mac/.build/dist/CodeBurnMenubar-v0.9.8.zip.sha256 --clobberLocate IBM Bob IDE task history storage paths
mainIBM Bob stores its IDE task history in the application data directory under
User/globalStorage/ibm.bob-code/tasks/. CodeBurn checks the following default paths based on your platform:Platform Paths macOS ~/Library/Application Support/IBM Bob/User/globalStorage/ibm.bob-code/,~/Library/Application Support/Bob-IDE/User/globalStorage/ibm.bob-code/Windows %APPDATA%/IBM Bob/User/globalStorage/ibm.bob-code/,%APPDATA%/Bob-IDE/User/globalStorage/ibm.bob-code/Linux $XDG_CONFIG_HOME/IBM Bob/User/globalStorage/ibm.bob-code/,$XDG_CONFIG_HOME/Bob-IDE/User/globalStorage/ibm.bob-code/(with~/.configfallback)Note: The
Bob-IDEpaths are included to support older installations that used the preview-era application name.Configure Kimi Code data source location
mainBy default, the provider scans known Kimi Code runtime stores. You can narrow the scan to a specific directory by setting the
KIMI_CODE_HOMEenvironment variable.Default scan locations:
~/.kimi-code~/Library/Application Support/kimi-desktop/daimon-share/daimon/runtime/kimi-code/home(Kimi desktop / IDE embedded runtime)
Internal directory structure scanned: Inside each home, the provider looks for sessions in:
$HOME/sessions/wd_*/<session-dir>/(CLI) orconv-*/ctitle-*(embedded runtimes).Each session directory must contain:
state.jsonagents/<agent-id>/wire.jsonl
Quick Start with codeburn sync
mainTo begin syncing your AI usage telemetry to a shared backend, perform a one-time setup followed by pushing your data and checking the status.
- Setup: Run
codeburn sync setup <url>to configure your endpoint and log in via your browser. - Push: Run
codeburn sync pushto send recent usage data. - Status: Run
codeburn sync statusto verify your configuration and authentication state.
# One-time setup (opens browser for login) codeburn sync setup https://metrics.your-team.com # Push recent usage codeburn sync push # Check status codeburn sync status- Setup: Run
Understand KiloCode provider data sources
mainThe KiloCode provider reads data from the VS Code extensionglobalStorageusing the extension IDkilocode.kilo-code. The actual file walking and parsing logic is delegated to thediscoverClineTasksfunction insrc/providers/vscode-cline-parser.ts.