Skip to content

Add OpenCode and Grok Build adapters#1

Merged
starkdmi merged 2 commits into
mainfrom
opencode-grok-build-adapters
Jun 11, 2026
Merged

Add OpenCode and Grok Build adapters#1
starkdmi merged 2 commits into
mainfrom
opencode-grok-build-adapters

Conversation

@starkdmi

Copy link
Copy Markdown
Owner

What changed

This adds the new OpenCode and Grok Build adapters and folds in the follow-up fixes that came out of review and real-data validation.

Why it changed

The goal is to ingest real OpenCode and Grok Build usage, recover per-model attribution where the raw data is incomplete, and estimate API-equivalent cost more fairly for provider-qualified and proxy-wrapped model names instead of leaving them at $0.

Impact

  • adds OpenCode and Grok Build source scanning
  • improves OpenCode model recovery from message records and preserves provider-qualified model identity
  • splits ambiguous multi-model OpenCode sessions when message-level usage is available, with residual aggregate fallback when reconstruction is partial
  • broadens pricing normalization for provider-prefixed and proxy-wrapped model IDs
  • makes Grok unified-log handling incremental per session for cache invalidation
  • hardens Grok JSONL parsing so malformed rows are skipped instead of aborting the whole scan

Root cause

The initial adapter implementation handled the core formats, but real local data exposed a few gaps:

  • OpenCode session-level model fields are often missing even when message-level model data exists
  • proxy/local-provider model names need normalization to map onto known pricing tables
  • Grok JSONL files can contain malformed trailing or partial rows that should not block usage collection

Validation

  • cargo test -p statsai-adapters -p statsai-pricing -p statsai
  • real-data preview scans for OpenCode and Grok Build during development

@starkdmi starkdmi changed the title [codex] add OpenCode and Grok Build adapters Add OpenCode and Grok Build adapters Jun 11, 2026
@starkdmi starkdmi marked this pull request as ready for review June 11, 2026 15:56
@starkdmi starkdmi merged commit 1fdc113 into main Jun 11, 2026
12 of 13 checks passed
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.

1 participant