ocinsights
v0.1.2
Published
opencode plugin for session analytics — track tokens, tools, costs across all your sessions
Maintainers
Readme
ocinsights
opencode plugin that automatically syncs every session to your ocinsights dashboard — track tokens, tools, MCP usage, and cost across all your AI sessions.
Install
npm i -g ocinsights
ocinsights setupYou'll be asked for two things:
- Insights API URL — where your ocinsights frontend is running (default
http://localhost:3001). - API key — get it from the ocinsights dashboard (Settings → API key).
The CLI then:
- copies the plugin to
.opencode/plugins/ocinsights.js - writes
OC_INSIGHTS_API_KEYandOC_INSIGHTS_API_BASEto.env
Restart opencode and you're done — every session is synced on session.idle.
Non-interactive mode
ocinsights setup --api-key=oc_xxx --api-base=http://localhost:3001Other commands
ocinsights import # batch import existing sessions from running opencode server
ocinsights helpManual install (without the CLI)
If you prefer to wire it up by hand:
Install the package as a dev dependency:
npm i -D ocinsightsAdd it to your
opencode.json:{ "plugin": ["ocinsights"] }Add to
.env:OC_INSIGHTS_API_KEY=oc_xxx OC_INSIGHTS_API_BASE=http://localhost:3001Restart opencode.
How it works
When a session goes idle, the plugin:
- reads all messages + tool calls from opencode
- aggregates tokens (input, output, cache read/write, reasoning)
- POSTs the session to
{OC_INSIGHTS_API_BASE}/api/sync
Your dashboard then shows the session with full token breakdown, tool usage, MCP servers, and cost.
Local development
git clone https://github.com/anomalyco/opencode-ai-insights
cd opencode-ai-insights
npm install
npm run buildThe plugin will be at dist/index.js. To test locally without publishing, copy it into your project's .opencode/plugins/ and restart opencode.
License
MIT
