Skip to content

Usage scorecard: ingest OpenRouter session logs as a third provider #59

Description

@pacphi

Context

The usage scorecard (ADR-0009) ingests two local transcript stores today:

Provider Store Parser
Claude Code ~/.claude/projects/**/*.jsonl parseClaude (src/lib/usage-index.mjs)
Codex CLI ~/.codex/sessions/**/rollout-*.jsonl parseCodex (src/lib/usage-index.mjs)

Sessions routed through OpenRouter (e.g. GLM models via z-ai/glm-5.2, or any other OpenRouter-served model reached from aqe's fallback chain or ruflo's provider matrix — see docs/PROVIDERS.md) are invisible to the scorecard unless they happen to flow through one of the two hosts above. As dual/multi-provider usage grows on machines running ak x provider pick with OpenRouter entries, the scorecard's "by host" and "models in play" panels undercount real activity.

Scope of the enhancement

  1. Discovery — establish where (and whether) an OpenRouter-backed CLI/host on this machine persists per-session transcripts with per-turn token usage, and what the log schema is. (OpenRouter itself is an API gateway; the local log format depends on the client driving it — this needs the same grounding pass parseCodex got before any parsing code is written.)
  2. Parser — a third parse* sibling in src/lib/usage-index.mjs, following the house rules the existing two enforce: cumulative-vs-delta token semantics established from real logs (not assumed — see the Codex thread-replay bug, docs/USAGE-SCORECARD-METRICS.md §15), read-only, malformed lines skipped never fatal, SCHEMA_VERSION bump if session-record fields change.
  3. Turn attribution — user-role turns must carry the kind field (prompt / tool-result / context) so the transcript reader never attributes tool output to the human (docs/TRANSCRIPTS.md).
  4. Pricing — OpenRouter passes through per-model pricing that differs from first-party list rates and publishes a machine-readable models endpoint; decide whether the maintained table in src/lib/pricing.mjs grows OpenRouter entries or gains a dated snapshot from that endpoint (keeping the offline-first contract — no network at scan time).
  5. UI — "by host" grows a third card; the provider ordering in dashboard-server.mjs (order=["claude","codex"]) becomes extensible.

Documentation to update when this lands

  • docs/USAGE-SCORECARD-METRICS.md (§1 data provenance, §8 by-host, §13 pricing tables)
  • docs/TRANSCRIPTS.md (provider differences table)
  • ADR-0009 (amendment)

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions