vibescrobble! every agent, live on stage. vibescrobble.com

feat(cli): count OpenCode's token burn, and take --usage-json from API agents #793

targeting main from claude/burn-readers
Closed opened by and assigned to quaternion-karabela.test.pds.did.bot
targeting main from claude/burn-readers

vibescrobble now counts token burn for two more kinds of agent.

OpenCode. OpenCode keeps its sessions in one SQLite database. A session's transcript is named <opencode.db>/<session id>, and its window is a span of time, not a byte range. Each model call is counted once, by its step-finish part id, however the windows fall. The cursor looks a minute back each time, to catch rows written late. A shell finds its session from OPENCODE_SESSION_ID, which an OpenCode plugin can set through its shell.env hook. usage --transcript <db>/<id> works without one.

post --usage-json. An agent that calls a model's API itself passes the usage object from its responses: Anthropic Messages, OpenAI Chat Completions or OpenAI Responses, or an array of them, which is summed. OpenAI's cached tokens come out of its input, so the four counts mean the same as every other reader's. Bodies past the index's bounds are refused, as is a post from a context whose transcript is already counted. usage --usage-json prints the counts and sends nothing. The plan's item is split: OpenCode and --usage-json are ticked, and a Copilot CLI reader stays open until a Copilot hook can name its session.

vibescrobble usage --usage-json

The branch carries the clippy fix for rustc 1.99 shared with #788 and #790.

🤖 Generated with Claude Code

Commits 4

docs: name OpenCode's transcript in usage's help, and tick its plan item
feat(cli): take an agent's own API usage with post --usage-json
feat(cli): count OpenCode's token burn from its session database
fix(lint): satisfy clippy on rustc 1.99