Skip to content

Add support for Gemini CLI session tracking #166

Closed

Description

@ozymandiashh

Summary

Codeburn currently supports Claude Code, Codex CLI, and Cursor (per --provider flag in 0.9.2). Adding Gemini CLI would close the loop for the most common multi-provider setup.

Why

Many users run all three concurrently (Claude Code as primary, Codex for code review, Gemini for research / large-context work). Codeburn already gives the cleanest TUI in this space, so the lack of Gemini means we either compromise on UX or run a second tracker just for Gemini cost visibility.

Where Gemini CLI stores logs

Path:

~/.gemini/tmp/<project>/chats/session-<timestamp>-<hash>.jsonl

In my install I have 83 active session files across multiple projects.

Tested with:

  • Gemini CLI: 0.39.1
  • macOS (Apple Silicon)

Format (verified, real sample, sanitized)

First line is session metadata, then JSONL with messages:

{"sessionId":"<uuid>","projectHash":"<sha256>","startTime":"2026-04-27T01:55:42.605Z","lastUpdated":"2026-04-27T01:55:42.605Z","kind":"main"}
{"id":"<uuid>","timestamp":"2026-04-27T01:55:45.373Z","type":"user","content":[{"text":"..."}]}
{"$set":{"lastUpdated":"2026-04-27T01:55:45.373Z"}}
{"id":"<uuid>","timestamp":"2026-04-27T01:55:50.123Z","type":"model","content":[{"text":"..."}]}

Message type values seen: user, model, plus stream-update lines with $set.

Pricing references

For cost calculation, Gemini API pricing is published at https://ai.google.dev/pricing. Models I use most often:

  • gemini-3.1-pro-preview
  • gemini-2.5-pro
  • gemini-2.5-flash

Notes

I tested splitrail (which advertises Gemini support) and found two related issues there:

  1. It looks for *.json, but Gemini CLI writes *.jsonl (mismatch causes 0 sessions detected).
  2. After renaming a sample to .json, splitrail registers the analyzer but parses 0 messages, suggesting the schema check expects an older format.

Sharing in case it's useful when designing the codeburn parser.

Happy to test pre-release builds against my 83 sessions if helpful.

Activity

  1. iamtoruk commented on Apr 28, 2026

    @iamtoruk
    Member

    on it

  2. added a commit that references this issue on Apr 28, 2026
    3321e47
  3. added a commit that references this issue on Apr 28, 2026
    6d15ea4
  4. ozymandiashh commented on Apr 28, 2026

    @ozymandiashh
    CollaboratorAuthor

    Quick follow-up after testing on 0.9.3 - I'm seeing the provider register but with 0 sessions detected, despite having 65 valid session files.

    Repro on my setup:

    • 65 files matching session-*.{json,jsonl} under ~/.gemini/tmp/<project>/chats/
    • Manually parsing them via Node confirms discoverSessions() would return all 65
    • codeburn today --provider gemini and codeburn report --provider gemini --period 30days --format json both return 0 cost / 0 sessions / 0 calls

    Sample message format I have (Gemini CLI 0.39.1):

    {"sessionId":"<uuid>","projectHash":"<sha>","startTime":"2026-04-27T00:00:27.112Z","lastUpdated":"...","kind":"main"}
    {"id":"<uuid>","timestamp":"...","type":"user","content":[{"text":"..."}]}
    {"$set":{"lastUpdated":"..."}}
    {"id":"<uuid>","timestamp":"...","type":"gemini","content":"...","tokens":{"input":9224,"output":24,"cached":0,"thoughts":0,"tool":0,"total":9248},"model":"gemini-3.1-pro-preview"}

    Note the $set lines (mixed in between message records) and the type: "gemini" for assistant messages. My guess is the parser might be choking silently on the $set lines or expecting a different type value.

    Also small unrelated nit: codeburn export --provider <provider> help still lists only claude, codex, cursor (missing gemini), while report and today accept it correctly.

    Happy to provide a sanitized session sample if useful for repro.

  5. iamtoruk commented on Apr 28, 2026

    @iamtoruk
    Member

    Good catch! Gemini CLI 0.39+ switched to JSONL format with $set metadata lines mixed in. The parser was only handling the older single-JSON format.

    Fixed on main. Since this isn't published to npm yet, you can test from source:

    git clone https://github.com/getagentseal/codeburn.git
    cd codeburn
    npm install
    npx tsx src/cli.ts report --provider gemini -p all

    Let us know if your 65 sessions show up!

  6. iamtoruk commented on Apr 28, 2026

    @iamtoruk
    Member

    Also -- if it works, would you mind sharing a screenshot of your codeburn report --provider gemini -p all output? With 65 sessions that'd be a great demo for the Gemini community. No worries if not!

  7. ozymandiashh commented on Apr 28, 2026

    @ozymandiashh
    CollaboratorAuthor

    Confirmed working on main (commit 64259c9)! 🎉

    Tested via npx tsx src/cli.ts report --provider gemini -p all:

    • Before fix: 0 Gemini sessions detected (parser couldn't handle JSONL + $set metadata lines)
    • After fix: 54 sessions captured, full breakdown intact
    codeburn report output (project names redacted for privacy)
       Today     7 Days     30 Days     This Month   [ All Time ]
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ CodeBurn  All Time                                                           │
    │ €3.72 cost   54 calls   54 sessions   71.2% cache hit                        │
    │ 1.9M in   289.4K out   4.7M cached   0 written                               │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ Daily Activity                                                               │
    │                     cost calls                                               │
    │ 04-24 ███░░░░░░░  €0.420     2                                               │
    │ 04-25 ██░░░░░░░░  €0.313     5                                               │
    │ 04-26 ██████░░░░  €0.961    21                                               │
    │ 04-27 ██████████   €1.58    18                                               │
    │ 04-28 ███░░░░░░░  €0.447     8                                               │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ By Project                                                                   │
    │                                                        cost  avg/s  sess     │
    │ ██████████ [project-A]                                €2.60 €0.070    37     │
    │ ██░░░░░░░░ [user-home]                               €0.427 €0.142     3     │
    │ █░░░░░░░░░ [project-B]                               €0.203 €0.068     3     │
    │ █░░░░░░░░░ agent/a60418ed9c74250a5                   €0.182 €0.182     1     │
    │ ░░░░░░░░░░ agent/a7fa14151d8c59410                   €0.126 €0.031     4     │
    │ ░░░░░░░░░░ agent/a06379f72fccd0fc2                   €0.080 €0.080     1     │
    │ ░░░░░░░░░░ agent/a7ad521428e2ba48e                   €0.064 €0.021     3     │
    │ ░░░░░░░░░░ agent/a214e547b772d7c48                   €0.029 €0.029     1     │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ Top Sessions                                                                 │
    │                                                                   cost calls │
    │ ██████████ 2026-04-27 [project-A]                              €0.427     1  │
    │ █████████░ 2026-04-24 [user-home]                              €0.401     1  │
    │ ██████░░░░ 2026-04-26 [project-A]                              €0.256     1  │
    │ ████░░░░░░ 2026-04-27 agent/a60418ed9c74250a5                  €0.182     1  │
    │ ███░░░░░░░ 2026-04-26 [project-A]                              €0.149     1  │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ By Activity                                                                  │
    │                             cost turns 1-shot                                │
    │ ██████████ Exploration     €1.68    14      -                                │
    │ ████░░░░░░ Conversation   €0.753    21      -                                │
    │ ███░░░░░░░ Coding         €0.490     3   100%                                │
    │ ███░░░░░░░ Brainstorming  €0.439     7      -                                │
    │ ██░░░░░░░░ Feature Dev    €0.300     8      -                                │
    │ ░░░░░░░░░░ Debugging      €0.059     1      -                                │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ By Model                                                                     │
    │                              cost  cache  calls                              │
    │ ██████████ Gemini 3.1 Pro   €2.18  36.1%     33                              │
    │ █████░░░░░ Gemini 3 Flash  €0.990  80.7%     18                              │
    │ ███░░░░░░░ Gemini 2.5 Pro  €0.550  60.1%      3                              │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    ╭──────────────────────────────────────────────────────────────────────────────╮
    │ Core Tools                                                                   │
    │                                                                     calls    │
    │ ██████████ GoogleSearch                                                16    │
    │ ██░░░░░░░░ Read                                                         3    │
    │ █░░░░░░░░░ Invoke Subagent                                              2    │
    │ █░░░░░░░░░ FindFiles                                                    2    │
    │ █░░░░░░░░░ run_shell_command                                            1    │
    │ █░░░░░░░░░ Bash                                                         1    │
    │ █░░░░░░░░░ ReadFolder                                                   1    │
    │ █░░░░░░░░░ Write                                                        1    │
    │ █░░░░░░░░░ browser_run_code (playwright-mcp MCP Server)                 1    │
    │ █░░░░░░░░░ browser_navigate (playwright-mcp MCP Server)                 1    │
    ╰──────────────────────────────────────────────────────────────────────────────╯
    

    Notes:

    • Initial estimate of 65 sessions was based on raw file count; actual valid parsed sessions = 54 (some files like tools.json and metadata-only entries don't count as completed sessions)
    • Cache hit rate (71.2%) and per-model breakdown look accurate
    • Daily activity correctly attributed across the 5 days

    Thanks for the fast turnaround on the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions