@phil65/demoreel 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -12
- package/dist/args.js +14 -0
- package/dist/cli.js +22 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/mcp.d.ts +5 -0
- package/dist/mcp.js +441 -0
- package/dist/sheet.d.ts +6 -0
- package/dist/sheet.js +10 -0
- package/package.json +7 -1
- package/skills/demoreel/SKILL.md +161 -0
package/README.md
CHANGED
|
@@ -61,18 +61,21 @@ npx demoreel doctor # checks Chromium, ffmpeg, GPU, framesheet
|
|
|
61
61
|
|
|
62
62
|
```
|
|
63
63
|
demoreel run <scenario.ts|js> record, write project, render MP4, contact sheet
|
|
64
|
-
--out DIR --no-render --dry-run --state FILE --fps 30 --quality medium|good|source
|
|
64
|
+
--out DIR --no-render --gif --dry-run --state FILE --fps 30 --quality medium|good|source
|
|
65
65
|
--[no-]gpu --trim-idle --speed 1.5 --viewport 1280x720 --headed -n 12 --framesheet auto|off
|
|
66
66
|
demoreel inspect <url|scenario> ARIA snapshot (+ optional --screenshot) of a page or scenario end state
|
|
67
67
|
--screenshot FILE --state FILE --viewport 1280x800 --headed
|
|
68
68
|
demoreel login <url> sign in in headed Chromium and save storageState (default .demoreel/auth.json)
|
|
69
69
|
--state FILE --viewport 1280x800
|
|
70
70
|
demoreel render <project.openscreen> [--out FILE.mp4 --fps --quality --[no-]gpu]
|
|
71
|
-
demoreel rezoom <outdir> re-derive zooms / idle cuts / marks from timeline.json
|
|
71
|
+
demoreel rezoom <outdir> re-derive zooms / idle cuts / keycaps / marks from timeline.json
|
|
72
72
|
--max-depth 4 --lead 350 --hold 800 --no-auto-zoom --options JSON
|
|
73
|
-
--trim-idle --idle-options '{"minMs":1500,"keepMs":600,"mode":"speed"}' --render
|
|
73
|
+
--trim-idle --idle-options '{"minMs":1500,"keepMs":600,"mode":"speed"}' --show-keys --render
|
|
74
74
|
demoreel validate <project> OpenScreen's validateProjectData / normalizeProjectEditor
|
|
75
75
|
demoreel sheet <video|outdir> framesheet inspect --marks marks.json, else ffmpeg tiles
|
|
76
|
+
demoreel frame <video|outdir> <sec> [--out FILE.png] extract one full-res PNG frame for review
|
|
77
|
+
demoreel gif <video|outdir> [--out FILE.gif --width 960 --fps 12] two-pass palette README GIF
|
|
78
|
+
demoreel mcp start the official MCP server over stdio
|
|
76
79
|
demoreel init [dir] [--url URL] [--js] scaffold a scenario (+ a demo app to record)
|
|
77
80
|
demoreel doctor environment check
|
|
78
81
|
```
|
|
@@ -94,15 +97,17 @@ Each run writes into `out/<name>/`:
|
|
|
94
97
|
| --- | --- |
|
|
95
98
|
| `goto(url)` | navigate (the first call starts the recording) |
|
|
96
99
|
| `click(target, { zoom, label, navigates })` | eased cursor travel, aim, click; zooms by default |
|
|
100
|
+
| `select(target, value, { zoom, label })` | move to a `<select>` and pick an option cleanly |
|
|
101
|
+
| `drag(from, to \| { dx, dy }, { duration, zoom })` | 60 Hz cursor-tracked drag (3D canvases, sliders, drag-and-drop) |
|
|
97
102
|
| `type(target, text, { clear, zoom })` | click into a field and type with human-ish timing |
|
|
98
103
|
| `hover(target, { dwell, zoom })` | move there and rest (no zoom unless asked) |
|
|
99
104
|
| `moveTo(target \| {x, y})` | move the cursor, nothing else |
|
|
100
105
|
| `scroll(target \| { by: px })` | smooth scroll (the page's or the target's scroll container) |
|
|
101
|
-
| `press(key)` | keyboard shortcut
|
|
106
|
+
| `press(key, { show, duration })` | keyboard shortcut (Playwright syntax); optional keycap HUD pill |
|
|
102
107
|
| `pause(ms)` | wait |
|
|
103
108
|
| `caption(text, { duration, wait })` | caption overlay (an OpenScreen text annotation, sharp at any zoom) |
|
|
104
|
-
| `zoom(target, { depth, duration, context, wait })` | explicit zoom
|
|
105
|
-
| `highlight(target, { duration, color, zoom })` | outline
|
|
109
|
+
| `zoom(target, { depth, duration, context, wait })` | explicit zoom (integer tier `1..6`: 1.25x..5x) overriding auto zooms |
|
|
110
|
+
| `highlight(target, { duration, color, dim, badge, zoom })` | outline with optional spotlight dim backdrop and callout badge |
|
|
106
111
|
|
|
107
112
|
`target` is a structured accessibility-first spec (`{ role, name?, exact?, nth? }`,
|
|
108
113
|
`{ label, exact?, nth? }`, `{ placeholder, exact?, nth? }`, `{ text, exact?, nth? }`,
|
|
@@ -116,11 +121,13 @@ up), `serve` (static dir served at `ctx.baseUrl`), `storageState` (Playwright st
|
|
|
116
121
|
JSON, relative to the scenario file), `colorScheme`, `seed`, `pacing`
|
|
117
122
|
(`speed`, `beforeAction`, `afterClick`, `typeDelay`, ...), `zoom` (see below), `look`
|
|
118
123
|
(`wallpaper`, `padding`, `borderRadius`, `shadowIntensity`, `aspectRatio`,
|
|
119
|
-
`captionPosition`), `
|
|
124
|
+
`captionPosition`, `showKeys`), `cursor` (`size`, `clickBounce`, `smoothing`, `motionBlur`,
|
|
125
|
+
`show`), `clickRipple`, `trimIdle` (`true` or `{ minMs, keepMs, mode, speed, ignoreFrames }`).
|
|
120
126
|
|
|
121
127
|
Library: `recordScenario`, `dryRunScenario`, `resolveStorageState`, `deriveZoomRegions`,
|
|
122
128
|
`deriveIdleRegions`, `buildProject`, `buildCursorData`, `buildMarks`, `renderProject`,
|
|
123
|
-
`validateProject`, `rezoom`, `reviewSheet`,
|
|
129
|
+
`validateProject`, `rezoom`, `reviewSheet`, `extractFrame`, `exportGif`, `createMcpServer`,
|
|
130
|
+
all typed (`dist/index.d.ts`).
|
|
124
131
|
|
|
125
132
|
### Inspect before you script
|
|
126
133
|
|
|
@@ -182,14 +189,42 @@ to the scenario file; `--state` overrides it relative to cwd). Add `.demoreel/`
|
|
|
182
189
|
- **Captions** sit at the bottom unless that would cover a target active at the time; then
|
|
183
190
|
they move to the top (`look.captionPosition: "auto"`, or force `"top"` / `"bottom"`).
|
|
184
191
|
|
|
185
|
-
## Agent loop
|
|
192
|
+
## Agent loop & MCP server
|
|
186
193
|
|
|
187
194
|
`timeline.json` + `marks.json` make the output checkable without watching the video:
|
|
188
195
|
`demoreel sheet out/<name>` runs `framesheet inspect <video> --marks marks.json` (framesheet
|
|
189
196
|
on PATH, in `node_modules`, or via `uvx framesheet`) which draws clicks, targets, zooms and
|
|
190
|
-
captions onto the tiles and flags e.g. captions covering a target.
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
captions onto the tiles and flags e.g. captions covering a target. Use `demoreel frame out/<name> 12.5`
|
|
198
|
+
to pull a single full-resolution PNG when inspecting dense UI, and iterate with `demoreel rezoom`
|
|
199
|
+
(no re-recording) and `demoreel render`.
|
|
200
|
+
|
|
201
|
+
### MCP server (Claude Desktop, Cursor, Antigravity, Contexter, etc.)
|
|
202
|
+
|
|
203
|
+
demoreel ships an official MCP server (`@modelcontextprotocol/server`) over stdio that returns
|
|
204
|
+
inline PNG screenshots, contact sheets, and full-res frames plus live render progress notifications:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"mcpServers": {
|
|
209
|
+
"demoreel": {
|
|
210
|
+
"command": "npx",
|
|
211
|
+
"args": ["-y", "@phil65/demoreel", "mcp"]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Tools exposed: `doctor`, `inspect_page`, `dry_run_scenario`, `run_scenario`, `rezoom`,
|
|
218
|
+
`inspect_frame`, and `export_gif`.
|
|
219
|
+
|
|
220
|
+
### Agent skill
|
|
221
|
+
|
|
222
|
+
Install the bundled skill ([skills/demoreel/SKILL.md](skills/demoreel/SKILL.md)) into Claude Code,
|
|
223
|
+
Cursor, Codex, or Antigravity:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npx skills add phil65/demoreel
|
|
227
|
+
```
|
|
193
228
|
|
|
194
229
|
## Limitations
|
|
195
230
|
|
package/dist/args.js
CHANGED
|
@@ -89,6 +89,20 @@ export const COMMANDS = {
|
|
|
89
89
|
width: { type: "number", value: "PX", description: "GIF width in px, height auto (default 960; 0 = source)" },
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
|
+
frame: {
|
|
93
|
+
usage: "frame <video.mp4|outdir> <seconds>",
|
|
94
|
+
description: "extract a single full-resolution PNG frame at a timestamp (for checking dense UI)",
|
|
95
|
+
positionals: { min: 2, max: 2 },
|
|
96
|
+
flags: {
|
|
97
|
+
out: { type: "string", alias: "o", value: "FILE", description: "output PNG path (default: next to the MP4)" },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
mcp: {
|
|
101
|
+
usage: "mcp",
|
|
102
|
+
description: "start the demoreel MCP server over stdio (for Cursor, Claude, Antigravity, etc.)",
|
|
103
|
+
positionals: { min: 0, max: 0 },
|
|
104
|
+
flags: {},
|
|
105
|
+
},
|
|
92
106
|
inspect: {
|
|
93
107
|
usage: "inspect <url|scenario.ts|js>",
|
|
94
108
|
description: "print a page's ARIA snapshot (or dry-run a scenario and inspect its end state)",
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import { loadScenario } from "./load.js";
|
|
|
12
12
|
import { PACKAGE_ROOT } from "./openscreen.js";
|
|
13
13
|
import { dryRunScenario, recordScenario, resolveStorageState } from "./record.js";
|
|
14
14
|
import { renderProject, validateProject } from "./render.js";
|
|
15
|
-
import { findFramesheet, reviewSheet } from "./sheet.js";
|
|
15
|
+
import { extractFrame, findFramesheet, reviewSheet } from "./sheet.js";
|
|
16
16
|
const fmt = (ms) => `${(ms / 1000).toFixed(1)}s`;
|
|
17
17
|
const log = (msg) => console.error(msg);
|
|
18
18
|
function progressPrinter(enabled) {
|
|
@@ -223,6 +223,25 @@ async function cmdGif({ positionals, flags }) {
|
|
|
223
223
|
log(`gif: ${g.outputPath} (${(g.bytes / 1e6).toFixed(1)} MB, ${g.width || "source"}px @ ${g.fps}fps)`);
|
|
224
224
|
console.log(g.outputPath);
|
|
225
225
|
}
|
|
226
|
+
async function cmdFrame({ positionals, flags }) {
|
|
227
|
+
let target = path.resolve(positionals[0]);
|
|
228
|
+
if (fs.existsSync(target) && fs.statSync(target).isDirectory()) {
|
|
229
|
+
const tl = readTimeline(target);
|
|
230
|
+
target = path.join(target, tl.files?.video ?? `${tl.scenario}.mp4`);
|
|
231
|
+
}
|
|
232
|
+
if (!fs.existsSync(target))
|
|
233
|
+
throw new DemoreelError(`video not found: ${target}`, "render it first: demoreel render <project>");
|
|
234
|
+
const seconds = Number(positionals[1]);
|
|
235
|
+
if (!Number.isFinite(seconds) || seconds < 0)
|
|
236
|
+
throw new UsageError(`invalid timestamp: ${positionals[1]} (expected seconds >= 0)`);
|
|
237
|
+
const f = await extractFrame(target, seconds, flags.out ? path.resolve(String(flags.out)) : undefined);
|
|
238
|
+
log(`frame @ ${f.seconds.toFixed(2)}s / ${f.duration.toFixed(2)}s -> ${f.outPng}`);
|
|
239
|
+
console.log(f.outPng);
|
|
240
|
+
}
|
|
241
|
+
async function cmdMcp() {
|
|
242
|
+
const { runMcpServer } = await import("./mcp.js");
|
|
243
|
+
await runMcpServer();
|
|
244
|
+
}
|
|
226
245
|
async function cmdLogin({ positionals, flags }) {
|
|
227
246
|
const url = positionals[0];
|
|
228
247
|
const statePath = path.resolve(String(flags.state ?? path.join(".demoreel", "auth.json")));
|
|
@@ -461,6 +480,8 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
461
480
|
validate: cmdValidate,
|
|
462
481
|
sheet: cmdSheet,
|
|
463
482
|
gif: cmdGif,
|
|
483
|
+
frame: cmdFrame,
|
|
484
|
+
mcp: cmdMcp,
|
|
464
485
|
inspect: cmdInspect,
|
|
465
486
|
login: cmdLogin,
|
|
466
487
|
init: cmdInit,
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export { buildMarks, type Marks, type MarkPoint, type MarkRegion, type MarkSpan,
|
|
|
9
9
|
export { stageLayout, type StageLayout } from "./layout.ts";
|
|
10
10
|
export { compose, rezoom, readTimeline, type Timeline, TIMELINE_VERSION } from "./compose.ts";
|
|
11
11
|
export { type CursorStyle, type RenderOptions, type RenderResult, renderProject, type ValidationResult, validateProject } from "./render.ts";
|
|
12
|
-
export { contactSheet, findFramesheet, reviewSheet, type SheetOptions, type SheetResult } from "./sheet.ts";
|
|
12
|
+
export { contactSheet, extractFrame, findFramesheet, reviewSheet, type SheetOptions, type SheetResult } from "./sheet.ts";
|
|
13
|
+
export { createMcpServer, runMcpServer } from "./mcp.ts";
|
|
13
14
|
export { DemoreelError, detectGpu, type GpuMode, type GpuProbe } from "./env.ts";
|
|
14
15
|
export { loadScenario } from "./load.ts";
|
|
15
16
|
export type * from "./types.ts";
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { buildMarks } from "./marks.js";
|
|
|
9
9
|
export { stageLayout } from "./layout.js";
|
|
10
10
|
export { compose, rezoom, readTimeline, TIMELINE_VERSION } from "./compose.js";
|
|
11
11
|
export { renderProject, validateProject } from "./render.js";
|
|
12
|
-
export { contactSheet, findFramesheet, reviewSheet } from "./sheet.js";
|
|
12
|
+
export { contactSheet, extractFrame, findFramesheet, reviewSheet } from "./sheet.js";
|
|
13
|
+
export { createMcpServer, runMcpServer } from "./mcp.js";
|
|
13
14
|
export { DemoreelError, detectGpu } from "./env.js";
|
|
14
15
|
export { loadScenario } from "./load.js";
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
/** Creates a configured demoreel `McpServer` instance (connect to stdio or any MCP transport). */
|
|
3
|
+
export declare function createMcpServer(): McpServer;
|
|
4
|
+
/** Starts the demoreel MCP server over stdio. */
|
|
5
|
+
export declare function runMcpServer(): Promise<void>;
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official MCP server for demoreel (`demoreel mcp`, stdio transport).
|
|
3
|
+
*
|
|
4
|
+
* Exposes the full inspect -> dry-run -> record/render -> contact-sheet -> frame-check -> rezoom -> gif
|
|
5
|
+
* loop with inline PNG images and live `notifications/progress` updates during renders.
|
|
6
|
+
*/
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
11
|
+
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { parseSize } from "./args.js";
|
|
14
|
+
import { readTimeline, rezoom } from "./compose.js";
|
|
15
|
+
import { checkFfmpeg, detectGpu, launchChromium } from "./env.js";
|
|
16
|
+
import { exportGif } from "./gif.js";
|
|
17
|
+
import { loadScenario } from "./load.js";
|
|
18
|
+
import { dryRunScenario, recordScenario, resolveStorageState } from "./record.js";
|
|
19
|
+
import { renderProject, validateProject } from "./render.js";
|
|
20
|
+
import { extractFrame, findFramesheet, reviewSheet } from "./sheet.js";
|
|
21
|
+
function pngBlock(filePath) {
|
|
22
|
+
if (!fs.existsSync(filePath))
|
|
23
|
+
return null;
|
|
24
|
+
return { type: "image", data: fs.readFileSync(filePath).toString("base64"), mimeType: "image/png" };
|
|
25
|
+
}
|
|
26
|
+
function resolveVideoTarget(targetPath) {
|
|
27
|
+
const p = path.resolve(targetPath);
|
|
28
|
+
if (fs.existsSync(p) && fs.statSync(p).isDirectory()) {
|
|
29
|
+
const tl = readTimeline(p);
|
|
30
|
+
return {
|
|
31
|
+
videoPath: path.join(p, tl.files?.video ?? `${tl.scenario}.mp4`),
|
|
32
|
+
marksPath: path.join(p, tl.files?.marks ?? "marks.json"),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return { videoPath: p, marksPath: path.join(path.dirname(p), "marks.json") };
|
|
36
|
+
}
|
|
37
|
+
function readPackageVersion() {
|
|
38
|
+
try {
|
|
39
|
+
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
40
|
+
return pkg.version ?? "0.0.0";
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return "0.0.0";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function makeProgressNotifier(ctx) {
|
|
47
|
+
const token = ctx.mcpReq?._meta?.progressToken;
|
|
48
|
+
const notify = ctx.mcpReq?.notify;
|
|
49
|
+
let lastSent = -1;
|
|
50
|
+
return (progress, message) => {
|
|
51
|
+
if (token === undefined || !notify)
|
|
52
|
+
return;
|
|
53
|
+
const pct = Math.min(100, Math.max(0, Math.round(progress)));
|
|
54
|
+
if (pct === lastSent && !message)
|
|
55
|
+
return;
|
|
56
|
+
lastSent = pct;
|
|
57
|
+
void notify({
|
|
58
|
+
method: "notifications/progress",
|
|
59
|
+
params: { progressToken: token, progress: pct, total: 100, ...(message ? { message } : {}) },
|
|
60
|
+
}).catch(() => { });
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const logStderr = (msg) => console.error(msg);
|
|
64
|
+
/** Creates a configured demoreel `McpServer` instance (connect to stdio or any MCP transport). */
|
|
65
|
+
export function createMcpServer() {
|
|
66
|
+
const server = new McpServer({ name: "demoreel", version: readPackageVersion() }, {
|
|
67
|
+
instructions: "demoreel records scripted Playwright product demos with smooth cursor motion, auto-zoom, captions, keycap HUDs, and OpenScreen MP4/GIF rendering. Follow the loop: inspect_page -> write scenario -> dry_run_scenario -> run_scenario -> inspect contact sheet (and inspect_frame for dense UI) -> rezoom or refine.",
|
|
68
|
+
});
|
|
69
|
+
server.registerTool("doctor", {
|
|
70
|
+
title: "Check demoreel environment",
|
|
71
|
+
description: "Checks Chromium, ffmpeg, hardware GPU acceleration, and framesheet availability.",
|
|
72
|
+
inputSchema: z.object({}),
|
|
73
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
74
|
+
}, async () => {
|
|
75
|
+
let chromium = "missing";
|
|
76
|
+
try {
|
|
77
|
+
const b = await launchChromium();
|
|
78
|
+
chromium = b.version();
|
|
79
|
+
await b.close();
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
chromium = `error: ${e.message.split("\n")[0]}`;
|
|
83
|
+
}
|
|
84
|
+
let ffmpeg = "ok";
|
|
85
|
+
try {
|
|
86
|
+
checkFfmpeg();
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
ffmpeg = `error: ${e.message.split("\n")[0]}`;
|
|
90
|
+
}
|
|
91
|
+
const gpu = await detectGpu();
|
|
92
|
+
const fsCmd = findFramesheet();
|
|
93
|
+
const info = {
|
|
94
|
+
version: readPackageVersion(),
|
|
95
|
+
node: process.version,
|
|
96
|
+
platform: process.platform,
|
|
97
|
+
chromium,
|
|
98
|
+
ffmpeg,
|
|
99
|
+
gpu,
|
|
100
|
+
framesheet: fsCmd ? `${fsCmd.cmd} ${fsCmd.args.join(" ")}`.trim() : null,
|
|
101
|
+
};
|
|
102
|
+
return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
|
|
103
|
+
});
|
|
104
|
+
server.registerTool("inspect_page", {
|
|
105
|
+
title: "Inspect a URL or scenario end state",
|
|
106
|
+
description: "Returns the ARIA accessibility snapshot (YAML tree) and an optional inline PNG screenshot of a URL, or dry-runs a scenario file and inspects its end/failure state.",
|
|
107
|
+
inputSchema: z.object({
|
|
108
|
+
target: z.string().describe("HTTP(S) URL or path to a *.scenario.ts/.mts/.mjs file."),
|
|
109
|
+
screenshot: z.boolean().optional().default(true).describe("Return an inline PNG screenshot (default true)."),
|
|
110
|
+
viewport: z.string().optional().describe("Optional WxH viewport override, e.g. '1280x800'."),
|
|
111
|
+
state: z.string().optional().describe("Optional Playwright storageState JSON file path."),
|
|
112
|
+
}),
|
|
113
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
114
|
+
}, async ({ target, screenshot, viewport, state }) => {
|
|
115
|
+
const isUrl = /^https?:\/\//i.test(target);
|
|
116
|
+
let aria = "";
|
|
117
|
+
let summary = "";
|
|
118
|
+
const tmpPng = screenshot ? path.join(os.tmpdir(), `demoreel-inspect-${Date.now()}.png`) : null;
|
|
119
|
+
try {
|
|
120
|
+
if (isUrl) {
|
|
121
|
+
const vp = viewport ? parseSize(viewport) : { width: 1280, height: 800 };
|
|
122
|
+
const storageState = resolveStorageState(state);
|
|
123
|
+
const browser = await launchChromium();
|
|
124
|
+
try {
|
|
125
|
+
const ctx = await browser.newContext({ viewport: vp, ...(storageState ? { storageState } : {}) });
|
|
126
|
+
const page = await ctx.newPage();
|
|
127
|
+
await page.goto(target, { waitUntil: "load" });
|
|
128
|
+
aria = await page.locator("body").ariaSnapshot();
|
|
129
|
+
if (tmpPng)
|
|
130
|
+
await page.screenshot({ path: tmpPng });
|
|
131
|
+
summary = `Inspected URL ${target} (${vp.width}x${vp.height})`;
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
await browser.close().catch(() => { });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const file = path.resolve(target);
|
|
139
|
+
const scenario = await loadScenario(file);
|
|
140
|
+
const overrides = {};
|
|
141
|
+
if (viewport)
|
|
142
|
+
overrides.viewport = parseSize(viewport);
|
|
143
|
+
const res = await dryRunScenario(scenario, {
|
|
144
|
+
scenarioFile: file,
|
|
145
|
+
overrides,
|
|
146
|
+
storageState: state,
|
|
147
|
+
atEnd: async (page) => {
|
|
148
|
+
aria = await page.locator("body").ariaSnapshot();
|
|
149
|
+
if (tmpPng)
|
|
150
|
+
await page.screenshot({ path: tmpPng });
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
summary = res.ok
|
|
154
|
+
? `Dry-run "${scenario.name}": ${res.actions.length} actions ok (${(res.durationMs / 1000).toFixed(1)}s)`
|
|
155
|
+
: `Dry-run "${scenario.name}" FAILED at action #${res.error?.actionIndex}: ${res.error?.message}`;
|
|
156
|
+
}
|
|
157
|
+
const content = [{ type: "text", text: `${summary}\n\n${aria}` }];
|
|
158
|
+
if (tmpPng) {
|
|
159
|
+
const img = pngBlock(tmpPng);
|
|
160
|
+
if (img)
|
|
161
|
+
content.push(img);
|
|
162
|
+
}
|
|
163
|
+
return { content };
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
if (tmpPng && fs.existsSync(tmpPng))
|
|
167
|
+
fs.rmSync(tmpPng, { force: true });
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
server.registerTool("dry_run_scenario", {
|
|
171
|
+
title: "Dry-run a scenario",
|
|
172
|
+
description: "Runs a scenario in fast mode (no sleeps, no ffmpeg, no output files) to verify every selector and action in seconds. On failure, includes the ARIA snapshot and failure screenshot.",
|
|
173
|
+
inputSchema: z.object({
|
|
174
|
+
scenarioPath: z.string().describe("Path to the scenario file (*.scenario.ts/.mts/.mjs)."),
|
|
175
|
+
viewport: z.string().optional().describe("Optional WxH viewport override."),
|
|
176
|
+
state: z.string().optional().describe("Optional Playwright storageState JSON file path."),
|
|
177
|
+
}),
|
|
178
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
179
|
+
}, async ({ scenarioPath, viewport, state }) => {
|
|
180
|
+
const file = path.resolve(scenarioPath);
|
|
181
|
+
const scenario = await loadScenario(file);
|
|
182
|
+
const overrides = {};
|
|
183
|
+
if (viewport)
|
|
184
|
+
overrides.viewport = parseSize(viewport);
|
|
185
|
+
let failureAria = "";
|
|
186
|
+
const tmpPng = path.join(os.tmpdir(), `demoreel-fail-${Date.now()}.png`);
|
|
187
|
+
try {
|
|
188
|
+
const res = await dryRunScenario(scenario, {
|
|
189
|
+
scenarioFile: file,
|
|
190
|
+
overrides,
|
|
191
|
+
storageState: state,
|
|
192
|
+
onFailure: async (_err, page) => {
|
|
193
|
+
failureAria = await page.locator("body").ariaSnapshot().catch(() => "");
|
|
194
|
+
await page.screenshot({ path: tmpPng }).catch(() => { });
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
const lines = res.actions.map((a, i) => `${i}: ok ${a.kind}${a.label ? ` ${a.label}` : ""}`);
|
|
198
|
+
if (!res.ok && res.error) {
|
|
199
|
+
lines.push(`FAIL action #${res.error.actionIndex}: ${res.error.message}`);
|
|
200
|
+
if (failureAria)
|
|
201
|
+
lines.push("", "ARIA at failure:", failureAria);
|
|
202
|
+
const content = [{ type: "text", text: lines.join("\n") }];
|
|
203
|
+
const img = pngBlock(tmpPng);
|
|
204
|
+
if (img)
|
|
205
|
+
content.push(img);
|
|
206
|
+
return { isError: true, content };
|
|
207
|
+
}
|
|
208
|
+
lines.push(`dry-run "${scenario.name}": ${res.actions.length} actions ok (${(res.durationMs / 1000).toFixed(1)}s)`);
|
|
209
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
if (fs.existsSync(tmpPng))
|
|
213
|
+
fs.rmSync(tmpPng, { force: true });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
server.registerTool("run_scenario", {
|
|
217
|
+
title: "Record and render a demo video",
|
|
218
|
+
description: "Records a scenario, writes the OpenScreen project + timeline.json + marks.json, renders the MP4 (and optional GIF), builds the contact sheet, and returns the sheet PNG inline.",
|
|
219
|
+
inputSchema: z.object({
|
|
220
|
+
scenarioPath: z.string().describe("Path to the scenario file (*.scenario.ts/.mts/.mjs)."),
|
|
221
|
+
outDir: z.string().optional().describe("Output directory (default: out/<name>)."),
|
|
222
|
+
quality: z.enum(["medium", "good", "source"]).optional().default("good").describe("medium (720p), good (1080p, default), or source."),
|
|
223
|
+
fps: z.number().int().min(10).max(60).optional().default(30).describe("Output frame rate (default 30)."),
|
|
224
|
+
speed: z.number().positive().optional().describe("Optional pacing speed multiplier."),
|
|
225
|
+
viewport: z.string().optional().describe("Optional WxH viewport override, e.g. '1280x720'."),
|
|
226
|
+
trimIdle: z.boolean().optional().describe("Cut idle stretches with OpenScreen trim regions."),
|
|
227
|
+
gif: z.boolean().optional().default(false).describe("Also export a palette-optimised GIF next to the MP4."),
|
|
228
|
+
frames: z.number().int().min(4).max(32).optional().default(12).describe("Number of contact-sheet tiles (default 12)."),
|
|
229
|
+
state: z.string().optional().describe("Optional Playwright storageState JSON file path."),
|
|
230
|
+
render: z.boolean().optional().default(true).describe("Render MP4 after recording (default true)."),
|
|
231
|
+
}),
|
|
232
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
233
|
+
}, async (args, ctx) => {
|
|
234
|
+
const progress = makeProgressNotifier(ctx);
|
|
235
|
+
const file = path.resolve(args.scenarioPath);
|
|
236
|
+
const scenario = await loadScenario(file);
|
|
237
|
+
const overrides = {};
|
|
238
|
+
if (args.viewport)
|
|
239
|
+
overrides.viewport = parseSize(args.viewport);
|
|
240
|
+
if (args.speed !== undefined)
|
|
241
|
+
overrides.pacing = { ...scenario.pacing, speed: args.speed };
|
|
242
|
+
if (args.trimIdle !== undefined)
|
|
243
|
+
overrides.trimIdle = args.trimIdle && (scenario.trimIdle || true);
|
|
244
|
+
const outDir = path.resolve(args.outDir ?? path.join("out", scenario.name));
|
|
245
|
+
progress(5, `Recording "${scenario.name}"...`);
|
|
246
|
+
const rec = await recordScenario(scenario, {
|
|
247
|
+
outDir,
|
|
248
|
+
scenarioFile: file,
|
|
249
|
+
overrides,
|
|
250
|
+
storageState: args.state,
|
|
251
|
+
log: logStderr,
|
|
252
|
+
});
|
|
253
|
+
const validation = await validateProject(rec.projectPath);
|
|
254
|
+
const summary = {
|
|
255
|
+
scenario: scenario.name,
|
|
256
|
+
outDir,
|
|
257
|
+
recordedDurationMs: rec.timeline.durationMs,
|
|
258
|
+
outputDurationMs: rec.timeline.outputDurationMs,
|
|
259
|
+
actions: rec.timeline.actions.length,
|
|
260
|
+
zoomRegions: rec.timeline.zoomRegions.length,
|
|
261
|
+
trimRegions: rec.timeline.trimRegions.length,
|
|
262
|
+
valid: validation.valid,
|
|
263
|
+
projectPath: rec.projectPath,
|
|
264
|
+
timelinePath: rec.timelinePath,
|
|
265
|
+
marksPath: rec.marksPath,
|
|
266
|
+
};
|
|
267
|
+
const content = [];
|
|
268
|
+
if (args.render) {
|
|
269
|
+
const mp4 = path.join(outDir, `${scenario.name}.mp4`);
|
|
270
|
+
const rendered = await renderProject({
|
|
271
|
+
projectPath: rec.projectPath,
|
|
272
|
+
outputPath: mp4,
|
|
273
|
+
frameRate: args.fps,
|
|
274
|
+
quality: args.quality,
|
|
275
|
+
cursor: scenario.cursor,
|
|
276
|
+
log: logStderr,
|
|
277
|
+
onProgress: (p) => progress(15 + p * 0.75, `Rendering ${Math.round(p)}%`),
|
|
278
|
+
});
|
|
279
|
+
summary.videoPath = rendered.outputPath;
|
|
280
|
+
summary.width = rendered.width;
|
|
281
|
+
summary.height = rendered.height;
|
|
282
|
+
summary.bytes = rendered.bytes;
|
|
283
|
+
summary.gpu = rendered.gpu;
|
|
284
|
+
summary.renderMs = rendered.renderMs;
|
|
285
|
+
if (args.gif) {
|
|
286
|
+
progress(92, "Exporting GIF...");
|
|
287
|
+
const g = await exportGif(mp4);
|
|
288
|
+
summary.gifPath = g.outputPath;
|
|
289
|
+
summary.gifBytes = g.bytes;
|
|
290
|
+
}
|
|
291
|
+
progress(96, "Building contact sheet...");
|
|
292
|
+
const sheet = await reviewSheet(mp4, {
|
|
293
|
+
outDir,
|
|
294
|
+
marks: rec.marksPath,
|
|
295
|
+
frames: args.frames,
|
|
296
|
+
log: logStderr,
|
|
297
|
+
});
|
|
298
|
+
summary.sheetPath = sheet.sheet;
|
|
299
|
+
summary.sheetTool = sheet.tool;
|
|
300
|
+
if (sheet.summary)
|
|
301
|
+
summary.framesheetSummary = sheet.summary;
|
|
302
|
+
content.push({ type: "text", text: JSON.stringify(summary, null, 2) });
|
|
303
|
+
const img = pngBlock(sheet.sheet);
|
|
304
|
+
if (img)
|
|
305
|
+
content.push(img);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
content.push({ type: "text", text: JSON.stringify(summary, null, 2) });
|
|
309
|
+
}
|
|
310
|
+
progress(100, "Done");
|
|
311
|
+
return { content };
|
|
312
|
+
});
|
|
313
|
+
server.registerTool("rezoom", {
|
|
314
|
+
title: "Tune zooms, idle trims, or keycap HUD without re-recording",
|
|
315
|
+
description: "Re-derives zoomRegions, trimRegions, and keycap annotations from timeline.json in an existing output directory, optionally re-renders the MP4, and returns the updated contact sheet PNG.",
|
|
316
|
+
inputSchema: z.object({
|
|
317
|
+
outDir: z.string().describe("Output directory containing timeline.json."),
|
|
318
|
+
maxDepth: z.number().int().min(1).max(6).optional().describe("Deepest automatic zoom tier (1=1.25x .. 6=5x)."),
|
|
319
|
+
leadMs: z.number().optional().describe("Zoom-in lead time before cursor arrives (ms)."),
|
|
320
|
+
holdMs: z.number().optional().describe("Hold zoom after action ends (ms)."),
|
|
321
|
+
autoZoom: z.boolean().optional().describe("Enable/disable automatic zooms (false = manual scene.zoom() only)."),
|
|
322
|
+
trimIdle: z.boolean().optional().describe("Enable/disable idle trimming."),
|
|
323
|
+
ignoreFrames: z.boolean().optional().describe("Ignore raw screencast frame bursts when trimming idle (useful for WebGL/rAF apps)."),
|
|
324
|
+
showKeys: z.boolean().optional().describe("Toggle floating keycap HUD for scene.press() shortcuts."),
|
|
325
|
+
render: z.boolean().optional().default(true).describe("Re-render the MP4 and contact sheet (default true)."),
|
|
326
|
+
quality: z.enum(["medium", "good", "source"]).optional().default("good"),
|
|
327
|
+
fps: z.number().int().min(10).max(60).optional().default(30),
|
|
328
|
+
frames: z.number().int().min(4).max(32).optional().default(12),
|
|
329
|
+
}),
|
|
330
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
331
|
+
}, async (args, ctx) => {
|
|
332
|
+
const progress = makeProgressNotifier(ctx);
|
|
333
|
+
const dir = path.resolve(args.outDir);
|
|
334
|
+
const zoom = {};
|
|
335
|
+
if (args.maxDepth !== undefined)
|
|
336
|
+
zoom.maxDepth = args.maxDepth;
|
|
337
|
+
if (args.leadMs !== undefined)
|
|
338
|
+
zoom.leadMs = args.leadMs;
|
|
339
|
+
if (args.holdMs !== undefined)
|
|
340
|
+
zoom.holdMs = args.holdMs;
|
|
341
|
+
if (args.autoZoom !== undefined)
|
|
342
|
+
zoom.auto = args.autoZoom;
|
|
343
|
+
const trimIdle = args.trimIdle === false
|
|
344
|
+
? false
|
|
345
|
+
: args.trimIdle || args.ignoreFrames !== undefined
|
|
346
|
+
? { ...(args.ignoreFrames !== undefined ? { ignoreFrames: args.ignoreFrames } : {}) }
|
|
347
|
+
: undefined;
|
|
348
|
+
const look = args.showKeys !== undefined ? { showKeys: args.showKeys } : undefined;
|
|
349
|
+
const res = rezoom(dir, { zoom, trimIdle, look });
|
|
350
|
+
const summary = {
|
|
351
|
+
scenario: res.timeline.scenario,
|
|
352
|
+
outputDurationMs: res.timeline.outputDurationMs,
|
|
353
|
+
zoomRegions: res.timeline.zoomRegions,
|
|
354
|
+
trimRegions: res.timeline.trimRegions,
|
|
355
|
+
speedRegions: res.timeline.speedRegions,
|
|
356
|
+
};
|
|
357
|
+
const content = [];
|
|
358
|
+
if (args.render) {
|
|
359
|
+
const rendered = await renderProject({
|
|
360
|
+
projectPath: res.projectPath,
|
|
361
|
+
frameRate: args.fps,
|
|
362
|
+
quality: args.quality,
|
|
363
|
+
cursor: res.timeline.options?.cursor,
|
|
364
|
+
log: logStderr,
|
|
365
|
+
onProgress: (p) => progress(p * 0.9, `Rendering ${Math.round(p)}%`),
|
|
366
|
+
});
|
|
367
|
+
summary.videoPath = rendered.outputPath;
|
|
368
|
+
summary.renderMs = rendered.renderMs;
|
|
369
|
+
const sheet = await reviewSheet(rendered.outputPath, {
|
|
370
|
+
outDir: dir,
|
|
371
|
+
marks: res.marksPath,
|
|
372
|
+
frames: args.frames,
|
|
373
|
+
log: logStderr,
|
|
374
|
+
});
|
|
375
|
+
summary.sheetPath = sheet.sheet;
|
|
376
|
+
if (sheet.summary)
|
|
377
|
+
summary.framesheetSummary = sheet.summary;
|
|
378
|
+
content.push({ type: "text", text: JSON.stringify(summary, null, 2) });
|
|
379
|
+
const img = pngBlock(sheet.sheet);
|
|
380
|
+
if (img)
|
|
381
|
+
content.push(img);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
content.push({ type: "text", text: JSON.stringify(summary, null, 2) });
|
|
385
|
+
}
|
|
386
|
+
progress(100, "Done");
|
|
387
|
+
return { content };
|
|
388
|
+
});
|
|
389
|
+
server.registerTool("inspect_frame", {
|
|
390
|
+
title: "Extract a full-resolution frame at a timestamp",
|
|
391
|
+
description: "Extracts a single full-resolution PNG frame from a rendered MP4 (or demoreel output directory) at `seconds` and returns it inline — ideal for checking dense UI, small badges, or zoomed text that contact-sheet thumbnails shrink.",
|
|
392
|
+
inputSchema: z.object({
|
|
393
|
+
target: z.string().describe("Path to an MP4 file or a demoreel output directory."),
|
|
394
|
+
seconds: z.number().min(0).describe("Timestamp in seconds."),
|
|
395
|
+
outPath: z.string().optional().describe("Optional output PNG path."),
|
|
396
|
+
}),
|
|
397
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
398
|
+
}, async ({ target, seconds, outPath }) => {
|
|
399
|
+
const { videoPath } = resolveVideoTarget(target);
|
|
400
|
+
const tmp = outPath ? null : path.join(os.tmpdir(), `demoreel-frame-${Date.now()}.png`);
|
|
401
|
+
try {
|
|
402
|
+
const res = await extractFrame(videoPath, seconds, outPath ?? tmp ?? undefined);
|
|
403
|
+
const content = [
|
|
404
|
+
{
|
|
405
|
+
type: "text",
|
|
406
|
+
text: JSON.stringify({ videoPath, seconds: res.seconds, duration: res.duration, ...(outPath ? { outPath: res.outPng } : {}) }, null, 2),
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
const img = pngBlock(res.outPng);
|
|
410
|
+
if (img)
|
|
411
|
+
content.push(img);
|
|
412
|
+
return { content };
|
|
413
|
+
}
|
|
414
|
+
finally {
|
|
415
|
+
if (tmp && fs.existsSync(tmp))
|
|
416
|
+
fs.rmSync(tmp, { force: true });
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
server.registerTool("export_gif", {
|
|
420
|
+
title: "Export a palette-optimised GIF",
|
|
421
|
+
description: "Converts a rendered MP4 (or demoreel output directory) into a looping two-pass palette-optimised GIF suitable for READMEs and docs.",
|
|
422
|
+
inputSchema: z.object({
|
|
423
|
+
target: z.string().describe("Path to an MP4 file or a demoreel output directory."),
|
|
424
|
+
outPath: z.string().optional().describe("Optional output GIF path (default: next to the MP4)."),
|
|
425
|
+
width: z.number().int().min(0).max(1920).optional().default(960).describe("Output width in px (default 960; 0 = source)."),
|
|
426
|
+
fps: z.number().int().min(1).max(30).optional().default(12).describe("Output frame rate (default 12)."),
|
|
427
|
+
}),
|
|
428
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
429
|
+
}, async ({ target, outPath, width, fps }) => {
|
|
430
|
+
const { videoPath } = resolveVideoTarget(target);
|
|
431
|
+
const res = await exportGif(videoPath, outPath, { width, fps });
|
|
432
|
+
return { content: [{ type: "text", text: JSON.stringify(res, null, 2) }] };
|
|
433
|
+
});
|
|
434
|
+
return server;
|
|
435
|
+
}
|
|
436
|
+
/** Starts the demoreel MCP server over stdio. */
|
|
437
|
+
export async function runMcpServer() {
|
|
438
|
+
const server = createMcpServer();
|
|
439
|
+
const transport = new StdioServerTransport();
|
|
440
|
+
await server.connect(transport);
|
|
441
|
+
}
|
package/dist/sheet.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export declare function probeDuration(video: string): Promise<number>;
|
|
2
|
+
/** Extracts a single full-resolution PNG frame at `seconds` from a video via ffmpeg. */
|
|
3
|
+
export declare function extractFrame(video: string, seconds: number, outPng?: string): Promise<{
|
|
4
|
+
outPng: string;
|
|
5
|
+
seconds: number;
|
|
6
|
+
duration: number;
|
|
7
|
+
}>;
|
|
2
8
|
/** Plain ffmpeg contact sheet: `n` evenly spaced frames with timestamps. */
|
|
3
9
|
export declare function contactSheet(video: string, outPng: string, n?: number, cols?: number, width?: number): Promise<{
|
|
4
10
|
outPng: string;
|
package/dist/sheet.js
CHANGED
|
@@ -11,6 +11,16 @@ export async function probeDuration(video) {
|
|
|
11
11
|
const out = await run(ffprobeBin(), ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", video]);
|
|
12
12
|
return Number(out.trim());
|
|
13
13
|
}
|
|
14
|
+
/** Extracts a single full-resolution PNG frame at `seconds` from a video via ffmpeg. */
|
|
15
|
+
export async function extractFrame(video, seconds, outPng) {
|
|
16
|
+
const src = path.resolve(video);
|
|
17
|
+
const duration = await probeDuration(src);
|
|
18
|
+
const clamped = Math.max(0, Math.min(Number.isFinite(seconds) ? seconds : 0, Math.max(0, duration - 0.05)));
|
|
19
|
+
const dst = path.resolve(outPng ?? src.replace(/\.\w+$/, `.frame-${clamped.toFixed(2)}s.png`));
|
|
20
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
21
|
+
await run(ffmpegBin(), ["-y", "-loglevel", "error", "-ss", clamped.toFixed(3), "-i", src, "-frames:v", "1", dst]);
|
|
22
|
+
return { outPng: dst, seconds: clamped, duration };
|
|
23
|
+
}
|
|
14
24
|
/** Plain ffmpeg contact sheet: `n` evenly spaced frames with timestamps. */
|
|
15
25
|
export async function contactSheet(video, outPng, n = 12, cols = 4, width = 480) {
|
|
16
26
|
const duration = await probeDuration(video);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phil65/demoreel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Scripted product demo videos (videos as code): Playwright scenarios with auto cursor + auto zoom, rendered headless by OpenScreen's exporter.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dist",
|
|
42
42
|
"examples/local-demo.ts",
|
|
43
43
|
"examples/demo-app",
|
|
44
|
+
"skills",
|
|
44
45
|
"licenses",
|
|
45
46
|
"THIRD_PARTY_NOTICES.md"
|
|
46
47
|
],
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"playwright": ">=1.49.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
64
|
+
"@modelcontextprotocol/client": "^2.4.0",
|
|
63
65
|
"@types/node": "^26.6.6",
|
|
64
66
|
"ajv": "^8.20.0",
|
|
65
67
|
"gif.js": "^0.2.0",
|
|
@@ -72,5 +74,9 @@
|
|
|
72
74
|
"vite": "^8.3.8",
|
|
73
75
|
"vitest": "^5.1.1",
|
|
74
76
|
"web-demuxer": "^4.0.0"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
80
|
+
"zod": "^4.6.7"
|
|
75
81
|
}
|
|
76
82
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: demoreel
|
|
3
|
+
description: Make or improve a product demo video with demoreel (Playwright scenario -> auto cursor + auto zoom -> MP4 via OpenScreen). Use when asked to record a demo, screencast or walkthrough video of a web app, or to fix pacing, zoom or captions of one.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# demoreel: the demo video loop
|
|
7
|
+
|
|
8
|
+
Inspect the app first, write a scenario, dry-run it with `demoreel inspect`, record and render,
|
|
9
|
+
inspect a contact sheet instead of watching the video, tune, and repeat. Never judge a video
|
|
10
|
+
you have not inspected.
|
|
11
|
+
|
|
12
|
+
## 1. Inspect the URL (and log in if needed)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx demoreel login http://localhost:3000 # if auth is required -> .demoreel/auth.json
|
|
16
|
+
npx demoreel inspect http://localhost:3000 --screenshot page.png [--state .demoreel/auth.json]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Read the printed ARIA snapshot (YAML accessibility tree) to pick real, stable role/name or
|
|
20
|
+
selector targets before writing the scenario.
|
|
21
|
+
|
|
22
|
+
## 2. Write the scenario
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { defineScenario } from "@phil65/demoreel";
|
|
26
|
+
|
|
27
|
+
export default defineScenario({
|
|
28
|
+
name: "checkout",
|
|
29
|
+
viewport: { width: 1920, height: 1080 },
|
|
30
|
+
cssZoom: 1.5, // only for pages whose layout you control; crisper text
|
|
31
|
+
// trimIdle: true, // cut dead time ({ ignoreFrames: true } for WebGL / rAF / spinner apps)
|
|
32
|
+
async run(scene) {
|
|
33
|
+
await scene.goto("http://localhost:3000/");
|
|
34
|
+
await scene.caption("Pay in two clicks", { duration: 2800 });
|
|
35
|
+
await scene.click({ role: "button", name: "Add to cart" });
|
|
36
|
+
await scene.select({ label: "Plan" }, "pro");
|
|
37
|
+
await scene.drag({ css: "canvas" }, { dx: 180, dy: -60 }, { duration: 1000 });
|
|
38
|
+
await scene.click("#checkout", { navigates: true });
|
|
39
|
+
await scene.type({ label: "Card number" }, "4242 4242 4242 4242");
|
|
40
|
+
await scene.zoom("#total", { depth: 3, duration: 2000, wait: true });
|
|
41
|
+
await scene.highlight(".receipt", { duration: 1800, dim: true, badge: "Paid" });
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Prefer structured accessibility targets (`{ role: "button", name: "Save" }`,
|
|
47
|
+
`{ label: "Email" }`, `{ placeholder }`, `{ text }`, `{ testId }`, `{ css }`, optional
|
|
48
|
+
`exact` / `nth`): `role` and `label` specs are the most stable choice and automatically
|
|
49
|
+
produce readable default labels in `timeline.json`, `marks.json` and the sheet. Give
|
|
50
|
+
important actions an explicit `label` when you want a shorter or clearer name.
|
|
51
|
+
- Use `scene.drag(from, toOrDelta, opts)` for sliders, 3D/WebGL canvas orbiting, and
|
|
52
|
+
drag-and-drop (it records 60 Hz cursor telemetry so OpenScreen's cursor tracks the drag;
|
|
53
|
+
raw `scene.page.mouse` does not). Use `scene.select(target, value, opts)` for `<select>`
|
|
54
|
+
dropdowns instead of clicking them.
|
|
55
|
+
- Optional visual cues (all opt-in so demos stay clean):
|
|
56
|
+
- `look: { showKeys: true }` (or `{ position, durationMs }` / per-step `scene.press("Control+K", { show: true })`)
|
|
57
|
+
renders crisp shortcut keycap pills (`Ctrl + K`, `Esc`) as OpenScreen annotations (also toggleable via `demoreel rezoom --show-keys`).
|
|
58
|
+
- `clickRipple: true` (or `{ color, size, durationMs }`) adds an expanding translucent ring at each click.
|
|
59
|
+
- `scene.highlight(target, { dim: true, badge: "..." })` adds a spotlight backdrop dim and optional callout pill.
|
|
60
|
+
- `cursor: { size, clickBounce, smoothing, motionBlur, show }` tunes OpenScreen's rendered cursor per scenario.
|
|
61
|
+
- `depth` is an **integer tier `1..6`**, not a raw zoom multiplier:
|
|
62
|
+
`1 = 1.25x`, `2 = 1.5x`, `3 = 1.8x`, `4 = 2.2x`, `5 = 3x`, `6 = 5x`.
|
|
63
|
+
- One idea per caption, 2.5-3.5 s each; start the caption before the action it explains.
|
|
64
|
+
Stick to clean ASCII in captions/labels when possible (some `framesheet` overlay fonts
|
|
65
|
+
render emoji or em-dashes as missing glyphs).
|
|
66
|
+
- Navigation clicks need `navigates: true`.
|
|
67
|
+
- Name the file `*.scenario.ts` in an ESM package, `*.scenario.mts` otherwise.
|
|
68
|
+
- For logged-in apps, set `storageState: "./.demoreel/auth.json"` (relative to the scenario
|
|
69
|
+
file) or pass `--state .demoreel/auth.json` on the CLI.
|
|
70
|
+
- **Skip slow boot/WASM spinners at frame 0**: recording starts on the first `scene.*` call.
|
|
71
|
+
To open directly on the ready UI, call `await scene.page.goto(url)` and `waitForFunction`
|
|
72
|
+
for app readiness before calling `scene.pause()` / `scene.caption()`.
|
|
73
|
+
- **WebGL / Canvas / continuous-rAF apps**: `trimIdle: { minMs: 1200, keepMs: 500, ignoreFrames: true }`
|
|
74
|
+
ensures continuous background repaints or spinners do not block idle trimming of slow
|
|
75
|
+
compute/build waits.
|
|
76
|
+
- **Dark UIs**: set `colorScheme: "dark"` and pair with a deep slate/indigo `look.wallpaper`
|
|
77
|
+
gradient (e.g. `linear-gradient(135deg, #0b1022 0%, #1d2d5c 52%, #3a2368 100%)`) rather than
|
|
78
|
+
bright default gradients.
|
|
79
|
+
- **AI / streaming apps**: mock only the LLM fetch/SSE boundary via `scene.page.evaluate(...)`
|
|
80
|
+
or `page.route(...)` while keeping real client-side/WASM tools live — deterministic, fast,
|
|
81
|
+
zero API cost, and authentic tool results.
|
|
82
|
+
|
|
83
|
+
## 3. Dry-run and inspect the scenario
|
|
84
|
+
|
|
85
|
+
Verify every selector and check the end state in a second (fast mode: no sleeps, no ffmpeg,
|
|
86
|
+
no output files):
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx demoreel inspect checkout.scenario.ts --screenshot end.png
|
|
90
|
+
npx demoreel run checkout.scenario.ts --dry-run
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
If a step fails, `demoreel inspect` reports the failing action index and error, and
|
|
94
|
+
still prints the ARIA snapshot (and writes `--screenshot`) at the moment of failure. Fix
|
|
95
|
+
broken selectors here before spending time recording.
|
|
96
|
+
|
|
97
|
+
## 4. Run
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx demoreel run checkout.scenario.ts --out out/checkout # record + render + sheet
|
|
101
|
+
npx demoreel run checkout.scenario.ts --gif # also export palette-optimised GIF
|
|
102
|
+
npx demoreel run checkout.scenario.ts --no-render # fast: record only
|
|
103
|
+
npx demoreel run checkout.scenario.ts --quality medium # cheaper drafts
|
|
104
|
+
npx demoreel gif out/checkout --width 960 --fps 12 # export README GIF from existing MP4
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
No GPU (CI, containers): software rendering is slow; draft with `--viewport 1280x720
|
|
108
|
+
--quality source` and render the final 1080p once (30 fps by default; `--fps 60` for smoother motion at twice the render time).
|
|
109
|
+
|
|
110
|
+
## 5. Inspect the contact sheet
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npx demoreel sheet out/checkout -n 16 # framesheet inspect <mp4> --marks marks.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Read the printed findings, then look at `out/checkout/framesheet/sheet.png` (tiles with click
|
|
117
|
+
points, target boxes, zoom spans and captions drawn on, plus a timeline). Also read
|
|
118
|
+
`out/checkout/timeline.json` (actions with times and boxes, `zoomRegions`, `trimRegions`).
|
|
119
|
+
For dense zoomed UI (tool cards, charts, small text), also extract a full-resolution check
|
|
120
|
+
frame (`npx demoreel frame out/checkout 12.5`) — contact-sheet thumbnails can
|
|
121
|
+
hide small error badges (`✕` vs `✓`), truncated text, or failed tool calls.
|
|
122
|
+
|
|
123
|
+
What to look for:
|
|
124
|
+
|
|
125
|
+
- **Caption covering the target** (framesheet `video-mark-overlap`): the caption box overlaps a
|
|
126
|
+
target box while it is active. Fix: shift the caption in time, shorten it, or set
|
|
127
|
+
`look.captionPosition` (`"auto"` already avoids active targets where it can).
|
|
128
|
+
- **Zoom on the wrong element / too tight / too loose**: the target box is not where the
|
|
129
|
+
action happens, or the zoomed tile cuts off context the viewer needs. Fix: zoom onto a
|
|
130
|
+
container with `data-demoreel-zoom` on it, `{ zoom: { context: 2 } }`, `{ zoom: { depth: 2 } }`,
|
|
131
|
+
`{ zoom: false }`, an explicit `scene.zoom(...)`, or scenario `zoom.maxDepth`.
|
|
132
|
+
- **Dead time**: tiles marked duplicate / long static stretches in the timeline, gaps between
|
|
133
|
+
actions after page loads, or slow typing in a small input (under 0.05% pixel change). Fix:
|
|
134
|
+
`trimIdle: true` (or `{ ignoreFrames: true }` for rAF/WebGL apps), shorter `pause()`,
|
|
135
|
+
higher `pacing.speed` / lower `pacing.typeDelay`, or a shorter typed prompt.
|
|
136
|
+
- **Too fast**: actions closer than ~0.8 s, captions shorter than ~2 s, zoom regions that
|
|
137
|
+
last less than ~1.5 s (they flash). Fix: `pause()`, longer `duration`, `pacing.speed` < 1.
|
|
138
|
+
- **Pan/zoom ping-pong**: many short zoom regions alternating far apart. Fix: larger
|
|
139
|
+
`mergeGapMs`, `maxDepth` lower, or one explicit `scene.zoom()` over the whole step.
|
|
140
|
+
- **Wrong state**: a tile shows an error page, a spinner, a failed tool badge, or an empty
|
|
141
|
+
list. Wait for a specific success selector (not a generic `img` or container) before moving on.
|
|
142
|
+
- **Blank or black tiles** at the start/end: page not loaded at the first `goto`, or the
|
|
143
|
+
ending hold is too short/long.
|
|
144
|
+
|
|
145
|
+
## 6. Tune without re-recording when you can
|
|
146
|
+
|
|
147
|
+
Zoom and idle changes do not need a new recording:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx demoreel rezoom out/checkout --max-depth 2 --hold 1200 --render
|
|
151
|
+
npx demoreel rezoom out/checkout --trim-idle --idle-options '{"minMs":1500,"keepMs":700}' --render
|
|
152
|
+
npx demoreel rezoom out/checkout --no-auto-zoom --render # only explicit scene.zoom()
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Changes to actions, captions, pacing, selectors or `look` need `demoreel run` again.
|
|
156
|
+
|
|
157
|
+
## 7. Repeat
|
|
158
|
+
|
|
159
|
+
Inspect -> dry-run -> run -> sheet -> fix the worst problem -> run again, until the sheet has no findings you can
|
|
160
|
+
fix and every tile shows what its caption says. Report the final MP4 path, its duration and
|
|
161
|
+
the sheet, and mention anything you could not fix.
|