Opencode support#5
Open
apre wants to merge 7 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Discover the opencode DB in build_sources, exclude it from JSONL discovery, and append its events in both the one-shot and live load paths. Add an end-to-end test over a fixture database. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
These lints were introduced by a newer stable clippy than the repo was last linted against and are unrelated to the opencode feature. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: everything generated by AI, I don’t understand rust and never practiced it. at least it seems to work, but no idea if it’s slop or not. tested it only quickly on my macos machine.
What this adds
Adds opencode as a first-class usage source, on par with Claude and Codex — feeding the daily/today/monthly/weekly/session/top reports, the merged dashboard, per-project/model/source breakdowns, a
tu opencodesubcommand, and atu livetab.Why it's a bit different from the other sources
Claude and Codex write newline-delimited JSON logs that the existing streaming parser walks line by line. opencode instead stores usage in a SQLite database (
~/.local/share/opencode/opencode.db), so this PR adds a dedicated reader (src/pipeline/opencode.rs) that queries themessagetable read-only and produces the sameUsageEvents the rest of the pipeline already consumes. Everything downstream is source-generic and needed no changes.$XDG_DATA_HOMEand the$OPENCODE_DBoverride.input → input,cache.write → cache_creation,cache.read → cache_read,output + reasoning → output,reasoning → reasoning(matching opencode's own stats convention).Cost: estimated vs. logged
opencode records its own per-message cost, which matters because it's often used with custom/local models the built-in pricing table doesn't know. New flag
--opencode-cost <estimated|logged>(config mirroropencodeCost):estimated(default) — recompute from the pricing table, consistent with Claude/Codex.logged— trust opencode's recorded cost.New surface
tu opencode--no-opencode,--opencode-db <path>(repeatable),--opencode-cost <estimated|logged>tu live opencodenoOpencode,opencodeDb,opencodeCostConfigAPI gainsno_opencode/opencode_dbNotes for review
rusqlitewith thebundledfeature (no system SQLite lib required).sort_by→sort_by_key, redundant.into_iter()) that a newer stable clippy flags in unrelated code, so CI's@stableclippy step stays green. Happy to drop it if you'd rather keep the PR narrow.cargo fmt,cargo clippy -D warnings, and the full test suite pass (added: mapper unit tests, a fixture-DB reader test, and an end-to-end daily-report test).