Skip to content
ecorealPublic

About

⏪ tape — time-travel debugger for AI agent sessions. Zero deps, reads the JSONL your agent already writes.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

36 Commits

Folders and files

Repository files navigation

tape — time-travel debugger for AI agent sessions

Your agent ran all night. Something broke at step 15. Which step was 15?

tape film — a 25-step agent session, replayable frame by frame ↑ a real 25-step debugging session, replayed by tape gif — every frame is a step, offline, no keys

CI npm License: MIT Dependencies Node Stars PRs Welcome

Zero dependencies · Zero config · Zero cloud. Reads the JSONL your agent already writes.


✨ Core Features

  • 📼 Time-travel scrubbing — j/k through every step of an agent session like a video editor; the detail pane shows exactly what the agent saw, including full tool output.
  • 🔌 Reads what you already have — Claude Code session files, OpenClaw / pi AgentSession JSONL, tape-native, and generic {role, content} lines. No SDK, no instrumentation, no re-running anything.
  • 🔍 Search across everything — one keystroke jumps to the first mention of that ECONNRESET you're hunting.
  • 🛡 Never crashes on your data — malformed lines are skipped and counted, never fatal. Real transcripts are messy; tape expects it.
  • 🤖 Headless mode — --frame N --plain renders any moment to stdout: scriptable, CI-friendly, and it's how every screenshot in this README was made (no image editor involved).
  • 🎞 tape gif — the session as an animated GIF that plays by itself: steps reveal one at a time, the current one is lit, and a ribbon underneath shows the shape of the whole run. Encoded by hand (GIF89a + LZW, zero deps), so it works offline and in CI.
  • 🪶 Zero runtime dependencies — ~20 KB of JavaScript. Nothing to audit, nothing to break, npx and go.

🧭 How It Works

flowchart LR
    subgraph files["📄 Sessions you already have"]
        A1["Claude Code<br/>~/.claude/projects/**/*.jsonl"]
        A2["tape-native<br/>JSONL"]
        A3["OpenClaw / pi<br/>AgentSession JSONL"]
        A4["generic<br/>{role, content}"]
    end
    R["🔌 adapters<br/>auto-sniff + tolerant parse"]
    M["🧠 core · unified Step model<br/>pure · testable · portable"]
    T["🖥 TUI timeline<br/>scrub · search · detail"]
    H["🤖 headless --frame<br/>CI · scripts · README shots"]
    F["⏪ fork N · deterministic re-run"]
    A1 --> R
    A2 --> R
    A3 --> R
    A4 --> R
    R --> M
    M --> T
    M --> H
    M -.->|"v0.5"| F
Loading

The core knows nothing about files, terminals, or networks — which is why frames render identically in a TTY, in CI, and in this README. (Adapter contract: docs/adapter-spec.md)

🚀 Quick Start (30 seconds, two commands)

npx tape-replay demo                    # ① writes a 25-step sample session (~1s)
npx tape-replay demo-session.jsonl      # ② opens the timeline — scrub with j/k

Point it at a real session instead:

tape ~/.claude/projects/<your-project>/<session>.jsonl

Sessions living elsewhere (OpenClaw / tape-native / generic dirs)? Point tape at them:

TAPE_SESSIONS_DIR=~/agent-sessions tape          # picker + grep scan there
tape grep ECONNRESET --root ~/agent-sessions     # …or pass --root per command
🖥 No TTY? (CI, scripts, piping)
tape demo-session.jsonl --frame 8 --plain   # render any moment to stdout
⚙ Scripting — --json everywhere

Every reporting command (stats, diff, grep, cache) takes --json: stable single-line JSON on stdout, nothing else on the pipe. Human output is unchanged without the flag, and errors always go to stderr with exit code 1 — so scripts can trust it:

tape stats session.jsonl --json | jq .cost        # 0.139
tape grep ECONNRESET --json | jq -r '.[].path'    # which sessions mention it
tape diff run-a.jsonl run-b.jsonl --json | jq .divergence
key action key action
↑/↓ j/k select step / search
J/K scroll detail g / G first / last
? help q quit

Also: tape stats [file] (cost/tokens summary), tape diff a.jsonl b.jsonl (where two runs split), tape adapters (which session formats tape reads — and how to add one), tape gif <file> (the session as an animated GIF), and tape <file> --follow — tail a session while the agent is still writing it.

🎞 tape gif — a session that plays itself

npx tape-replay gif demo-session.jsonl            # → demo-session.gif
npx tape-replay gif ses.jsonl --out run.gif --rows 8 --frames 60 --delay 6

Each frame reveals one more step, the current step is lit, and the ribbon at the bottom holds the shape of the entire session — you can see where the errors cluster before the caption says so. Everything is drawn from the session file: a hand-made 5×7 bitmap font (no font files to install), a 29-colour palette derived from the ANSI codes tape already emits, and a hand-written GIF89a/LZW encoder. Same input, same bytes, every time — the GIF is as reproducible as the replay.

flag default what it does
--out <file>.gif where to write
--rows 12 steps visible at once (the window scrolls)
--frames 48 animation length; long sessions are sampled evenly
--delay 8 centiseconds per frame
--width 800 canvas width in pixels
--scale 2 glyph scale (1 = 800px of 130 columns, 2 = 66 columns)
--no-diff off full frames every time instead of transparent deltas

Frames after the first are deltas: every pixel identical to the previous frame is written as transparent (GIF disposal 1), so the unchanged chrome — the border, the legend, the steps that already scrolled past — costs almost nothing. On a real session that is about half the file (--no-diff reproduces the naive output if you need it), and what you see is byte-for-byte the same.

📸 Showcase

Real output, no paint — the moment a test run fails (rendered by tape --frame 8 --plain):

⏪ tape examples/demo-session.jsonl 25 steps
┌──────────────────────────────────┬──────────────────────────────────────────┐
│  U The login page 500s intermit… │tool_result  2026-10-25 12:06:27          │
│  A I'll reproduce the failure f… │                                          │
│  T Read src/auth/session.ts      │> npm test -- tests/auth.test.js          │
│  R 14 | export async function r… │                                          │
│  T Read src/auth/login.ts        │  ✗ concurrent refresh keeps one session  │
│  R 31 | router.post('/login', a… │row (2 racing requests)                   │
│  A Suspicious: refreshSession r… │  ✗ token from refresh is usable on next  │
│  T Bash npm test -- tests/auth.… │request                                   │
│  R > npm test -- tests/auth.tes… │  ✗ login returns 200 under load          │
│  A 3 failures, all around concu… │  9 passed · 3 failed                     │
│  T Edit src/auth/session.ts (+1… │                                          │
│  T Bash npm test -- tests/auth.… │                                          │
│  ! fetch failed: ECONNRESET — t… │                                          │
│  A The DB container crashed mid… │                                          │
│  T Bash docker restart pg-test … │                                          │
│  R > npm test -- tests/auth.tes… │                                          │
│  A Root cause: token refresh ra… │                                          │
│  U nice. add a regression test … │                                          │
│  T Edit tests/auth.test.js (+31) │                                          │
└──────────────────────────────────┴──────────────────────────────────────────┘
↑↓ select · / search · ? help · q quit 9/25

📊 tape stats — what that session actually cost you

⏪ tape — stats  ~/.claude/projects/<project>/<session>.jsonl

steps        14  user 2 · tool_use 5 · tool_result 5 · assistant 2
duration     18m47s
cost         $0.139
tokens       in 52.9k · out 2.3k
models       z-ai/glm-5.3 (7)
top tools    Bash 4 · Read 1

activity     ▁▁▄▁▁▁▄█▁▁▁▄▆▁

(real output from a real session — every number was already sitting in the JSONL)

🆚 Why tape

today's options the pain
Langfuse / AgentOps SDK in your code, an account, sessions leave your machine
dashboard observability services to run, a web UI to click through for one question
less session.jsonl a wall of JSON — no timeline, no types, no search
--resume flags continues a session, can't inspect one

🗺 Roadmap

  • v0.5: tape fork + rerun ✅ shipped — tape fork <file> <N> branches a session ($EDITOR edit of step N when interactive), tape rerun continues it (echo provider offline, any OpenAI-compatible endpoint via TAPE_API_KEY). fork → rerun → diff is offline prompt A/B testing.
  • next: a --follow-style GIF that grows while the agent is still writing, and per-adapter film themes.

🤝 Contributing

Small, sharp PRs welcome — this codebase is deliberately tiny (~1.5k lines, zero deps) so you can hold it all in your head.

🏆 Best first PR: a session-format adapter (~20 lines). The contract is docs/adapter-spec.md — the unified Step model, the claude-code mapping table, tolerance rules, and a copy-paste golden-test recipe; tape adapters lists what's built in. src/parse.js (normalize()) remains the reference implementation. Bug reports with a redacted transcript that fails to parse are gold.

git clone https://github.com/ecoreal/tape && cd tape
npm test          # node:test — zero config

Issues labeled good first issue are pre-scoped. Be kind; we're all debugging agents at 2am.

🙏 Acknowledgments

  • git bisect and the Chrome DevTools Performance panel — the two great time-travel UIs tape humbly imitates.
  • Langfuse & AgentOps — they built the cloud version of this problem; tape exists for everyone who wants the local one.
  • Every terminal emulator that correctly renders ─ and │. You know who you are.

🧩 the nova suite

tape is part of a small family of zero-dependency terminal tools:

  • duel — ⚔️ your agents fight; every match is a replayable file
  • mogwai — 🐾 a pet whose brain is a git repo (mogwai feed --tape <session> eats this tool's sessions)
  • tape — ⏪ time-travel debugger for AI agent sessions

📄 License

MIT © 2026 tape contributors

About

⏪ tape — time-travel debugger for AI agent sessions. Zero deps, reads the JSONL your agent already writes.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages