# @oh-my-pi/omp-stats

> Local observability dashboard for pi AI usage statistics

Latest version **18.3.1** (published 2026-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @oh-my-pi/omp-stats
pnpm add @oh-my-pi/omp-stats
yarn add @oh-my-pi/omp-stats
bun add @oh-my-pi/omp-stats
```

Provides the command `omp-stats`.

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 18.3.1 |
| Published | 2026-09-25 |
| First published | 2026-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 10 |
| Unpacked size | 2.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28726 |
| Author | Stencil Labs, Inc. |
| Maintainers | can1357 |
| Keywords | ai, observability, metrics, dashboard, llm, statistics |

## Links

- npm: https://www.npmjs.com/package/@oh-my-pi/omp-stats
- Repository: https://github.com/can1357/oh-my-pi
- Homepage: https://omp.sh
- Issues: https://github.com/can1357/oh-my-pi/issues
- npm.io page: https://npm.io/package/@oh-my-pi/omp-stats

## Dependencies (10)

- [react](https://npm.io/package/react.md) 19.2.7
- [chart.js](https://npm.io/package/chart.js.md) ^4.5.1
- [react-dom](https://npm.io/package/react-dom.md) 19.2.7
- [tailwindcss](https://npm.io/package/tailwindcss.md) ^4.3.2
- [lucide-react](https://npm.io/package/lucide-react.md) ^1.24.0
- [@oh-my-pi/pi-ai](https://npm.io/package/@oh-my-pi/pi-ai.md) 18.3.1
- [react-chartjs-2](https://npm.io/package/react-chartjs-2.md) ^5.3.1
- [@tailwindcss/node](https://npm.io/package/@tailwindcss/node.md) ^4.3.2
- [@oh-my-pi/pi-utils](https://npm.io/package/@oh-my-pi/pi-utils.md) 18.3.1
- [@oh-my-pi/pi-catalog](https://npm.io/package/@oh-my-pi/pi-catalog.md) 18.3.1

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 18.3.1 (latest) — 2026-09-25
- 18.3.0 — 2026-09-24
- 18.2.11 — 2026-09-23
- 18.2.10 — 2026-09-22
- 18.2.9 — 2026-09-22
- 18.2.8 — 2026-09-21
- 18.2.7 — 2026-09-21
- 18.2.6 — 2026-09-18
- 18.2.5 — 2026-09-17
- 18.2.4 — 2026-09-17
- 18.2.3 — 2026-09-17
- 18.2.2 — 2026-09-16
- 18.2.1 — 2026-09-15
- 18.2.0 — 2026-09-15
- 18.1.22 — 2026-09-14
- … 528 more at https://npm.io/package/@oh-my-pi/omp-stats/versions

## README

# @oh-my-pi/omp-stats

Local observability dashboard for AI usage statistics.

## Features

- **Session log parsing**: Reads JSONL session logs from `~/.omp/agent/sessions/`
- **SQLite aggregation**: Efficient stats storage and querying using `bun:sqlite`
- **Web dashboard**: Real-time metrics visualization with Chart.js
- **Incremental sync**: Only processes new/modified log entries

## Metrics Tracked

| Metric | Calculation |
|--------|-------------|
| Tokens/s | `output_tokens / (duration / 1000)` |
| Cache Rate | `cache_read / (input + cache_read) * 100` |
| Cache Savings | `(uncached prompt cost - actual prompt cost) / uncached prompt cost * 100` |
| Error Rate | `count(stopReason=error) / total_calls * 100` |
| API-equivalent estimate | Sum of token usage priced with the matching public API rate card |
| Avg Latency | Mean of `duration` |
| TTFT | Mean of `ttft` (time to first token) |

Subscription-backed models use matching public API prices when an exact public model exists; these values estimate API-equivalent usage rather than the user's bill. Subscription-only models without a public price are reported as N/A and excluded from dollar totals.

## Usage

### Via CLI

```bash
# Start dashboard server (default: http://localhost:3847)
omp stats

# Custom port
omp stats --port 8080

# Print summary to console
omp stats --summary

# Output as JSON (for scripting)
omp stats --json
```

### Programmatic

```typescript
import { getDashboardStats, syncAllSessions } from "@oh-my-pi/omp-stats";

// Sync session logs to database
const { processed, files } = await syncAllSessions();

// Get aggregated stats
const stats = await getDashboardStats();
console.log(stats.overall.totalCost);
console.log(stats.byModel[0].avgTokensPerSecond);
```

## API Endpoints

| Endpoint | Description |
|----------|-------------|
| `GET /api/stats` | Overall stats with all breakdowns |
| `GET /api/stats/models` | Per-model statistics |
| `GET /api/stats/folders` | Per-folder/project statistics |
| `GET /api/stats/timeseries` | Hourly time series data |
| `GET /api/sync` | Trigger sync and return counts |

## Data Storage

- **Session logs**: `~/.omp/agent/sessions/` (JSONL files)
- **Stats database**: `~/.omp/stats.db` (SQLite)

## Dashboard

The web dashboard provides:

- Overall metrics cards (requests, API-equivalent estimate, cache rate, cache savings, error rate, duration, tokens/s)
- Time series chart showing requests and errors over time
- Per-model breakdown table
- Per-folder breakdown table
- Auto-refresh every 30 seconds

## License

MIT

---
_Source: https://npm.io/package/@oh-my-pi/omp-stats · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
