@dev4s/opencode-command-stats
v0.1.1
Published
OpenCode plugin that tracks usage statistics for user-defined commands
Downloads
9
Readme
OpenCode Command Stats
An OpenCode plugin that tracks usage statistics for user-defined commands.
Features
- Tracks how many times each command is used
- Records the last time each command was executed
- Excludes built-in OpenCode commands by default (configurable)
- Optional debug logging with date-based rotation
- View statistics via
stats-commandstool
Installation
Add to ~/.config/opencode/opencode.json:
{
"plugin": ["@dev4s/opencode-command-stats"]
}Then restart OpenCode.
Usage
Once installed, the plugin automatically tracks command usage. To view statistics, run the stats-commands tool.
Example Output
| Command | Uses | Last Used |
|--------------|------|------------|
| deploy | 42 | 2025-01-09 |
| run-tests | 15 | 2025-01-08 |
| format-code | 3 | 2025-01-05 |Configuration
The plugin creates a configuration file at:
~/.config/opencode/command-stats-config.json
Default Configuration
{
"excludeCommands": [
"init", "review",
"read", "write", "edit", "multiedit",
"glob", "grep", "bash", "task",
"todowrite", "todoread",
"webfetch", "websearch", "codesearch",
"skill", "question",
"stats-commands"
],
"debug": true
}Options
| Option | Type | Default | Description |
| ----------------- | ---------- | ------- | ------------------------------------------------ |
| excludeCommands | string[] | (above) | Commands to exclude from tracking |
| debug | boolean | true | Enable debug logging (set to false to disable) |
Data Storage
| Path | Purpose |
| ------------------------------------------------------- | ---------------------- |
| ~/.config/opencode/command-stats-config.json | Plugin configuration |
| ~/.local/state/opencode/command-stats.json | Usage statistics |
| ~/.config/opencode/logs/command-stats-YYYY-MM-DD.log | Debug logs (if enabled)|
Stats Data Format
{
"command-name": {
"count": 5,
"lastUsed": "2025-01-09"
}
}License
UNLICENSED
