--- name: enliven description: Make an Electron or web app measurably faster without losing a feature, and prove it. The agent builds a repeatable A/B harness that drives the real production build through Playwright and reads Chromium's own counters over the DevTools protocol, finds the cause of the cost with a Blink style-invalidation trace and a React commit probe instead of guessing, fixes root causes, re-measures the same way, and writes a self-contained HTML report that shows the regressions as loudly as the wins. Use when the user asks to profile, speed up, slim down, find memory leaks in, or benchmark before and after on a desktop or web app, or asks for a performance report. --- # Enliven Turns "make the app fast" into a number you can defend. The output is three things: root causes named at `file:line`, a harness anyone can re-run, and an HTML report whose every figure comes from a JSON file the harness wrote. It is distilled from a real Electron audit where the first two attempts failed independent review. Every rule below is a mistake that got caught. Follow them up front and skip those rounds. `ensoul` gives a product a soul, `immune-system` keeps it well, and this one makes it lively: an app that answers the instant you touch it and carries no weight it does not need. Same construction as `ensoul`, same idea one step further in: not what it looks like, but how alive it feels to use, proved with numbers rather than asserted. The shape of the work is one loop: **measure → find the cause → fix the cause → measure the same way → report honestly**. Never skip a step, never reorder, and never let the report get ahead of the data. ## The short path The scripts in `scripts/` are the audit already written down. Do not rebuild them from scratch; the exploration is what took the time, and it is already spent. ```sh cp scripts/profile.example.mjs perf-profile.mjs # fill in: entry, selectors, phases, cycle node scripts/perf-ab.mjs --profile=./perf-profile.mjs --app= --label=before --out=./perf node scripts/style-trace.mjs --profile=./perf-profile.mjs --app= --phase= # fix what the trace names, rebuild from a purged output directory node scripts/perf-ab.mjs --profile=./perf-profile.mjs --app= --label=after --out=./perf node scripts/perf-report.mjs --before=./perf/before.json --after=./perf/after.json \ --changes=./perf/changes.json --out=./perf/report.html ``` Writing `perf-profile.mjs` is the only real work: name the phases people actually perform, and make the leak cycle end where it began. Read [reference/traps.md](reference/traps.md) first, in full. Every line in it cost a failed review. These scripts have been run end to end against a real Electron build, not just written: a five-phase profile produced boot timings, per-phase CDP counters, a three-cycle leak series with flat node counts, and an HTML page. On that run the orphan count came back at 866 files and 43 MB, which was correct: the output directory had accumulated stale chunks from earlier builds. Purge it before you trust any bundle number, exactly as Phase 4 says. The phases below explain why each script does what it does. Read them when something does not fit your app, not before your first run. ## Phase 1: Build the harness before you look at any code The first instinct is to open a profiler and start reading flame graphs. Resist it. A flame graph of one run on a busy laptop tells you nothing you can defend later. Build the measuring instrument first, and make it produce a JSON file. One script, checked into the repo, that takes `--app= --label= --out= --repeats=N` and writes `