Skip to content

fix: parse Grok Build usage logs - #45

Merged
juliantanx merged 6 commits into
mainfrom
fix/issue-43-grok-parser
Jul 16, 2026
Merged

fix: parse Grok Build usage logs#45
juliantanx merged 6 commits into
mainfrom
fix/issue-43-grok-parser

Conversation

@juliantanx

Copy link
Copy Markdown
Owner

Summary

  • add a dedicated stateful Grok Build parser for updates.jsonl
  • convert cumulative totalTokens counters into positive per-turn deltas
  • extract Grok session, model, timestamp, provider, and encoded workspace metadata
  • restrict Grok discovery and status counts to actual usage logs
  • version the Grok parser watermark so logs skipped by v1.5.10 are replayed once

Root cause

Grok Build's session directory was registered in discovery, but Aggregator had no parser for the grok tool. The generic JSONL parser also does not understand Grok's JSON-RPC fields or cumulative token semantics. Despite producing no records, the CLI advanced each file's watermark to EOF, preventing a later fixed version from automatically importing historical sessions.

Impact

aiusage parse --tool grok and automatic parsing now import existing and newly appended Grok Build usage. Repeated/decreasing cumulative counters do not double-count tokens, multiple sessions remain isolated, and a second parse is idempotent.

Grok currently exposes no stable input/output/cache split, so positive total-token deltas are recorded as input tokens.

Validation

  • pnpm test — 605 tests passed across core, web, widget, site, and CLI
  • pnpm build — core, web, CLI, and widget builds passed
  • focused Grok parser, discovery, watermark migration, and CLI integration tests included

Closes #43

@willtse

willtse commented Jul 14, 2026

Copy link
Copy Markdown

本机测试了下:

结论

结果 说明
分支 fix/issue-43-grok-parser (72285c6) PR #45
Core build 通过 @aiusage/core
单测 grok + aggregator 通过 12/12
集成测 parse-grok / discovery / watermark 通过 32/32
本机 Grok 日志 13 个 updates.jsonl ~\.grok\sessions
首次 parse --tool grok 通过 导入 38 条记录
再次 parse 通过(幂等) 行数仍 38,活跃 turn 可 upsert 更新
会话数 通过 13,与日志文件数一致
模型 / provider 通过 grok-4.5 / xai
cwd 解码 通过 D:\git\github_clone
token 语义 通过 增量记入 input_tokensoutput=0,无负值
水位迁移 通过 grokParserVersion: 1,13 个文件水位
全量 pnpm test / pnpm build 未跑 非本修复阻塞项
总评 通过 可合入,修复 issue #43

可以认为 PR #45 在本机已验证通过,能合入解决 issue #43

@juliantanx
juliantanx marked this pull request as ready for review July 16, 2026 03:21
@juliantanx
juliantanx merged commit dd18144 into main Jul 16, 2026
7 checks passed
@juliantanx
juliantanx deleted the fix/issue-43-grok-parser branch July 16, 2026 03:30
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] Grok Build 会话日志被发现但未解析任何使用数据

2 participants