Skip to main content

opencode-db

Python License

CLI for OpenCode's local database. OpenCode saves every agent session, conversation, token usage, and cost in a local SQLite file. This tool lets you inspect, export, analyze, and clean up that data.

pip install opencode-db

# recommended if your system python3 is older than 3.12:
uv tool install opencode-db

Quick start

opencode-db --version    # installed version
opencode-db list         # recent sessions
opencode-db directories  # launch directories, including missing ones
opencode-db view         # interactive session viewer (colored, scrollable)
opencode-db stats        # database summary
opencode-db health       # SQLite storage health (read-only)
opencode-db backup       # managed, verified snapshot
opencode-db backups list # inspect snapshots
opencode-db schema       # detect v1/v2 schema
opencode-db costs --total  # total token costs
opencode-db export       # export dialog to .md (interactive)
opencode-db help         # full reference

Features

  • view — просмотр сессии в терминале с ANSI-цветами, Markdown-рендерингом и прокруткой через less
  • list / info / search / tree — навигация и поиск по сессиям
  • directories (dirs) — все директории запусков, включая отсутствующие; list --directory добавляет путь к сессии
  • export — экспорт диалога в Markdown (с поддержкой Obsidian)
  • delete / prune — удаление и массовая очистка с фильтрами; prune --missing-directories — защищённая очистка сессий из отсутствующих путей
  • costs / stats — аналитика токенов и расходов
  • health — read-only отчёт о freelist, WAL, auto_vacuum, оценке reclaimable space и свежести backup
  • backup / backups — управляемые снимки с manifest, sha256, gzip, verify и retention; --from-backup открывает снимок read-only
  • vacuum — безопасная оптимизация: lock check, backup, integrity check и сохранение WAL
  • schema — определяет v1/v2-схему OpenCode, миграции и доступные операции
  • --db-path / OPENCODE_DB — кастомный путь к БД
  • --from-backup — read-only работа с управляемым снимком (.db или .db.gz)

Optional extras

pip install opencode-db[rich]   # enhanced Markdown rendering (recommended)
pip install opencode-db         # zero external dependencies

Requirements

  • Python 3.12+ — the CLI checks the interpreter at startup and exits with a clear message instead of an ImportError on older versions
  • OpenCode (must have been run at least once)
  • macOS / Linux

Directory support: global is a synthetic project for non-Git directories; directories shows the real session.directory and marks it as Global (no project root). Missing paths are detected with os.path.isdir() at command runtime and can be filtered with --missing.

Schema support: OpenCode 1.19.x (v1) — read and write; OpenCode 2.x preview (v2) — read-only. Run opencode-db schema to check the detected schema. On v2, health and the read-only commands work; delete, prune, and vacuum are refused until write support is implemented.

Metadata

Release files for opencode-db 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencode-db 0.11.0
File Size Uploaded Provenance Actions
opencode_db-0.11.0.tar.gz 103.6 kB With provenance Details for opencode_db-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opencode-db 0.11.0
File Interpreter ABI Platform Actions
opencode_db-0.11.0-py3-none-any.whl Python 3 none any Details for opencode_db-0.11.0-py3-none-any.whl

Total release size: 194.8 kB

Release files / opencode_db-0.11.0.tar.gz

Download URL opencode_db-0.11.0.tar.gz
Size 103.6 kB
Tags Source
SHA-256 checksum
How to use checksums
818f5ca27bd6dab223bd9082c8b607c1fe31bd550e90eb549354ddc7625adccf
BLAKE2b-256 checksum
How to use checksums
ac1539f1fbfe231f18a31c94d2c888903b4dbb6e1267898639a4b71dbee183e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / opencode_db-0.11.0-py3-none-any.whl

Download URL opencode_db-0.11.0-py3-none-any.whl
Size 91.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e68f8e6f6642eea1f011a92a5905e602f608374442fa192e756bbe28778293cd
BLAKE2b-256 checksum
How to use checksums
b80d7123610d00845e8b2e9a33f41e67bf2dc0088b58f817216cf27b46a36b66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for opencode-db 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opencode_db-0.11.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page