Skip to content

fix(parser): support gemini-cli JSONL format (#144)#145

Merged
mag123c merged 1 commit into
mainfrom
fix/issue-144-gemini-jsonl
May 14, 2026
Merged

fix(parser): support gemini-cli JSONL format (#144)#145
mag123c merged 1 commit into
mainfrom
fix/issue-144-gemini-jsonl

Conversation

@mag123c
Copy link
Copy Markdown
Owner

@mag123c mag123c commented May 14, 2026

Summary

  • gemini-cli switched chat recording from single-object .json to streaming .jsonl on 2026-04-09 (feat(core): migrate chat recording to JSONL streaming google-gemini/gemini-cli#23749). toktrack's parser only matched */chats/session-*.json, so new gemini sessions were silently dropped → issue [Bug] Gemini usage not showing up #144 (reported on v2.7.0).
  • Add .jsonl support (line-by-line streaming, metadata + $set + $rewindTo + non-gemini types skipped) while keeping legacy .json working for users who haven't resumed yet.
  • Pick up subagent sessions too — {chatsDir}/{parentSessionId}/{id}.jsonl (no session- prefix).
  • tokens.tool (new toolUsePromptTokenCount) is folded into input_tokens so user-visible totals match gemini-cli's own.
  • Honor GEMINI_CLI_HOME env var (matches gemini-cli paths.ts).
  • Cache invalidation: CACHE_VERSION 12 → 13.

Closes #144.

Test plan

  • make check (fmt + clippy + 489 unit tests) — all green
  • 20 gemini parser tests pass (8 legacy regression + 12 new JSONL)
  • Verified locally — cargo run --release picks up gemini usage from ~/.gemini/tmp/*/chats/*.jsonl (reporter's reproduction)
  • CI green on 3 OS matrix

Out of scope

🤖 Reviewed by independent sub-agent review — P0/P1 findings dismissed as pre-existing repo conventions (env-var test pattern matches src/services/pricing.rs; cache mismatch semantics match issue #134).

gemini-cli migrated chat recording from single-object `.json` to streaming
`.jsonl` on 2026-04-09 (google-gemini/gemini-cli#23749). The legacy parser
only matched `*/chats/session-*.json` so new sessions were silently
dropped — issue #144 (v2.7.0).

- `collect_files`: 3-glob union (main `.jsonl`, legacy `.json`, subagent
  `.jsonl` under nested parent-session dirs)
- `parse_file`: extension dispatch — `.jsonl` streams line-by-line and
  ignores metadata, `\$set`, `\$rewindTo`, and non-`gemini` message lines
- `tokens.tool` (toolUsePromptTokenCount, added in the same gemini-cli
  release) is folded into input_tokens so totals match gemini-cli's own
- `GEMINI_CLI_HOME` env var honored, matching gemini-cli paths.ts
- Cache invalidates via CACHE_VERSION 12 → 13
@mag123c mag123c force-pushed the fix/issue-144-gemini-jsonl branch from dae0dee to d376ded Compare May 14, 2026 12:50
@mag123c mag123c merged commit 7ea890a into main May 14, 2026
3 checks passed
@mag123c mag123c deleted the fix/issue-144-gemini-jsonl branch May 14, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Gemini usage not showing up

1 participant