https://github.com/manzil-infinity180/aflock-replay
Browser-based tool to replay Claude Code sessions against aflock policy
https://github.com/manzil-infinity180/aflock-replay
aflock agent claude claude-code
Last synced: 14 days ago
JSON representation
Browser-based tool to replay Claude Code sessions against aflock policy
- Host: GitHub
- URL: https://github.com/manzil-infinity180/aflock-replay
- Owner: manzil-infinity180
- Created: 2026-04-04T17:07:38.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-04T19:53:04.000Z (3 months ago)
- Last Synced: 2026-04-04T20:11:20.423Z (3 months ago)
- Topics: aflock, agent, claude, claude-code
- Language: HTML
- Homepage: https://manzil-infinity180.github.io/aflock-replay/
- Size: 53.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aflock replay
> **[Live Demo](https://manzil-infinity180.github.io/aflock-replay/)** — try it in your browser, no install needed
Browser-based tool to replay Claude Code sessions against [aflock](https://github.com/aflock-ai/aflock) policies. See what would be allowed or denied — action by action.
Uses the **real aflock policy evaluator** compiled to WebAssembly. Same Go code that runs in the CLI runs in your browser. 100% client-side — no data leaves your browser.
 
https://github.com/user-attachments/assets/406d5ac5-3099-4529-87ea-85437fb6c187
## How It Works
1. Drop a Claude Code session (`.jsonl`) and an aflock policy (`.aflock`)
2. Click **Play** or **Step** to advance through actions
3. Each tool call is evaluated against the policy
4. See **ALLOW** / **DENY** / **ASK** decisions with matched rules highlighted
5. Final report shows verdict, stats, and violations
The WASM binary contains aflock's actual `internal/policy` and `internal/replay` packages — not a reimplementation. When aflock's evaluator changes, rebuild the WASM and the UI picks it up.
## Quick Start
### Prerequisites
- **Go 1.23+** (to build the WASM module)
- **Python 3** (to serve static files, or use any HTTP server)
- **aflock repo** with the `wasm-implementation` branch
### Step 1: Clone both repos
```bash
# This repo
git clone https://github.com/manzil-infinity180/aflock-replay.git
# aflock with WASM support (wasm-implementation branch)
git clone -b wasm-implementation https://github.com/aflock-ai/aflock.git
```
### Step 2: Build the WASM module
```bash
cd aflock-replay
AFLOCK_REPO=../aflock make wasm
```
This compiles `aflock/cmd/wasm/main.go` to `web/static/replay.wasm` (~34 MB). The WASM binary is gitignored — you build it locally.
### Step 3: Run
```bash
make dev
# → http://localhost:8080
```
That's it. Open the browser, drop in files, replay.
### One-command version
```bash
make run # builds WASM + starts server
```
## Standalone Mode (No WASM, No Build)
If you don't want to build the WASM, there's a standalone JS version with a client-side policy evaluator (approximate, not the real Go code):
```bash
make standalone
# → http://localhost:8080
# Or just open the file directly:
open standalone/index.html
```
## Project Structure
```
aflock-replay/
├── web/ # WASM version (primary)
│ ├── index.html # Landing page + replay UI
│ ├── docs/ # Documentation
│ │ └── index.html
│ └── static/
│ ├── app.js # Frontend JavaScript
│ ├── replay.wasm # Built from aflock (gitignored)
│ └── wasm_exec.js # Go WASM runtime
├── standalone/ # JS-only fallback
│ └── index.html # Self-contained, no WASM needed
├── cmd/server/main.go # Optional Go HTTP server
├── Makefile
├── go.mod
└── README.md
```
## How the WASM Works
The WASM binary is built from [`aflock/cmd/wasm/main.go`](https://github.com/aflock-ai/aflock/blob/wasm-implementation/cmd/wasm/main.go) which lives inside the aflock module. This is the only way to access Go's `internal/` packages.
It registers these JavaScript globals:
| Function | Purpose |
|----------|---------|
| `aflockReplay(sessionJSONL, policyJSON)` | Full replay — returns JSON report |
| `aflockParseSession(sessionJSONL)` | Parse session metadata |
| `aflockEvaluateAction(tool, input, policy, root)` | Evaluate single action |
| `aflockVersion()` | Module version |
The browser loads `wasm_exec.js` (Go's WASM runtime), instantiates `replay.wasm`, and calls these functions. All evaluation happens client-side.
```
Browser → wasm_exec.js → replay.wasm → internal/replay.Run() → JSON report
```
## Rebuilding WASM
When aflock's evaluator changes:
```bash
cd aflock && git pull
cd ../aflock-replay && make wasm
```
The `.wasm` file is ~34 MB (Go runtime included). With gzip (nginx/Cloudflare), ~8 MB over the wire.
## Evaluation Modes
| Mode | Command | Evaluator | Privacy | Accuracy |
|------|---------|-----------|---------|----------|
| **WASM** | `make dev` | Real Go code in browser | 100% client-side | Exact |
| **Standalone JS** | `make standalone` | JS port | 100% client-side | Approximate |
| **Go Server** | `make go-server` | Calls `aflock replay` CLI | Server-side | Exact |
## Finding Session Files
Claude Code sessions live at:
```bash
~/.claude/projects//.jsonl
# List recent sessions:
ls -lt ~/.claude/projects/*/*.jsonl | head -5
```
## Configuration
```bash
AFLOCK_REPO=../aflock make wasm # Custom aflock repo path
PORT=3000 make dev # Custom port
```
## Demo
[](https://www.youtube.com/watch?v=Og6NHoKF3DU)
[Watch the demo on YouTube](https://www.youtube.com/watch?v=Og6NHoKF3DU)
## Inspiration
- [claude-replay](https://es617.dev/claude-replay/) — Interactive HTML replays for Claude Code sessions. The step-by-step playback UI, block-level animation, and keyboard-driven navigation in aflock-replay are inspired by this project. We adapted the concept to overlay policy enforcement decisions on each action.
## Related
- [aflock](https://github.com/aflock-ai/aflock) — Cryptographically signed policies for constrained AI agent execution
- [aflock-tui](https://github.com/aflock-ai/aflock-tui) — Terminal UI for browsing sessions, attestations, and JWTs
- [claude-replay](https://es617.dev/claude-replay/) — Interactive HTML replays for Claude Code sessions (inspiration for the turn-based conversation UI)
- [awesome-agent-runtime-security](https://github.com/bureado/awesome-agent-runtime-security) — aflock is listed here
## License
MIT