Statin
opencode plugin: event telemetry with JSONL log and per-session statistics
0
389
近 7 天 32
35.7
生态多维模型
10 天前
2026-09-25
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-statin@0.2.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-statin@0.2.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-statinOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Telemetry for your opencode sessions. opencode-statin records every event the
opencode runtime emits — with timestamps — to a JSONL log and keeps per-session
statistics: messages by role, parts by type, tool calls and durations,
compactions, idle periods, tokens, cost, system-prompt size, and the models in
play. Two slash commands surface it: /statin for a session summary and
/statin-events for the most recent events plus the log path.
It is read-only: it observes, it never injects anything into a session and never tells the model what to do.
Install
opencode plugin opencode-statin -g
Restart opencode to load the plugin.
opencode plugin only installs the module and adds it to your plugin config —
it does not copy command files out of the package. So also register the two
slash commands by copying the bundled files into your global commands directory:
cp ~/.cache/opencode/node_modules/opencode-statin/commands/*.md ~/.config/opencode/commands/
From a repo checkout, use cp commands/*.md ~/.config/opencode/commands/
instead. opencode scans both command/ and commands/, in the global config
directory and in a project's .opencode/. As an alternative to files, you can
declare the commands inline under the command key of opencode.json.
Usage
| Command | Effect |
|---|---|
/statin |
Session statistics: messages, parts, tools, tokens, cost, ... |
/statin-events |
The last 40 recorded events and the path to the JSONL log |
Configure
Create ~/.config/opencode/statin.json (a legacy opencode-statin.json in the
same directory is also read):
{
"logDir": "~/.config/opencode/statin",
"maxLogBytes": 5242880,
"ringSize": 5000,
"logPartUpdated": false,
"eventLog": false,
"usageTtlDays": 7
}
| Field | Default | Description |
|---|---|---|
logDir |
~/.config/opencode/statin |
Directory for usage.json (and events.jsonl when eventLog is on) |
maxLogBytes |
5242880 (5 MiB) |
Rotate to events.jsonl.1 once the log grows past this size |
ringSize |
5000 |
In-memory ring buffer of recent events |
logPartUpdated |
false |
Also log message.part.updated (very noisy — streaming deltas) |
eventLog |
false |
Write the event telemetry log. Off by default since 0.2.0 |
usageTtlDays |
7 |
Prune usage.json entries not touched for this many days |
Usage tracking
Independently of the event log, the plugin counts read and grep tool calls
and persists them to usage.json (same logDir). Each entry is
tool:argument -> { count, first, last }, keyed by project (the working
directory's basename), so the file can be kept per-machine and compared across
machines. read paths are stored relative to the project root — use the counts
to spot documentation gaps (files the agent keeps having to read, classes it
keeps grepping for) and describe them in docs instead. Entries are pruned after
usageTtlDays of inactivity. /statin-events shows the top entries and the
file path.
Privacy
events.jsonl (when enabled) and usage.json contain event payload summaries and
tool arguments, including fragments of your conversations (titles, message
roles, token counts, tool names, file paths, grep patterns). Treat them as
sensitive data and keep them out of version control and shared backups.
Development
npm install
npm run typecheck
npm test
License
MIT
同类生态推荐
Headsup
@banburist/opencode-headsup
Live inference telemetry pinned to the OpenCode 2 sidebar.
Visual Cache
opencode-visual-cache
OpenCode TUI plugin displaying real-time token cache hit rate in the sidebar
Tokenmeter Tui
opencode-tokenmeter-tui
OpenCode TUI plugin: TokenMeter sidebar — live token usage, cost, and delegation tree for sessions