openode_session_extractor — Extract agent conversations from OpenCode SQLite database.
Install
pip install openode_session_extractor
Usage
from openode_session_extractor import export_session_json, export_session_markdown, export_session_html
# Export a session to JSON
export_session_json("/path/to/opencode.db", "session_id", "output.json")
# Export to Markdown
export_session_markdown("/path/to/opencode.db", "session_id", "output.md")
# Export to HTML
export_session_html("/path/to/opencode.db", "session_id", "output.html")
CLI
# List available sessions
openode_session_extractor --list
# Search sessions
openode_session_extractor --list --search "my project"
# Export a specific session to all formats
openode_session_extractor --session SESSION_ID --output-dir ./exports
# Export all sessions to Markdown only
openode_session_extractor --all --format markdown --output-dir ./exports
# Use custom database path
openode_session_extractor --db /path/to/custom.db --list
API
Core Functions
compute_file_hash(filepath: str) -> str- Compute SHA-256 hash of a filecompute_content_hash(content: str) -> str- Compute SHA-256 hash of string contentwrite_if_changed(output_path: str, content: str) -> bool- Write file only if content changed (hash-based collision detection)
Database Functions
get_sessions(db_path: str, limit: Optional[int], search: Optional[str]) -> List[dict]- Fetch sessions from databaseget_messages(db_path: str, session_id: str) -> List[dict]- Fetch messages for a sessionget_parts(db_path: str, message_id: str) -> List[dict]- Fetch parts for a message
Export Functions
export_session_json(db_path: str, session_id: str, output_path: str) -> bool- Export to JSONexport_session_markdown(db_path: str, session_id: str, output_path: str) -> bool- Export to Markdownexport_session_html(db_path: str, session_id: str, output_path: str) -> bool- Export to HTML
Formatting Functions
format_time(timestamp_ms: int) -> str- Convert millisecond timestamp to readable dateformat_part(part_data: dict) -> str- Format a message part based on its type
Development
git clone https://github.com/daedalus/openode_session_extractor.git
cd openode_session_extractor
pip install -e ".[test]"
# run tests
pytest
# format
ruff format src/ tests/
# lint + type check (prospector runs ruff check + mypy together)
prospector --with-tool ruff --with-tool mypy src/
semgrep --config=auto --severity=ERROR src/
Metadata
Release files for opencode-session-extractor 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opencode_session_extractor-0.1.0.tar.gz | 9.6 kB | With provenance | Details for opencode_session_extractor-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opencode_session_extractor-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for opencode_session_extractor-0.1.0-py3-none-any.whl |
Total release size: 23.4 kB
Release files / opencode_session_extractor-0.1.0.tar.gz
| Download URL | opencode_session_extractor-0.1.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
393cba53fc56a639c49be5363f5dfb909f7b4440fb28ae9fb4dc297e24750edf
|
|
BLAKE2b-256 checksum How to use checksums |
3267b7a2a5da3c1c722ba8b987a3eaf3e41972b656bb860b96012c07e9d7225f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 5, 2026.
Transparency logRelease files / opencode_session_extractor-0.1.0-py3-none-any.whl
| Download URL | opencode_session_extractor-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a8fb9235c4c26d524df6f7f343aaa115d33aab61bfe9b5f99b28f42234d96fd
|
|
BLAKE2b-256 checksum How to use checksums |
9d8379619e4bb7ee8d8bf1935b3456f639625859b0746504694b3620671a7cd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 5, 2026.
Transparency logSecurity for opencode-session-extractor 0.1.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.
Attestation for opencode_session_extractor-0.1.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 May 5, 2026.
Transparency logA 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.