[Feature Request]: add flag to see usage when using `opencode run`
Question
In the opnecode's interactive mode, the token usage and cost is shown on top right corner. Is there a way to get the same when running it in non-interactive mode such that at the end of execution it gives total cost and token usage?
@FarrukhCyber are you trying to see it in ci? Or what's the environment you are running it in, there may already be a way for you to do this using opencode export but that's prolly not ideal
I run opencode run <prompt> inside a python script
@FarrukhCyber would you like some flag on opencode run that would print usage to stdout or a file or something
yes ideally. Is this feature available?
Not yet :)
just wanted to confirm what you wanted
@rekram1-node I would be happy to implement this feature and open a PR. I'm not sure if this comes under core feature because contribution policy states that core feature requires a design review with the core team before implementation.
i think a pr would be good, I should reword that to not sound so strict.
Edit: ill just assign to u so ppl know u wanted to work on it
I also reworded the contributing guidelines to sound a little less "strict": https://github.com/sst/opencode/blob/dev/CONTRIBUTING.md#contributing-to-opencode
@rekram1-node Do you think this feature can be implemented using just a plugin?
We don't have a great way to indicate if the run is headless or not so Idk how the plugin would be able to surface it unless you just wanted to write it to a file
To confirm even if I provide the approx cost in a custom provider and model setup in my config, when running headless, there is no current method to have it output total tokens/cost at the end correct?
And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?
when running headless, there is no current method to have it output total tokens/cost at the end correct?
You can do --format json
And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?
If you are using an sdk you should have everything you need to get cost info