|
| 1 | +# Claude Code Instructions for openadapt-viewer |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +HTML visualization generators for training dashboards, benchmark results, and capture playback. Generates standalone HTML files that can be opened in any browser. |
| 6 | + |
| 7 | +## Quick Start |
| 8 | + |
| 9 | +```bash |
| 10 | +# Install |
| 11 | +uv sync |
| 12 | + |
| 13 | +# Generate demo benchmark viewer |
| 14 | +uv run openadapt-viewer demo --tasks 5 --output viewer.html |
| 15 | + |
| 16 | +# Open in browser |
| 17 | +open viewer.html |
| 18 | +``` |
| 19 | + |
| 20 | +## CLI Commands |
| 21 | + |
| 22 | +| Command | Description | |
| 23 | +|---------|-------------| |
| 24 | +| `demo` | Generate demo viewer with sample data | |
| 25 | +| `benchmark` | Generate viewer from benchmark results | |
| 26 | + |
| 27 | +## Key Files |
| 28 | + |
| 29 | +- `viewers/benchmark/generator.py` - Main HTML generator |
| 30 | +- `viewers/benchmark/data.py` - Data models (BenchmarkRun, TaskExecution) |
| 31 | +- `viewers/benchmark/templates/` - Jinja2 templates |
| 32 | +- `__main__.py` - CLI entry point |
| 33 | + |
| 34 | +## Architecture |
| 35 | + |
| 36 | +``` |
| 37 | +openadapt_viewer/ |
| 38 | +├── viewers/ |
| 39 | +│ └── benchmark/ |
| 40 | +│ ├── generator.py # generate_benchmark_html() |
| 41 | +│ ├── data.py # BenchmarkRun, TaskExecution, ExecutionStep |
| 42 | +│ └── templates/ |
| 43 | +│ └── benchmark.html.j2 |
| 44 | +├── __init__.py |
| 45 | +└── __main__.py # CLI |
| 46 | +``` |
| 47 | + |
| 48 | +## HTML Features |
| 49 | + |
| 50 | +The generated viewer includes: |
| 51 | +- Summary statistics (pass/fail, success rate) |
| 52 | +- Domain breakdown charts |
| 53 | +- Task list with filtering |
| 54 | +- Step-by-step screenshot playback |
| 55 | +- Playback controls (prev/next, play/pause, speed) |
| 56 | +- Keyboard shortcuts |
| 57 | + |
| 58 | +## Integration |
| 59 | + |
| 60 | +Used by openadapt-ml and openadapt-evals to visualize results: |
| 61 | + |
| 62 | +```python |
| 63 | +from openadapt_viewer import generate_benchmark_html, BenchmarkRun |
| 64 | + |
| 65 | +run = BenchmarkRun.from_results(results) |
| 66 | +html = generate_benchmark_html(run, embed_screenshots=True) |
| 67 | +Path("results.html").write_text(html) |
| 68 | +``` |
| 69 | + |
| 70 | +## Development |
| 71 | + |
| 72 | +```bash |
| 73 | +# Run tests (when added) |
| 74 | +uv run pytest tests/ -v |
| 75 | + |
| 76 | +# Check imports |
| 77 | +uv run python -c "from openadapt_viewer import generate_benchmark_html; print('OK')" |
| 78 | +``` |
0 commit comments