Metadata-Version: 2.5
Name: agent-reel
Version: 0.1.0
Summary: Replay, scrub and share AI coding agent sessions as a single self-contained HTML file.
License: MIT
License-File: LICENSE
Keywords: agents,ai,claude-code,debugging,llm,replay
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# agent-replay

**Replay, scrub and share AI coding-agent sessions as one self-contained HTML file.**

```bash
# install once (the PyPI package is called agent-reel; the command is agent-replay)
uv tool install agent-reel          # or: pipx install agent-reel / pip install agent-reel

agent-replay latest                 # replay your most recent Claude Code session
agent-replay <session-id> -o replay.html
agent-replay --list                 # recent Claude Code, Codex and Cursor sessions (10 each; --limit N)
agent-replay cursor:latest          # your latest Cursor chat
agent-replay codex:latest           # your latest Codex CLI session
agent-replay <session-id> --fork-at 42 -o context.md   # export steps 1-42 as Markdown

# or run without installing
uvx --from agent-reel agent-replay latest
```

![agent-replay demo: scrubbing through a session, filtering to Edit calls, forking from a step](docs/demo.gif)

The demo is a fully synthetic session: [`examples/demo-session.jsonl`](examples/demo-session.jsonl)
(regenerate with `python examples/make_demo_session.py`). Try the real viewer on it with
`agent-replay examples/demo-session.jsonl --open`, or open the rendered
[`docs/index.html`](docs/index.html) (GitHub Pages: serve the `/docs` folder).

## Why

Agent runs are long, opaque and hard to share. `agent-replay` turns a session log into a
single HTML file you can open anywhere, attach to a PR, or post in a thread: no server, no
account, no network calls.

## Features (v0.1)

- **Timeline + scrubber**: prompts, replies, thinking, tool calls and results; play, step, or drag
- **File diffs** for every `Edit` / `MultiEdit` / `Write`, colored inline
- **Summary header**: duration, prompts, tool calls, files touched, lines +/−, tokens, errors
- **Fork from here**: pick any step and export the conversation up to it as Markdown context you can paste into a
  new agent session (button in the viewer, or `--fork-at N` on the CLI)
- **Filter chips** per event type and tool (Edit, Write, Bash, …), color-coded; navigation skips hidden events
- **Idle-gap markers**: long pauses (resumed sessions) show as "⏸ 3 days later" and don't inflate timestamps
- **Search** across the whole session; keyboard nav (`←/→`, `j/k`, `space`, `Home/End`)
- **Secret redaction on by default**: API keys, tokens, private keys, URL credentials, `*_PASSWORD=` style
  assignments and high-entropy strings are masked
- **Zero dependencies**, light/dark theme, works fully offline

## Privacy

Cursor's database also holds your login tokens. agent-replay opens it read-only and only reads
`composerData:` / `bubbleId:` keys (a test enforces this).

Sessions contain your code, prompts and sometimes secrets. Redaction is best-effort, not a guarantee:
**skim a replay before sharing it publicly.** Use `--no-redact` only for your own eyes.

## Supported agents

| Agent | Status |
|---|---|
| Claude Code (`~/.claude/projects/**/*.jsonl`) | ✅ |
| Aider (`.aider.chat.history.md`) | ✅ `agent-replay path/to/repo`. Edits are rebuilt from SEARCH/REPLACE blocks; the log has no per-message timestamps or token counts |
| Codex CLI (`~/.codex` rollout files) | ✅ `agent-replay codex:latest`, or `codex:<id>` from `--list` (also found via `$CODEX_HOME`). `apply_patch` becomes Edit/Write/Delete with diffs, shell calls become Bash. Built from the documented rollout format; not yet verified against many real sessions, so please open an issue if one renders wrongly |
| Cursor (chat database `state.vscdb`) | ✅ `agent-replay cursor:latest`, or `cursor:<id>` from `--list`. Read-only; only chat keys are read. Tool names are normalized (Read/Edit/Bash/…). Subagent chats are followed: their steps appear under the `Agent` call, tagged `subagent` (and left out of `--fork-at` context) |
| Codex CLI, … | 🙋 contributions welcome, see below |

Claude Code's log format isn't a stable API, so the parser is lenient and skips what it
doesn't understand. If a new version breaks something, please open an issue with an anonymized sample.

## Architecture

```
logs ──▶ parsers/<agent>.py ──▶ Session/Event (models.py) ──▶ redact ──▶ analyze ──▶ render ──▶ .html
```

Only `parsers/` knows about a specific agent. To add one, write a module that returns a
`Session` and register it in `parsers/__init__.py`.

## Development

```bash
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -q && ruff check .
```

## Roadmap

- [x] Fork-from-step: export the conversation up to step N as Markdown context
- [ ] Run-vs-run diff
- [x] Aider
- [x] Cursor
- [x] Codex CLI
- [ ] More agents (Gemini CLI, Copilot CLI)
- [ ] Live tailing of a running session

## Contributing

Re-record the demo GIF with `python scripts/make_demo_gif.py docs/index.html docs/demo.gif`
(needs `pip install playwright pillow && playwright install chromium`).

## License

MIT
