Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish to npm

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- run: bun install --frozen-lockfile

- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,37 @@ Tracks token usage, costs, model selection, and agent activity across sessions.

## Installation

```bash
git clone https://github.com/sleipi/opencode-usage-stats.git
cd opencode-usage-stats
bun install
Add the plugin to your `opencode.json`:

```json
{
"plugin": ["@sleipi/opencode-usage-stats"]
}
```

### Symlink into OpenCode plugins
Restart OpenCode to load the plugin. The plugin starts tracking immediately.

### Manual installation (alternative)

```bash
git clone https://github.com/sleipi/opencode-usage-stats-plugin.git
cd opencode-usage-stats-plugin
bun install
ln -s "$(pwd)/src/plugin.ts" ~/.config/opencode/plugins/opencode-usage-stats.ts
ln -s "$(pwd)/src/dashboard.ts" ~/.config/opencode/plugins/usage-stats-dashboard.ts
```

Restart OpenCode to load the plugin. The plugin starts tracking immediately.

## Dashboard

Start the dashboard manually:
Start the dashboard:

```bash
bun run dashboard
bunx @sleipi/opencode-usage-stats
```

Use a custom port if 3333 is already occupied by OpenCode itself:
Or with a custom port (default is 3333):

```bash
PORT=3334 bun run dashboard
PORT=3334 bunx @sleipi/opencode-usage-stats
```

Opens at [http://localhost:3333](http://localhost:3333).
Expand Down
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## Completed

- [x] Publish as npm package (`@sleipi/opencode-usage-stats`) with bin entrypoint for dashboard
- [x] Refactor dashboard into SOLID modules with DI, separated templates, services, and routes
- [x] Refactor plugin hook processing into explicit interfaces and focused handlers (SOLID)
- [x] Introduce Playwright end-to-end tests for dashboard rendering and stats endpoint
Expand Down
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
{
"name": "opencode-usage-stats",
"name": "@sleipi/opencode-usage-stats",
"version": "0.1.0",
"description": "Usage statistics tracking and dashboard for OpenCode",
"type": "module",
"main": "./src/plugin.ts",
"exports": {
".": "./src/plugin.ts"
},
"bin": {
"opencode-usage-stats": "./src/dashboard.ts"
},
"files": [
"src/"
],
"repository": {
"type": "git",
"url": "https://github.com/sleipi/opencode-usage-stats-plugin.git"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"dashboard": "bun --watch run src/dashboard.ts",
"check": "biome check .",
Expand Down