Local-first analytics over OpenCode session data. Read-only on opencode.db. Separate derived cache. No SaaS, no telemetry.
OpencodeView is an independent, unofficial companion for people who already run OpenCode locally. It is not part of OpenCode, not affiliated with the OpenCode team, and not a substitute for OpenCode's own product surface.
v0.9.0 is source-only. Clone and run with Bun. No npm package, binary, container, or installer. Treat APIs, cache schema, CLI flags, and env vars as unstable until 1.0.0.
UI preview (synthetic sample data)
<table>
<tr>
<td width="50%"><img src="docs/images/preview-live.png" alt="Live session tree with health and attention panels (synthetic)" /></td>
<td width="50%"><img src="docs/images/preview-overview.png" alt="Overview project rollups (synthetic)" /></td>
</tr>
<tr>
<td width="50%"><img src="docs/images/preview-efficiency.png" alt="Efficiency model mix and agent table (synthetic)" /></td>
<td width="50%"><img src="docs/images/preview-orchestration.png" alt="Orchestration routing and delegation tree (synthetic)" /></td>
</tr>
</table>
<p align="center"><sub>Synthetic documentation previews — not live user data. Projects, sessions, and metrics are fabricated.</sub></p>
OpenCode owns the agent runtime and the on-disk session store. OpencodeView only reads that store (and optional local logs), derives aggregates into its own cache file, and serves a local dashboard.
If something looks wrong in the source data, prefer investigating or reporting it in OpenCode when appropriate. Flags and quality hints here are local operator signals derived from rows on disk, not statements about OpenCode product quality.
Who this is for
You already run OpenCode locally and want answers like:
Which projects consume the most tokens and active time?
Which models/agents show high tool-error rates or low patch yield?
How deep or wide are subagent / delegation trees?
What sessions are in progress right now, without exporting transcripts by hand?
If you need a hosted multi-tenant product, an official OpenCode UI, or a versioned public contract against opencode.db, see Non-goals.
Why it exists
OpenCode already persists rich local history. OpencodeView turns that history into project-scoped analytics on your machine, without sending session data to a third party.
| Principle | Behavior |
|---|---|
| Local-first | Default bind is loopback. No telemetry. No outbound calls from the app. |
| Read-only source | opencode.db opens with readonly: true + PRAGMA query_only = 1. |
| Separate cache | Derived metrics live in OPENCODEVIEW_CACHE only. Never alias the source file. |
| Redact before leave | Transcript/live payloads are redacted server-side before JSON leaves the process. |
| Fail closed | Non-loopback bind without OPENCODEVIEW_AUTH_TOKEN refuses to start. |
Quick start
Requires Bun>= 1.3.0 and a local OpenCode DB (default ~/.local/share/opencode/opencode.db).
git clone https://github.com/4i3n6/opencodeview.git
cd opencodeview
bun install
cd web && bun install && cd ..
bun src/scan.ts --all # materialize cache from opencode.db
bun run serve # API -> http://127.0.0.1:4317
bun run web # UI -> http://127.0.0.1:5273 (proxies /api)
Override the source DB:
OPENCODE_DB=/path/to/opencode.db bun src/scan.ts --all
What you get
Overview — project/global rollups: tokens, active time, tool calls, flags
Optional Tailscale: bun run serve:tailscale (or web:tailscale) probes the local Tailscale CLI. If the tailnet is up, the API binds to the Tailscale IPv4 and requires a bearer token (auto-written to gitignored .cache/tailscale-auth-token when unset). If Tailscale is down, it stays on loopback.
Redaction (src/redaction.ts): secret-like keys, bearer tokens, common provider prefixes (sk-, ghp-, …), URL userinfo, absolute home paths → [REDACTED].
API responses: Cache-Control: no-store.
No telemetry / no outbound network from the app itself.
Exposing past loopback is an operator choice. Review redaction against your own data first. Prefer Tailscale over raw LAN bind.
Environment
| Variable | Default | Purpose |
|---|---|---|
| OPENCODE_DB | ~/.local/share/opencode/opencode.db | Source DB (RO) |
| OPENCODEVIEW_CACHE | <repo>/.cache/analytics.sqlite | Derived cache |
| OPENCODEVIEW_HOST | 127.0.0.1 | API bind; non-loopback needs auth token |
| OPENCODEVIEW_AUTH_TOKEN | unset | Bearer for non-loopback /api/* |
| OPENCODEVIEW_TAILSCALE | off | off | auto | on — auto-bind to Tailscale IPv4 when the CLI reports Running |
| PORT | 4317 | API port |
| OH_MY_OPENCODE_LOG | $TMPDIR/oh-my-opencode.log | Optional live activity tail |
Commands
| Command | What it does |
|---|---|
| bun src/scan.ts --list | Cheap project list |
| bun src/scan.ts <project> | Scan one project into cache |
| bun src/scan.ts --all | Scan everything |
| bun run serve | API on 127.0.0.1:4317 |
| bun run serve:tailscale | API; binds Tailscale IPv4 + bearer auth when tailnet is up |
| bun run web | UI on 127.0.0.1:5273 |
| bun run web:tailscale | API + UI on Tailscale IPv4 when available |
| bun run check | Full gate: test, typecheck, lint, build, audit, Gitleaks |
| bun run release:check | Release harness only |
Gitleaks is mandatory for bun run check (gitleaks on PATH or GITLEAKS_BIN).
Development
bun run check # before every PR
bun run test # root + web
bun run typecheck
bun run lint
bun run build
Hooks (Lefthook): Conventional Commits, staged Gitleaks, release harness, and exclusive GitHub identity 4i3n6 on maintainer push.
UI strings live in web/src/i18n (en-US + pt-BR). Protocol IDs, model/tool names, session IDs, raw flags, and tab IDs stay untranslated. Visual rules: DESIGN.md.
Non-goals
Replacing OpenCode or shipping an official OpenCode UI
Claiming affiliation with or endorsement by the OpenCode team
Cloud / multi-tenant hosted analytics
npm/registry distribution or installer (source-run only)
A stable, versioned integration contract against opencode.db before 1.0.0
Known limitations
opencode.db is an internal OpenCode implementation detail. The adapter is best-effort and may lag upstream schema changes.
cost is only comparable within the same billing regime; some auth modes report 0.
For sessions created in 2026-06 and 2026-07, summary_additions coverage in local data is incomplete; those sessions may be tagged data_quality_gap.
Sessions that used legacy edit/write tools (not apply_patch) do not populate apply_patch_* counters.
Expect breaking changes to cache schema, API, and CLI before 1.0.0.