Skip to main content

A comprehensive tool to analyze opencode logs and provide insights into development activity

Project description

Opencode Analyzer

A comprehensive Python tool to analyze opencode logs and provide insights into development activity, patterns, and productivity metrics.

Features

  • Session Analysis: Parse and reconstruct session timelines with full message history
  • Tool Usage Statistics: Track tool frequency, distribution, and success rates
  • Token Usage Analytics: Monitor input, output, and reasoning token consumption across models
  • Content Theme Analysis: Identify themes, keywords, and patterns in development work
  • Activity Patterns: Analyze hourly, daily, and weekly activity trends
  • Progress Tracking: Track project evolution with trend analysis and milestone detection
  • Error Analysis: Detect tool errors and debugging session patterns
  • Search & Discovery: Full-text search across all prompts and responses
  • Multiple Output Formats: Rich terminal tables, JSON, Markdown, and CSV
  • Interactive CLI: Feature-rich command-line interface with 7 commands

Requirements

  • Python 3.13+
  • uv package manager

Installation

cd /path/to/opencode_analyzer
uv sync

Usage

Commands

# Show summary dashboard of all sessions
uv run opencode-analyzer overview

# List all sessions in reverse chronological order
uv run opencode-analyzer list

# Deep dive into a specific session
uv run opencode-analyzer analyze <session-id>

# Search through prompts and responses
uv run opencode-analyzer search "<query>"

# Generate time-based reports
uv run opencode-analyzer report --period today|week|month|all

# Show detailed statistics and metrics
uv run opencode-analyzer stats

# Output all JSON data for a session
uv run opencode-analyzer cat <session-id>

Global Options

All commands support these options:

Option Description
--format Output format: table (default), json, or markdown
--verbose / -v Enable verbose output for debugging
--opencode-dir Custom opencode data directory (default: ~/.local/share/opencode)

Examples

# Overview with JSON output
uv run opencode-analyzer overview --format json

# Search with markdown output
uv run opencode-analyzer search "error handling" --format markdown

# Generate weekly report
uv run opencode-analyzer report --period week

# Analyze session with verbose output
uv run opencode-analyzer analyze abc123 --verbose

# Use custom data directory
uv run opencode-analyzer stats --opencode-dir /path/to/opencode

Project Structure

opencode_analyzer/
├── src/opencode_analyzer/
│   ├── __init__.py        # Package initialization
│   ├── cli.py             # Rich CLI interface (7 commands)
│   ├── data_parser.py     # Data parsing with caching
│   ├── analyzer.py        # Core analysis engines
│   ├── reporter.py        # Multi-format report generation
│   └── utils.py           # 40+ utility functions
├── tests/
│   ├── conftest.py        # Pytest fixtures
│   ├── unit/              # Component-specific tests
│   │   ├── test_data_parser.py
│   │   ├── test_analyzer.py
│   │   ├── test_cli.py
│   │   └── test_utils.py
│   └── integration/
│       └── test_end_to_end.py
├── pyproject.toml         # Project configuration
└── uv.lock                # Dependency lock file

Data Source

This tool analyzes opencode data stored in ~/.local/share/opencode/:

Directory Contents
log/ Timestamped service log files (.log)
storage/message/ Session messages organized by session ID
storage/part/ Message parts (reasoning, text, tool calls)

Analysis Capabilities

Session Metrics

  • Total sessions, messages, and average metrics
  • Model usage distribution
  • Project correlation
  • Time span and duration calculations

Tool Analysis

  • Tool frequency and usage distribution
  • Success and error rates per tool
  • Sessions with specific tool patterns

Content Analysis

  • Keyword extraction (top words and bigrams)
  • Theme identification in prompts
  • Response pattern analysis
  • Reasoning content extraction

Activity Analysis

  • Hourly, daily, weekly breakdowns
  • Peak activity identification
  • Session length distribution
  • Productivity metrics

Progress Tracking

  • Timeline reconstruction
  • Cumulative metrics tracking
  • Trend analysis (increasing/decreasing)
  • Milestone identification

Dependencies

Core

  • click - CLI framework
  • rich - Terminal formatting and display
  • orjson - Fast JSON parsing
  • jsonschema - JSON validation
  • python-dateutil - Date/time utilities
  • pytz - Timezone support

Development

  • pytest - Test framework
  • pytest-cov - Coverage reporting
  • pytest-mock - Mocking utilities

Development

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=src/opencode_analyzer

# Run specific test file
uv run pytest tests/unit/test_data_parser.py

# Run integration tests
uv run pytest tests/integration/

Performance

  • Caching: LRU cache for message parsing (max 1000 items)
  • Parallel Processing: ThreadPoolExecutor for session parsing (up to 4 workers)
  • Fast JSON: Uses orjson for optimized JSON parsing
  • Streaming: Handles large datasets efficiently

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencode_analyzer-0.1.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencode_analyzer-0.1.0-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file opencode_analyzer-0.1.0.tar.gz.

File metadata

  • Download URL: opencode_analyzer-0.1.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for opencode_analyzer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 09e3e7e008c1d54357aafe32584167e6f02eb66106827b3fae9a7e35a253e20f
MD5 bb4e94b257698aed4c9adf93ee7f6541
BLAKE2b-256 24729c65435db900d0c4e5eaa1c43605db2e93047010769060ae0cacf973de4d

See more details on using hashes here.

File details

Details for the file opencode_analyzer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opencode_analyzer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for opencode_analyzer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d69764141cf0c48e3cec8314bc790b9064c3aedc6b7188b066d43dea64201b1f
MD5 9d60db89b56a656d000c41628a302f2c
BLAKE2b-256 0b56f57866aa2defa960fc58dc37b4cb038dda2ad467cac9f226f72dc312974f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page