-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Open
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussionUsed for feature requests, proposals, ideas, etc. Open discussion
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Feature Request
It would be great to be able to run opencode stats --format json and receive json output for the stats (essentially the SessionStats object).
Why?
This would be extremely helpful for anyone who wants to use their opencode stats to build their own custom dashboards for tracking token usage, cost, etc. This is actually what I was in the process of doing until I took a step back and thought "man, it would be really great if I could just get the stats in a json object instead of having to query the sqlite db".
Suggested Implementation
If this feature sounds worth it to the OpenCode team, I'd love to make my first contribution and open a PR for it. I was thinking of adding a couple of new flags to opencode stats:
--format(choices:asciiorjson, defaults toasciiwhich displays the current table output)- Allows the user to select an output format for the stats
--pretty(boolean)- If output format is
json, this option will pretty-print the json with indentations of 2 spaces
- If output format is
Example output:

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussionUsed for feature requests, proposals, ideas, etc. Open discussion