cuetake 0.1.0 → 0.2.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 +3 -0
- package/package.json +1 -2
- package/src/cli.js +22 -5
- package/src/edit.js +13 -10
- package/src/look.js +107 -0
- package/src/pipeline.js +40 -3
- package/src/render-page.js +100 -41
- package/src/render.js +9 -0
- package/src/stage.js +20 -0
- package/skills/cuetake/SKILL.md +0 -52
- package/skills/cuetake/authentication.md +0 -18
- package/skills/cuetake/scenarios.md +0 -94
- package/skills/cuetake/scripts/cuetake +0 -4
- package/skills/cuetake/setup.md +0 -28
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# CueTake
|
|
2
2
|
|
|
3
|
+
[](https://skills.sh/levyxdev/cuetake) [](https://www.npmjs.com/package/cuetake)
|
|
4
|
+
|
|
3
5
|
**Script the flow. Keep the take.**
|
|
4
6
|
|
|
5
7
|
Built entirely for AI agents, CueTake turns browser interactions into sharp product demo videos with a precise cursor and continuous camera moves. Give an agent a scenario, then capture, render, and verify the result locally.
|
|
@@ -10,6 +12,7 @@ Built entirely for AI agents, CueTake turns browser interactions into sharp prod
|
|
|
10
12
|
- An automatic camera in the style of Screen Studio: it arrives just before each click, field and drag, follows the cursor on a spring, and ends on the wide shot.
|
|
11
13
|
- The page framed in a browser or macOS window on a gradient, brand-colored or blurred background, at 16:9, 1:1 or 9:16.
|
|
12
14
|
- Cursor and click sparks drawn at Render time, so a Take can be restyled without recording again.
|
|
15
|
+
- Styling chosen in conversation: the agent shows Previews of candidate Looks side by side in about a second, and the Look you pick is saved for later Takes.
|
|
13
16
|
- Rendering in Chromium with WebGL and WebCodecs: no FFmpeg, 4K60 by default.
|
|
14
17
|
- A separate folder for every Take: Source, Timeline, Edit, Final MP4, and verification.
|
|
15
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cuetake",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Local recording runtime for AI agents: plan a browser demo, capture it, and render a finished take.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"src",
|
|
11
|
-
"skills",
|
|
12
11
|
"examples",
|
|
13
12
|
"README.md",
|
|
14
13
|
"LICENSE"
|
package/src/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
3
|
import pkg from '../package.json' with { type: 'json' };
|
|
4
|
-
import { recordScenario, renderTake, verifyTake } from './pipeline.js';
|
|
4
|
+
import { recordScenario, renderTake, verifyTake, previewTake, applyLookToTake, saveLookFromTake } from './pipeline.js';
|
|
5
|
+
import { listLooks, removeLook } from './look.js';
|
|
5
6
|
import { doctor, installBrowser } from './environment.js';
|
|
6
7
|
import { login } from './auth.js';
|
|
7
8
|
import { extractFrame } from './render.js';
|
|
@@ -12,27 +13,39 @@ const help = `CueTake ${pkg.version} — browser demos directed by code
|
|
|
12
13
|
|
|
13
14
|
cuetake doctor
|
|
14
15
|
cuetake install-browser
|
|
15
|
-
cuetake record <scenario.mjs> [--out <new-directory>] [--auth-profile <name>] [--headed]
|
|
16
|
+
cuetake record <scenario.mjs> [--out <new-directory>] [--auth-profile <name>] [--look <name|file.json>] [--headed]
|
|
17
|
+
cuetake preview <take-directory> [--look <name|file.json>]... [--at <seconds>]
|
|
16
18
|
cuetake render <take-directory>
|
|
17
19
|
cuetake verify <take-directory>
|
|
18
20
|
cuetake frame <take-directory> <seconds> [--out <file.png>]
|
|
19
21
|
cuetake login <profile> <login-url>
|
|
22
|
+
cuetake look list
|
|
23
|
+
cuetake look save <name> <take-directory> [--global] [--replace]
|
|
24
|
+
cuetake look apply <name|file.json> <take-directory>
|
|
25
|
+
cuetake look rm <name> [--global]
|
|
20
26
|
|
|
21
27
|
install-browser downloads the Chromium build this CueTake version drives (about 150 MB).
|
|
22
28
|
record captures, renders and verifies a new take; an existing directory is never overwritten.
|
|
23
29
|
Capture runs headless; --headed shows the browser window while recording.
|
|
30
|
+
--look seeds the first Edit from a Look; fields the Scenario config names win.
|
|
31
|
+
preview writes preview.png in the take: the current Edit beside up to five Looks, at --at seconds
|
|
32
|
+
or at the end with the camera wide. It never changes edit.json or final.mp4.
|
|
24
33
|
render reuses source.webm, timeline.json and edit.json, replacing final.mp4 only on success.
|
|
25
34
|
frame saves one Final frame as a PNG for inspection.
|
|
26
35
|
login opens a separate browser; close its window after logging in to save the profile.
|
|
36
|
+
A Look is a take's reusable styling. Looks are saved locally (.cuetake/looks in this directory)
|
|
37
|
+
unless --global; a local Look hides a global one with the same name. apply rewrites edit.json.
|
|
27
38
|
Scenario files are trusted JavaScript. Recording runs locally, without audio.
|
|
28
39
|
`;
|
|
29
40
|
try {
|
|
30
|
-
const { values, positionals } = parseArgs({ args: process.argv.slice(2), allowPositionals: true, options: { out: { type: 'string' }, help: { type: 'boolean', short: 'h' }, 'auth-profile': { type: 'string' }, headed: { type: 'boolean' } } });
|
|
31
|
-
const [command, target] = positionals;
|
|
41
|
+
const { values, positionals } = parseArgs({ args: process.argv.slice(2), allowPositionals: true, options: { out: { type: 'string' }, help: { type: 'boolean', short: 'h' }, 'auth-profile': { type: 'string' }, headed: { type: 'boolean' }, look: { type: 'string', multiple: true }, at: { type: 'string' }, global: { type: 'boolean' }, replace: { type: 'boolean' } } });
|
|
42
|
+
const [command, target] = positionals, looks = values.look ?? [];
|
|
43
|
+
const print = data => console.log(JSON.stringify(data, null, 2));
|
|
32
44
|
if (values.help || !command) console.log(help);
|
|
33
45
|
else if (command === 'doctor') { const result = await doctor(); console.log(JSON.stringify(result, null, 2)); if (!result.ok) process.exitCode = 1; }
|
|
34
46
|
else if (command === 'install-browser') console.log(JSON.stringify(await installBrowser(), null, 2));
|
|
35
|
-
else if (command === 'record' && target)
|
|
47
|
+
else if (command === 'record' && target && looks.length <= 1) print(await recordScenario(target, values.out, { authProfile: values['auth-profile'], look: looks[0], headed: values.headed }));
|
|
48
|
+
else if (command === 'preview' && target) print(await previewTake(target, looks, { at: values.at === undefined ? undefined : Number(values.at) }));
|
|
36
49
|
else if (command === 'render' && target) { await renderTake(target); console.log(JSON.stringify(await verifyTake(target), null, 2)); }
|
|
37
50
|
else if (command === 'verify' && target) console.log(JSON.stringify(await verifyTake(target), null, 2));
|
|
38
51
|
else if (command === 'frame' && target && positionals[2]) {
|
|
@@ -41,5 +54,9 @@ try {
|
|
|
41
54
|
console.log(out);
|
|
42
55
|
}
|
|
43
56
|
else if (command === 'login' && target && positionals[2]) console.log(JSON.stringify(await login(positionals[2], target), null, 2));
|
|
57
|
+
else if (command === 'look' && target === 'list') print(await listLooks());
|
|
58
|
+
else if (command === 'look' && target === 'save' && positionals[3]) print(await saveLookFromTake(positionals[2], positionals[3], { global: values.global, replace: values.replace }));
|
|
59
|
+
else if (command === 'look' && target === 'apply' && positionals[3]) print(await applyLookToTake(positionals[2], positionals[3]));
|
|
60
|
+
else if (command === 'look' && target === 'rm' && positionals[2]) print(await removeLook(positionals[2], { global: values.global }));
|
|
44
61
|
else throw new Error(`Unknown or incomplete command.\n${help}`);
|
|
45
62
|
} catch (error) { console.error(`CueTake: ${error.message}`); process.exitCode = 1; }
|
package/src/edit.js
CHANGED
|
@@ -6,26 +6,29 @@ export const evenSize = z.number().int().min(240).max(7680).refine(n => n % 2 ==
|
|
|
6
6
|
const box = z.object({ x: z.number(), y: z.number(), width: z.number().nonnegative(), height: z.number().nonnegative() });
|
|
7
7
|
|
|
8
8
|
// size names the Final's short side; quality is the H.264 quantizer (lower is sharper and larger).
|
|
9
|
-
const outputFields = z.object({
|
|
9
|
+
export const outputFields = z.object({
|
|
10
10
|
size: z.union([z.enum(Object.keys(SHORT_SIDE)), evenSize]).default('2160p'),
|
|
11
11
|
aspect: z.enum(['16:9', '1:1', '9:16']).default('16:9'),
|
|
12
12
|
quality: z.number().int().min(10).max(40).default(22),
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
+
// The page in a window on a background. Radius is in 1080p pixels.
|
|
16
|
+
export const frameFields = z.object({
|
|
17
|
+
window: z.enum(Object.keys(CHROME_HEIGHT)).default('browser'),
|
|
18
|
+
background: z.enum([...Object.keys(BACKGROUNDS), 'auto', 'blur']).default('aurora'),
|
|
19
|
+
padding: z.number().min(0).max(0.3).default(0.08),
|
|
20
|
+
radius: z.number().min(0).max(48).default(12),
|
|
21
|
+
shadow: z.boolean().default(true),
|
|
22
|
+
url: z.string().max(200).optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
15
25
|
/** Times are seconds except clickEffect.duration, which is milliseconds; geometry is CSS pixels. */
|
|
16
26
|
export const editFields = {
|
|
17
27
|
cursor: z.object({ style: z.enum(['arrow', 'dot']).default('arrow'), size: z.number().min(12).max(64).default(24), color: z.string().regex(/^#[a-fA-F0-9]{6}$/).default('#ffffff') }).default({}),
|
|
18
28
|
clickEffect: z.object({ style: z.enum(['spark', 'none']).default('spark'), radius: z.number().min(8).max(80).default(32), length: z.number().min(4).max(40).default(16), count: z.number().int().min(4).max(16).default(8), duration: z.number().min(150).max(1000).default(420) }).default({}),
|
|
19
29
|
output: outputFields.default({}),
|
|
20
|
-
//
|
|
21
|
-
frame: z.union([z.literal(false),
|
|
22
|
-
window: z.enum(Object.keys(CHROME_HEIGHT)).default('browser'),
|
|
23
|
-
background: z.enum([...Object.keys(BACKGROUNDS), 'auto', 'blur']).default('aurora'),
|
|
24
|
-
padding: z.number().min(0).max(0.3).default(0.08),
|
|
25
|
-
radius: z.number().min(0).max(48).default(12),
|
|
26
|
-
shadow: z.boolean().default(true),
|
|
27
|
-
url: z.string().max(200).optional(),
|
|
28
|
-
})]).default({}),
|
|
30
|
+
// `false` lets the page fill the Final.
|
|
31
|
+
frame: z.union([z.literal(false), frameFields]).default({}),
|
|
29
32
|
// See camera.js. Each target is framed with `padding` CSS px around it, zooming at most `maxZoom`;
|
|
30
33
|
// fits below `minZoom` stay wide. The camera arrives `lead` before an action, holds `hold` after the
|
|
31
34
|
// last one in a segment, settles in about `response`, and returns wide `endWide` before the end.
|
package/src/look.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { editFields, editSchema, frameFields, outputFields } from './edit.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A Look is the part of an Edit that does not depend on one Take: everything except camera targets,
|
|
9
|
+
* the address bar's url and the frame rate. Every field is optional; a Look sets only what it names.
|
|
10
|
+
*/
|
|
11
|
+
export const lookSchema = z.object({
|
|
12
|
+
cursor: editFields.cursor.removeDefault().partial().strict(),
|
|
13
|
+
clickEffect: editFields.clickEffect.removeDefault().partial().strict(),
|
|
14
|
+
output: outputFields.partial().strict(),
|
|
15
|
+
frame: z.union([z.literal(false), frameFields.omit({ url: true }).partial().strict()]),
|
|
16
|
+
camera: editFields.camera.removeDefault().partial().strict(),
|
|
17
|
+
}).partial().strict();
|
|
18
|
+
|
|
19
|
+
const isObject = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
20
|
+
/** `over` wins field by field: nested objects merge, anything else (including `frame: false`) replaces. */
|
|
21
|
+
export function mergeLook(base, over) {
|
|
22
|
+
const merged = { ...base };
|
|
23
|
+
for (const [key, value] of Object.entries(over ?? {})) merged[key] = isObject(value) && isObject(base?.[key]) ? mergeLook(base[key], value) : value;
|
|
24
|
+
return merged;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The Look an Edit carries. */
|
|
28
|
+
export function lookFromEdit({ cursor, clickEffect, output: { fps, ...output }, frame, camera: { targets, ...camera } }) {
|
|
29
|
+
const { url, ...styling } = frame || {};
|
|
30
|
+
return lookSchema.parse({ cursor, clickEffect, output, frame: frame && styling, camera });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The Edit with a Look adopted. Camera targets and the frame rate stay; the address bar keeps its url, else shows `host`. */
|
|
34
|
+
export function applyLook(edit, look, host) {
|
|
35
|
+
const next = mergeLook(edit, look);
|
|
36
|
+
if (next.frame) next.frame = { url: edit.frame?.url ?? host, ...next.frame };
|
|
37
|
+
return editSchema.parse(next);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One line for listings, such as "browser · ocean · 16:9 · 2160p". */
|
|
41
|
+
export function summarize(look) {
|
|
42
|
+
const { frame, output = {} } = look;
|
|
43
|
+
const parts = frame === false ? ['no frame', output.size] : [frame?.window, frame?.background, output.aspect, output.size];
|
|
44
|
+
return parts.filter(Boolean).join(' · ') || Object.keys(look).join(', ') || 'empty';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Local Looks live in the directory CueTake runs in; global ones serve every directory. */
|
|
48
|
+
const scopes = (cwd = process.cwd()) => ({
|
|
49
|
+
local: join(cwd, '.cuetake', 'looks'),
|
|
50
|
+
global: process.env.CUETAKE_LOOK_DIR || join(homedir(), '.local/share/cuetake/looks'),
|
|
51
|
+
});
|
|
52
|
+
function lookPath(name, scope, cwd) {
|
|
53
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(name)) throw new Error('Use a short lowercase Look name, such as brand');
|
|
54
|
+
return join(scopes(cwd)[scope], `${name}.json`);
|
|
55
|
+
}
|
|
56
|
+
function parseLook(data, path) {
|
|
57
|
+
const result = lookSchema.safeParse(data);
|
|
58
|
+
if (!result.success) throw new Error(`${path} is not a valid Look: ${result.error.issues.map(issue => `${issue.path.join('.') || 'look'} ${issue.message}`).join('; ')}`);
|
|
59
|
+
return result.data;
|
|
60
|
+
}
|
|
61
|
+
const readIfPresent = path => fs.readFile(path, 'utf8').catch(error => { if (error.code === 'ENOENT') return null; throw error; });
|
|
62
|
+
|
|
63
|
+
/** A Look by name, local before global, or from a JSON file labeled by its `name` or file name. */
|
|
64
|
+
export async function loadLook(ref, cwd = process.cwd()) {
|
|
65
|
+
if (ref.endsWith('.json')) {
|
|
66
|
+
const path = resolve(cwd, ref);
|
|
67
|
+
const { name = basename(ref, '.json'), ...look } = JSON.parse(await fs.readFile(path, 'utf8'));
|
|
68
|
+
return { name: String(name), look: parseLook(look, path) };
|
|
69
|
+
}
|
|
70
|
+
for (const scope of ['local', 'global']) {
|
|
71
|
+
const path = lookPath(ref, scope, cwd), text = await readIfPresent(path);
|
|
72
|
+
if (text !== null) return { name: ref, scope, look: parseLook(JSON.parse(text), path) };
|
|
73
|
+
}
|
|
74
|
+
const { local, global } = scopes(cwd);
|
|
75
|
+
throw new Error(`No Look named '${ref}' in ${local} or ${global}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Every saved Look; a global Look hidden by a local one with the same name is marked shadowed. */
|
|
79
|
+
export async function listLooks(cwd = process.cwd()) {
|
|
80
|
+
const found = [];
|
|
81
|
+
for (const [scope, dir] of Object.entries(scopes(cwd))) {
|
|
82
|
+
const files = await fs.readdir(dir).catch(error => { if (error.code === 'ENOENT') return []; throw error; });
|
|
83
|
+
for (const file of files.filter(f => f.endsWith('.json')).sort()) {
|
|
84
|
+
const name = basename(file, '.json'), path = join(dir, file);
|
|
85
|
+
const summary = await fs.readFile(path, 'utf8').then(text => summarize(parseLook(JSON.parse(text), path)), error => `invalid: ${error.message}`);
|
|
86
|
+
found.push({ name, scope, shadowed: scope === 'global' && found.some(l => l.scope === 'local' && l.name === name), summary, path });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return found;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Saves a Look locally unless `global`; an existing Look with the name is kept unless `replace`. */
|
|
93
|
+
export async function saveLook(name, look, { global = false, replace = false, cwd } = {}) {
|
|
94
|
+
const scope = global ? 'global' : 'local', path = lookPath(name, scope, cwd);
|
|
95
|
+
await fs.mkdir(dirname(path), { recursive: true });
|
|
96
|
+
await fs.writeFile(path, JSON.stringify(lookSchema.parse(look), null, 2) + '\n', { flag: replace ? 'w' : 'wx' }).catch(error => {
|
|
97
|
+
if (error.code === 'EEXIST') throw new Error(`A ${scope} Look named '${name}' already exists at ${path}; pass --replace to overwrite it`);
|
|
98
|
+
throw error;
|
|
99
|
+
});
|
|
100
|
+
return { name, scope, path, summary: summarize(look) };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function removeLook(name, { global = false, cwd } = {}) {
|
|
104
|
+
const scope = global ? 'global' : 'local', path = lookPath(name, scope, cwd);
|
|
105
|
+
await fs.rm(path).catch(error => { if (error.code === 'ENOENT') throw new Error(`No ${scope} Look named '${name}' at ${path}`); throw error; });
|
|
106
|
+
return { name, scope, removed: path };
|
|
107
|
+
}
|
package/src/pipeline.js
CHANGED
|
@@ -4,12 +4,13 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { doctor } from './environment.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { startRecording, getRecordingPage, beginCapture, stopRecording, cleanup } from './recorder.js';
|
|
7
|
-
import { renderFinal, inspectFinal } from './render.js';
|
|
7
|
+
import { renderFinal, inspectFinal, composePreview } from './render.js';
|
|
8
8
|
import { outputSize } from './stage.js';
|
|
9
9
|
import { resolveAuthProfile } from './auth.js';
|
|
10
10
|
import { createDirector } from './director.js';
|
|
11
11
|
import { collectTimeline } from './probe.js';
|
|
12
12
|
import { editFields, editSchema, createEdit, evenSize } from './edit.js';
|
|
13
|
+
import { loadLook, mergeLook, applyLook, lookFromEdit, saveLook, summarize } from './look.js';
|
|
13
14
|
import pkg from '../package.json' with { type: 'json' };
|
|
14
15
|
|
|
15
16
|
const SCHEMA_VERSION = 2;
|
|
@@ -27,7 +28,9 @@ const readJson = async path => JSON.parse(await fs.readFile(path, 'utf8'));
|
|
|
27
28
|
/** New take directories are exclusive: reruns never overwrite a previous take. */
|
|
28
29
|
export async function recordScenario(scenarioPath, outputDir, options = {}) {
|
|
29
30
|
const scenario = await import(pathToFileURL(resolve(scenarioPath)).href);
|
|
30
|
-
|
|
31
|
+
// A Look sits under the Scenario: every field the config names wins over it.
|
|
32
|
+
const look = options.look ? await loadLook(options.look) : null;
|
|
33
|
+
const config = scenarioSchema.parse(look ? mergeLook(look.look, scenario.config) : scenario.config);
|
|
31
34
|
if (typeof scenario.run !== 'function') throw new Error('Scenario must export run(director)');
|
|
32
35
|
const authState = options.authProfile ? await resolveAuthProfile(options.authProfile) : undefined;
|
|
33
36
|
const ready = await doctor();
|
|
@@ -35,7 +38,7 @@ export async function recordScenario(scenarioPath, outputDir, options = {}) {
|
|
|
35
38
|
const dir = resolve(outputDir || join('recordings', config.name, new Date().toISOString().replace(/[:.]/g, '-')));
|
|
36
39
|
await fs.mkdir(resolve(dir, '..'), { recursive: true });
|
|
37
40
|
await fs.mkdir(dir); // EEXIST is intentional, including for empty existing folders.
|
|
38
|
-
let project = { schemaVersion: SCHEMA_VERSION, tool: 'CueTake', version: pkg.version, createdAt: new Date().toISOString(), status: 'recording', authenticated: Boolean(authState), config };
|
|
41
|
+
let project = { schemaVersion: SCHEMA_VERSION, tool: 'CueTake', version: pkg.version, createdAt: new Date().toISOString(), status: 'recording', authenticated: Boolean(authState), ...(look && { look: look.name }), config };
|
|
39
42
|
await writeJson(join(dir, 'project.json'), project);
|
|
40
43
|
await fs.copyFile(resolve(scenarioPath), join(dir, 'scenario.mjs'));
|
|
41
44
|
try {
|
|
@@ -79,6 +82,40 @@ async function loadTake(dir) {
|
|
|
79
82
|
return { project, config: scenarioSchema.parse(project.config), timeline: await readJson(join(dir, 'timeline.json')), edit: editSchema.parse(await readJson(join(dir, 'edit.json'))) };
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Writes preview.png: the Take's current Edit beside each Look (names or JSON files), composed at 1080p,
|
|
87
|
+
* whose proportions match every output size. Without `at` it shows the last moment with the camera wide.
|
|
88
|
+
*/
|
|
89
|
+
export async function previewTake(directory, refs = [], { at } = {}) {
|
|
90
|
+
const dir = resolve(directory);
|
|
91
|
+
const { config, timeline, edit } = await loadTake(dir);
|
|
92
|
+
if (refs.length > 5) throw new Error('Compare at most five Looks with the current Edit');
|
|
93
|
+
if (at !== undefined && !(at >= 0 && at <= timeline.duration)) throw new Error(`--at must be between 0 and ${timeline.duration} seconds`);
|
|
94
|
+
const host = new URL(config.url).host;
|
|
95
|
+
const looks = await Promise.all(refs.map(ref => loadLook(ref)));
|
|
96
|
+
const tiles = [{ name: 'current', edit }, ...looks.map(({ name, look }) => ({ name, edit: applyLook(edit, look, host) }))];
|
|
97
|
+
const png = await composePreview({ sourcePath: join(dir, 'source.webm'), timeline, at, tiles: tiles.map(({ name, edit }) => ({ name, edit: { ...edit, output: { ...edit.output, size: '1080p' } } })) });
|
|
98
|
+
const preview = join(dir, 'preview.png');
|
|
99
|
+
await fs.writeFile(preview, png);
|
|
100
|
+
return { preview, at: at ?? 'end, camera wide', tiles: tiles.map(({ name, edit }) => ({ name, summary: summarize(lookFromEdit(edit)) })) };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Adopts a Look into the Take's edit.json; the Final changes only after the next Render. */
|
|
104
|
+
export async function applyLookToTake(ref, directory) {
|
|
105
|
+
const dir = resolve(directory);
|
|
106
|
+
const { config, edit } = await loadTake(dir);
|
|
107
|
+
const { name, look } = await loadLook(ref);
|
|
108
|
+
const next = applyLook(edit, look, new URL(config.url).host);
|
|
109
|
+
await writeJson(join(dir, 'edit.json'), next);
|
|
110
|
+
return { look: name, edit: join(dir, 'edit.json'), summary: summarize(lookFromEdit(next)), next: `cuetake render ${dir}` };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Saves the Take's styling as a Look, locally unless `global`. */
|
|
114
|
+
export async function saveLookFromTake(name, directory, options) {
|
|
115
|
+
const { edit } = await loadTake(resolve(directory));
|
|
116
|
+
return saveLook(name, lookFromEdit(edit), options);
|
|
117
|
+
}
|
|
118
|
+
|
|
82
119
|
export async function renderTake(directory) {
|
|
83
120
|
const dir = resolve(directory);
|
|
84
121
|
const { project, config, timeline, edit } = await loadTake(dir);
|
package/src/render-page.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as MB from '/mediabunny.js';
|
|
9
9
|
import { cameraTrack } from '/camera.js';
|
|
10
10
|
import { pointerAt, presses, sparksAt, cursorGeometry, drawSpark, ARROW_PATH } from '/cursor.js';
|
|
11
|
-
import { layout, cameraView, BACKGROUNDS, autoBackground, brandHue } from '/stage.js';
|
|
11
|
+
import { layout, cameraView, previewSheet, BACKGROUNDS, autoBackground, brandHue } from '/stage.js';
|
|
12
12
|
|
|
13
13
|
const VERTEX = `#version 300 es
|
|
14
14
|
in vec2 p; void main() { gl_Position = vec4(p, 0, 1); }`;
|
|
@@ -118,8 +118,8 @@ function frameReader(track, decoderConfig) {
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
/** `
|
|
122
|
-
function createCompositor(stage,
|
|
121
|
+
/** `backdrop` is the static part of the frame: whether there is one, its background and shadow. */
|
|
122
|
+
function createCompositor(stage, backdrop, sourceWidth, sourceHeight) {
|
|
123
123
|
const { width, height } = stage;
|
|
124
124
|
const canvas = new OffscreenCanvas(width, height);
|
|
125
125
|
const gl = canvas.getContext('webgl2', { alpha: false, antialias: false, depth: false });
|
|
@@ -156,11 +156,11 @@ function createCompositor(stage, look, sourceWidth, sourceHeight) {
|
|
|
156
156
|
const set = (name, ...v) => gl[`uniform${v.length}f`](pageProgram.uniform(name), ...v);
|
|
157
157
|
set('uPage', stage.page.x, stage.page.y, stage.page.w, stage.page.h);
|
|
158
158
|
set('uWindow', stage.window.x, stage.window.y, stage.window.w, stage.window.h);
|
|
159
|
-
set('uRadius', stage.radius); set('uFramed',
|
|
160
|
-
if (
|
|
159
|
+
set('uRadius', stage.radius); set('uFramed', backdrop.framed ? 1 : 0); set('uShadow', backdrop.shadow ? 1 : 0); set('uBlur', backdrop.background ? 0 : 1);
|
|
160
|
+
if (backdrop.background) {
|
|
161
161
|
const rgb = hex => [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16) / 255);
|
|
162
|
-
set('uBase', ...rgb(
|
|
163
|
-
const blobs =
|
|
162
|
+
set('uBase', ...rgb(backdrop.background.base));
|
|
163
|
+
const blobs = backdrop.background.blobs.slice(0, 4);
|
|
164
164
|
gl.uniform1i(pageProgram.uniform('uBlobCount'), blobs.length);
|
|
165
165
|
gl.uniform4fv(pageProgram.uniform('uBlobs'), blobs.flatMap(([x, y, r]) => [x, y, r, 0]).concat(Array(16).fill(0)).slice(0, 16));
|
|
166
166
|
gl.uniform3fv(pageProgram.uniform('uBlobColors'), blobs.flatMap(b => rgb(b[3])).concat(Array(12).fill(0)).slice(0, 12));
|
|
@@ -178,6 +178,8 @@ function createCompositor(stage, look, sourceWidth, sourceHeight) {
|
|
|
178
178
|
return {
|
|
179
179
|
canvas,
|
|
180
180
|
gpu: info ? gl.getParameter(info.UNMASKED_RENDERER_WEBGL) : 'unknown',
|
|
181
|
+
/** Frees the GPU context; a Preview makes one compositor per tile. */
|
|
182
|
+
dispose() { gl.getExtension('WEBGL_lose_context')?.loseContext(); },
|
|
181
183
|
upload(frame) {
|
|
182
184
|
gl.bindTexture(gl.TEXTURE_2D, pageTexture);
|
|
183
185
|
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, frame);
|
|
@@ -275,6 +277,47 @@ async function encoderConfig(width, height, fps, quality) {
|
|
|
275
277
|
throw new Error(`No H.264 encoder supports ${width}×${height} at ${fps} fps`);
|
|
276
278
|
}
|
|
277
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Everything Render draws for one Edit: the stage under the camera, then the chrome, click sparks and
|
|
282
|
+
* cursor. `firstFrame` is the Source's first frame, which picks the `auto` background.
|
|
283
|
+
*/
|
|
284
|
+
function createScene(edit, viewport, { pointer, events }, firstFrame, sourceWidth, sourceHeight) {
|
|
285
|
+
const { camera, cursor, clickEffect, frame } = edit;
|
|
286
|
+
const stage = layout(edit, viewport);
|
|
287
|
+
const compositor = createCompositor(stage, { framed: Boolean(frame), shadow: frame && frame.shadow, background: frame && backgroundFor(frame, firstFrame) }, sourceWidth, sourceHeight);
|
|
288
|
+
// Page CSS pixels → stage pixels; sprites are rasterized for the closest zoom and mipmapped below it.
|
|
289
|
+
const at = (x, y) => [stage.page.x + x * stage.scale, stage.page.y + y * stage.scale];
|
|
290
|
+
const sharpest = stage.scale * camera.maxZoom * 2;
|
|
291
|
+
const geometry = cursorGeometry(cursor);
|
|
292
|
+
const pointerSprite = cursorSprite(cursor, sharpest);
|
|
293
|
+
const pointerTexture = compositor.sprite(pointerSprite.canvas);
|
|
294
|
+
const chromeTexture = stage.chrome ? compositor.sprite(chromeSprite(frame, viewport.width, stage.chrome / stage.scale, stage.radius / stage.scale, sharpest)) : null;
|
|
295
|
+
const pressList = presses(events);
|
|
296
|
+
const sparkReach = clickEffect.radius + clickEffect.length + 8;
|
|
297
|
+
let sparkTexture = null;
|
|
298
|
+
return {
|
|
299
|
+
stage, compositor,
|
|
300
|
+
/** Draws output time `t` with the camera showing `crop`, a viewport rectangle in CSS pixels. */
|
|
301
|
+
draw(t, crop) {
|
|
302
|
+
const view = cameraView(crop, stage, viewport);
|
|
303
|
+
compositor.frame(view.x, view.y, view.zoom, draw => {
|
|
304
|
+
if (chromeTexture) draw(chromeTexture, [stage.window.x, stage.window.y, stage.window.w, stage.chrome]);
|
|
305
|
+
for (const spark of sparksAt(pressList, clickEffect, t)) {
|
|
306
|
+
// Each spark is drawn at its on-screen scale so the thin rays stay crisp.
|
|
307
|
+
const scale = stage.scale * view.zoom, size = Math.ceil(2 * sparkReach * scale);
|
|
308
|
+
const ctx = new OffscreenCanvas(size, size).getContext('2d');
|
|
309
|
+
ctx.scale(scale, scale);
|
|
310
|
+
drawSpark(ctx, sparkReach, sparkReach, spark.progress, clickEffect, cursor.color);
|
|
311
|
+
sparkTexture = compositor.sprite(ctx.canvas, sparkTexture, false);
|
|
312
|
+
draw(sparkTexture, [...at(spark.x - sparkReach, spark.y - sparkReach), 2 * sparkReach * stage.scale, 2 * sparkReach * stage.scale]);
|
|
313
|
+
}
|
|
314
|
+
const point = pointerAt(pointer, t);
|
|
315
|
+
if (point) draw(pointerTexture, [...at(point.x - geometry.hotspot.x - pointerSprite.margin, point.y - geometry.hotspot.y - pointerSprite.margin), pointerSprite.width * stage.scale, pointerSprite.height * stage.scale]);
|
|
316
|
+
});
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
278
321
|
/** A WritableStream that posts each positioned chunk to Node, which writes it into the Final. */
|
|
279
322
|
const uploadStream = url => new WritableStream({
|
|
280
323
|
async write(chunk) {
|
|
@@ -284,8 +327,8 @@ const uploadStream = url => new WritableStream({
|
|
|
284
327
|
});
|
|
285
328
|
|
|
286
329
|
window.cuetakeRender = async ({ sourceUrl, finalUrl, duration, viewport, pointer, events, edit }) => {
|
|
287
|
-
const { camera
|
|
288
|
-
const
|
|
330
|
+
const { camera } = edit, { quality, fps } = edit.output;
|
|
331
|
+
const { width, height } = layout(edit, viewport);
|
|
289
332
|
const started = performance.now();
|
|
290
333
|
const input = new MB.Input({ formats: MB.ALL_FORMATS, source: new MB.UrlSource(sourceUrl) });
|
|
291
334
|
const track = await input.getPrimaryVideoTrack();
|
|
@@ -311,18 +354,8 @@ window.cuetakeRender = async ({ sourceUrl, finalUrl, duration, viewport, pointer
|
|
|
311
354
|
|
|
312
355
|
let current = await reader.next(), next = await reader.next(), uploaded = null;
|
|
313
356
|
if (!current) throw new Error('Source has no video frames');
|
|
314
|
-
const
|
|
357
|
+
const scene = createScene(edit, viewport, { pointer, events }, current, track.codedWidth, track.codedHeight), { compositor } = scene;
|
|
315
358
|
const cameraPath = cameraTrack({ targets: camera.targets, viewport, camera, duration, fps, pointerAt: t => pointerAt(pointer, t) });
|
|
316
|
-
// Page CSS pixels → stage pixels; sprites are rasterized for the closest zoom and mipmapped below it.
|
|
317
|
-
const at = (x, y) => [stage.page.x + x * stage.scale, stage.page.y + y * stage.scale];
|
|
318
|
-
const sharpest = stage.scale * camera.maxZoom * 2;
|
|
319
|
-
const geometry = cursorGeometry(cursor);
|
|
320
|
-
const pointerSprite = cursorSprite(cursor, sharpest);
|
|
321
|
-
const pointerTexture = compositor.sprite(pointerSprite.canvas);
|
|
322
|
-
const chromeTexture = stage.chrome ? compositor.sprite(chromeSprite(frame, viewport.width, stage.chrome / stage.scale, stage.radius / stage.scale, sharpest)) : null;
|
|
323
|
-
const pressList = presses(events);
|
|
324
|
-
const sparkReach = clickEffect.radius + clickEffect.length + 8;
|
|
325
|
-
let sparkTexture = null;
|
|
326
359
|
const origin = current.timestamp;
|
|
327
360
|
try {
|
|
328
361
|
for (let i = 0; i < frameCount; i++) {
|
|
@@ -331,21 +364,7 @@ window.cuetakeRender = async ({ sourceUrl, finalUrl, duration, viewport, pointer
|
|
|
331
364
|
const due = origin + Math.round(i * 1e6 / fps);
|
|
332
365
|
while (next && next.timestamp <= due) { current.close(); current = next; next = await reader.next(); }
|
|
333
366
|
if (uploaded !== current) { compositor.upload(current); uploaded = current; }
|
|
334
|
-
|
|
335
|
-
compositor.frame(view.x, view.y, view.zoom, draw => {
|
|
336
|
-
if (chromeTexture) draw(chromeTexture, [stage.window.x, stage.window.y, stage.window.w, stage.chrome]);
|
|
337
|
-
for (const spark of sparksAt(pressList, clickEffect, t)) {
|
|
338
|
-
// Each spark is drawn at its on-screen scale so the thin rays stay crisp.
|
|
339
|
-
const scale = stage.scale * view.zoom, size = Math.ceil(2 * sparkReach * scale);
|
|
340
|
-
const ctx = new OffscreenCanvas(size, size).getContext('2d');
|
|
341
|
-
ctx.scale(scale, scale);
|
|
342
|
-
drawSpark(ctx, sparkReach, sparkReach, spark.progress, clickEffect, cursor.color);
|
|
343
|
-
sparkTexture = compositor.sprite(ctx.canvas, sparkTexture, false);
|
|
344
|
-
draw(sparkTexture, [...at(spark.x - sparkReach, spark.y - sparkReach), 2 * sparkReach * stage.scale, 2 * sparkReach * stage.scale]);
|
|
345
|
-
}
|
|
346
|
-
const point = pointerAt(pointer, t);
|
|
347
|
-
if (point) draw(pointerTexture, [...at(point.x - geometry.hotspot.x - pointerSprite.margin, point.y - geometry.hotspot.y - pointerSprite.margin), pointerSprite.width * stage.scale, pointerSprite.height * stage.scale]);
|
|
348
|
-
});
|
|
367
|
+
scene.draw(i / fps, cameraPath[i]);
|
|
349
368
|
const videoFrame = new VideoFrame(compositor.canvas, { timestamp: Math.round(i * 1e6 / fps), duration: Math.round(1e6 / fps) });
|
|
350
369
|
encoder.encode(videoFrame, { keyFrame: i % (fps * 2) === 0, ...(quantizer ? { avc: { quantizer } } : {}) });
|
|
351
370
|
videoFrame.close();
|
|
@@ -381,15 +400,55 @@ window.cuetakeInspect = async url => {
|
|
|
381
400
|
};
|
|
382
401
|
};
|
|
383
402
|
|
|
384
|
-
/**
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const {
|
|
403
|
+
/**
|
|
404
|
+
* A Preview as a base64 PNG: each tile's Edit composed by the same scene as Render, over the Source at
|
|
405
|
+
* `at` seconds with the Final's camera, or (`at` null) over the last moment with the camera wide.
|
|
406
|
+
*/
|
|
407
|
+
window.cuetakePreview = async ({ sourceUrl, duration, viewport, pointer, events, tiles, at }) => {
|
|
408
|
+
const input = new MB.Input({ formats: MB.ALL_FORMATS, source: new MB.UrlSource(sourceUrl) });
|
|
409
|
+
const track = await input.getPrimaryVideoTrack();
|
|
410
|
+
const sink = new MB.VideoSampleSink(track), origin = await track.getFirstTimestamp();
|
|
411
|
+
const t = at ?? duration;
|
|
412
|
+
const firstSample = await sink.getSample(origin), sample = await sink.getSample(origin + t);
|
|
413
|
+
if (!firstSample || !sample) throw new Error('Source has no video frames');
|
|
414
|
+
const firstFrame = firstSample.toVideoFrame(), frame = sample.toVideoFrame();
|
|
415
|
+
try {
|
|
416
|
+
const sheet = previewSheet(tiles.map(({ edit }) => layout(edit, viewport)));
|
|
417
|
+
const ctx = new OffscreenCanvas(sheet.width, sheet.height).getContext('2d');
|
|
418
|
+
ctx.fillStyle = '#111114'; ctx.fillRect(0, 0, sheet.width, sheet.height);
|
|
419
|
+
ctx.imageSmoothingQuality = 'high';
|
|
420
|
+
ctx.font = '600 22px system-ui, -apple-system, sans-serif'; ctx.textBaseline = 'middle'; ctx.fillStyle = '#e5e7eb';
|
|
421
|
+
tiles.forEach(({ name, edit }, i) => {
|
|
422
|
+
const scene = createScene(edit, viewport, { pointer, events }, firstFrame, track.codedWidth, track.codedHeight);
|
|
423
|
+
let crop = { x: 0, y: 0, w: viewport.width, h: viewport.height };
|
|
424
|
+
if (at !== null) {
|
|
425
|
+
const { fps } = edit.output, path = cameraTrack({ targets: edit.camera.targets, viewport, camera: edit.camera, duration, fps, pointerAt: s => pointerAt(pointer, s) });
|
|
426
|
+
crop = path[Math.min(Math.round(at * fps), path.length - 1)] ?? crop;
|
|
427
|
+
}
|
|
428
|
+
scene.compositor.upload(frame);
|
|
429
|
+
scene.draw(t, crop);
|
|
430
|
+
// Copy before yielding: the WebGL canvas does not keep its drawing buffer.
|
|
431
|
+
const tile = sheet.tiles[i];
|
|
432
|
+
ctx.drawImage(scene.compositor.canvas, tile.x, tile.y, tile.w, tile.h);
|
|
433
|
+
if (tile.label) ctx.fillText(name, tile.label.x, tile.label.y);
|
|
434
|
+
scene.compositor.dispose();
|
|
435
|
+
});
|
|
436
|
+
return await pngBase64(ctx.canvas);
|
|
437
|
+
} finally { firstFrame.close(); frame.close(); firstSample.close(); sample.close(); }
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
async function pngBase64(canvas) {
|
|
390
441
|
const blob = canvas.convertToBlob ? await canvas.convertToBlob({ type: 'image/png' }) : await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
|
|
391
442
|
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
392
443
|
let binary = '';
|
|
393
444
|
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
394
445
|
return btoa(binary);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** One Final frame at `seconds`, as a base64 PNG. */
|
|
449
|
+
window.cuetakeFrame = async (url, seconds) => {
|
|
450
|
+
const input = new MB.Input({ formats: MB.ALL_FORMATS, source: new MB.UrlSource(url) });
|
|
451
|
+
const wrapped = await new MB.CanvasSink(await input.getPrimaryVideoTrack()).getCanvas(seconds);
|
|
452
|
+
if (!wrapped) throw new Error(`No frame at ${seconds} s`);
|
|
453
|
+
return pngBase64(wrapped.canvas);
|
|
395
454
|
};
|
package/src/render.js
CHANGED
|
@@ -71,6 +71,15 @@ export async function renderFinal({ sourcePath, finalPath, timeline, edit }) {
|
|
|
71
71
|
} finally { await handle.close(); }
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/** A Preview PNG of `tiles` ([{ name, edit }]) at `at` seconds, or at the end with the camera wide. No Final is touched. */
|
|
75
|
+
export async function composePreview({ sourcePath, timeline, tiles, at }) {
|
|
76
|
+
const png = await withRenderPage({ files: { source: sourcePath } }, page => page.evaluate(options => window.cuetakePreview(options), {
|
|
77
|
+
sourceUrl: `${ORIGIN}/files/source`, duration: timeline.duration, viewport: timeline.viewport,
|
|
78
|
+
pointer: timeline.pointer ?? [], events: timeline.events ?? [], tiles, at: at ?? null,
|
|
79
|
+
}));
|
|
80
|
+
return Buffer.from(png, 'base64');
|
|
81
|
+
}
|
|
82
|
+
|
|
74
83
|
/** Container metadata of a Final plus a full decode. */
|
|
75
84
|
export function inspectFinal(path) {
|
|
76
85
|
return withRenderPage({ files: { final: path } }, page => page.evaluate(url => window.cuetakeInspect(url), `${ORIGIN}/files/final`));
|
package/src/stage.js
CHANGED
|
@@ -92,3 +92,23 @@ export function brandHue(rgba) {
|
|
|
92
92
|
const hue = max === r ? 60 * (((g - b) / d) % 6) : max === g ? 60 * ((b - r) / d + 2) : 60 * ((r - g) / d + 4);
|
|
93
93
|
return (hue + 360) % 360;
|
|
94
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Where Preview tiles sit on one sheet, in sheet pixels. A single tile is the sheet; several are shown
|
|
98
|
+
* at half size in a grid of up to three columns, each with its label above it. Each row is as tall as
|
|
99
|
+
* its tallest tile, so a portrait tile does not stretch the other rows.
|
|
100
|
+
*/
|
|
101
|
+
export function previewSheet(sizes) {
|
|
102
|
+
if (sizes.length === 1) return { width: sizes[0].width, height: sizes[0].height, tiles: [{ x: 0, y: 0, w: sizes[0].width, h: sizes[0].height, label: null }] };
|
|
103
|
+
const scale = 0.5, gap = 32, label = 44;
|
|
104
|
+
const columns = sizes.length <= 4 ? 2 : 3, cellWidth = Math.max(...sizes.map(s => s.width)) * scale;
|
|
105
|
+
const rows = Array.from({ length: Math.ceil(sizes.length / columns) }, (_, row) => Math.max(...sizes.slice(row * columns, (row + 1) * columns).map(s => s.height)) * scale);
|
|
106
|
+
const rowTop = rows.map((_, row) => gap + rows.slice(0, row).reduce((sum, h) => sum + label + h + gap, 0));
|
|
107
|
+
return {
|
|
108
|
+
width: gap + columns * (cellWidth + gap), height: rowTop.at(-1) + label + rows.at(-1) + gap,
|
|
109
|
+
tiles: sizes.map(({ width, height }, i) => {
|
|
110
|
+
const x = gap + (i % columns) * (cellWidth + gap) + (cellWidth - width * scale) / 2, y = rowTop[Math.floor(i / columns)];
|
|
111
|
+
return { x, y: y + label, w: width * scale, h: height * scale, label: { x, y: y + label / 2 } };
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
}
|
package/skills/cuetake/SKILL.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cuetake
|
|
3
|
-
description: Plan, record, refine, and verify browser product demo videos with the CueTake CLI, including login preparation and camera/cursor styling.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# CueTake agent operating manual
|
|
7
|
-
|
|
8
|
-
CueTake is a local execution engine for AI agents. You direct the story; CueTake captures the browser and renders the finished take. Run every command through `scripts/cuetake` in this skill's folder; it launches the pinned CueTake version with `npx`. Read [scenarios.md](scenarios.md) when writing a scenario, [authentication.md](authentication.md) when a page needs login, and [setup.md](setup.md) when Node or `npx` is missing or `doctor` reports a failed check.
|
|
9
|
-
|
|
10
|
-
## Workflow
|
|
11
|
-
|
|
12
|
-
1. Infer the audience, demonstrated outcome, duration and framing from the request. Inspect the actual application with the available browser tool; use real locators and measured canvas coordinates.
|
|
13
|
-
2. Run `doctor`. If it fails, follow [setup.md](setup.md): nothing installs without the user's agreement. This does not start the application's dev server.
|
|
14
|
-
3. Write a trusted `.mjs` scenario in the business project. `prepare(page)` loads examples/assets before capture. `run(d)` performs timed interactions and returns evidence of the demonstrated changes. Never embed credentials or copied browser state in a scenario.
|
|
15
|
-
4. Run `record` with the scenario path and a new Take directory. It captures, renders and verifies in the foreground, then prints the verification report; a failure exits non-zero. Capture lasts as long as the scenario and Render adds its own time, so run it in the background when your shell would time out.
|
|
16
|
-
5. Read verification and application evidence. Inspect frames around clicks and camera transitions with `frame <take> <seconds>`, which saves a PNG you can view, and play the final MP4. Deliver the absolute final path and relevant limitations. Technical verification is not editorial approval or authorization to publish.
|
|
17
|
-
|
|
18
|
-
Run `render` after changing a take's `edit.json`. This reuses source.webm. Cursor, click effect, camera and output all live in the Edit, so restyling never requires recording again. Preserve versions by copying a take before editing it.
|
|
19
|
-
|
|
20
|
-
## Division of responsibility
|
|
21
|
-
|
|
22
|
-
- Skill: story, pacing, discovery, authorization boundaries, quality judgment, and tool usage.
|
|
23
|
-
- Scenario: site-specific selectors, actions and assertions. Store it in the business project.
|
|
24
|
-
- CLI: recording, cursor/click effects, camera math, auth-state loading, output files and verification. Do not duplicate the engine under skill scripts.
|
|
25
|
-
|
|
26
|
-
## Login
|
|
27
|
-
|
|
28
|
-
Reuse a named auth profile when the user has authorized that account for the demo. If missing or expired, run `login <profile> <login-url>` in the background; no capture runs in that window. Ask the user to complete password/SSO/2FA and then close the window; the command saves the profile when the window closes. Pass `--auth-profile <profile>` to `record`.
|
|
29
|
-
|
|
30
|
-
`prepare` must verify an authenticated page anchor before capture. If redirected to sign-in, stop and refresh the profile instead of recording login. Do not read the user's normal Chrome profile, print tokens, or put auth files into output/source control. A stored file proves only that state exists; the application decides whether the session is still valid.
|
|
31
|
-
|
|
32
|
-
## Styling and timing
|
|
33
|
-
|
|
34
|
-
Defaults: CSS viewport 1440×900, 2× capture resolution, 60 fps target, a 3840×2160 Final with the page in a browser window on the `aurora` background, 24 px white arrow. Clicks use an outlined white spark: 32 px radius, 16 px rays, 8 rays, 420 ms duration. Set `clickEffect.style: 'none'` to disable it; color follows the cursor.
|
|
35
|
-
|
|
36
|
-
The camera zooms automatically, like Screen Studio: it arrives 0.6 s before each action, frames the target with 48 px padding at up to 2×, follows the cursor while zoomed, holds 1.5 s after the last of a run of actions, and ends every Final on the wide shot. Leave at least 2 s after the last action so the result is seen in context. Use `d.focus(box, seconds)` to direct the camera at a moment; it replaces only the automatic zoom around that moment. Pass `focus: false` to an action that should not move the camera. Boxes are CSS pixels.
|
|
37
|
-
|
|
38
|
-
Capture is variable frame rate: static scenes reduce cadence and moving scenes can drop frames. Report observed stats, not a promise of 60 independent page frames each second. Capture runs headless by default; pass `--headed` to watch it. Coverage is macOS, same-document/SPA operations, no audio. Known limitation: headless Chromium renders the generic `monospace` family as Courier rather than Menlo; record with `--headed` when a page relies on it. Full document navigation during capture requires separate takes; login and other navigation may happen before capture.
|
|
39
|
-
|
|
40
|
-
## Commands
|
|
41
|
-
|
|
42
|
-
`<skill>` is this skill's folder.
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
<skill>/scripts/cuetake doctor
|
|
46
|
-
<skill>/scripts/cuetake install-browser
|
|
47
|
-
<skill>/scripts/cuetake record <scenario.mjs> --out <new-take-directory> [--auth-profile product-demo] [--headed]
|
|
48
|
-
<skill>/scripts/cuetake render <take-directory>
|
|
49
|
-
<skill>/scripts/cuetake verify <take-directory>
|
|
50
|
-
<skill>/scripts/cuetake frame <take-directory> 2.5
|
|
51
|
-
<skill>/scripts/cuetake login product-demo https://your-app.example/login
|
|
52
|
-
```
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# Login before recording
|
|
2
|
-
|
|
3
|
-
The default recorder launches an isolated browser context. It does not inherit the user's ordinary Chrome login. Use a named CueTake auth profile to restore an authorized session.
|
|
4
|
-
|
|
5
|
-
## Sequence
|
|
6
|
-
|
|
7
|
-
1. `cuetake login product-demo https://your-app.example/login` opens a separate headed browser. No recording starts. Run it in the background; it exits when the window closes.
|
|
8
|
-
2. The user completes login, including SSO/2FA, then closes the window. The command saves the state it last read and prints `saved: true`.
|
|
9
|
-
3. Record with `cuetake record <scenario.mjs> --out <new-take-directory> --auth-profile product-demo`.
|
|
10
|
-
4. In the scenario's `prepare`, wait for a reliable authenticated anchor. If it is absent or the site redirects to login, fail before capture and renew the profile.
|
|
11
|
-
|
|
12
|
-
The state loader uses Playwright `storageState`, including cookies, localStorage, and IndexedDB. See [Playwright authentication](https://playwright.dev/docs/auth).
|
|
13
|
-
|
|
14
|
-
Files live in `~/.local/share/cuetake/auth/<profile>.json` (or `CUETAKE_AUTH_DIR`). The directory is created with mode 0700; files are atomically saved with mode 0600. Files contain reusable session secrets and are not encrypted by CueTake. Never commit them, include them in a shared take, or paste their contents into agent messages. The take records only an authenticated-state boolean.
|
|
15
|
-
|
|
16
|
-
SessionStorage, device-bound sessions, passkeys, CAPTCHA, and some anti-automation SSO flows may require a different preparation path. A saved state does not bypass those controls or guarantee a session has not expired. The preferred flow remains authenticate before capture; refresh/re-authenticate when the site requires it.
|
|
17
|
-
|
|
18
|
-
Acceptance coverage: a local browser fixture verifies cookie/localStorage restore and file permissions. No real account has been logged into or exported during this implementation.
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Scenario API and take folders
|
|
2
|
-
|
|
3
|
-
A scenario is trusted JavaScript exporting `config`, optional `prepare(page)`, and `run(director)`. Do not execute scenario modules from an untrusted source.
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
export const config = {
|
|
7
|
-
name: 'product-editor',
|
|
8
|
-
url: 'http://localhost:3000/editor',
|
|
9
|
-
viewport: { width: 1440, height: 900 },
|
|
10
|
-
capture: { fps: 60, resolutionScale: 2 },
|
|
11
|
-
cursor: { style: 'arrow', size: 24, color: '#ffffff' },
|
|
12
|
-
clickEffect: { style: 'spark', radius: 32, length: 16, count: 8, duration: 420 },
|
|
13
|
-
output: { size: '2160p', aspect: '16:9', quality: 22 },
|
|
14
|
-
frame: { window: 'browser', background: 'aurora', padding: 0.08, radius: 12, shadow: true },
|
|
15
|
-
camera: {
|
|
16
|
-
maxZoom: 2,
|
|
17
|
-
minZoom: 1.2,
|
|
18
|
-
padding: 48,
|
|
19
|
-
lead: 0.6,
|
|
20
|
-
hold: 1.5,
|
|
21
|
-
chainGap: 2,
|
|
22
|
-
response: 0.6,
|
|
23
|
-
follow: true,
|
|
24
|
-
endWide: 1.5,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export async function prepare(page) {
|
|
29
|
-
// Runs before capture. Load a free example, wait for assets, open the editor.
|
|
30
|
-
await page.getByRole('button', { name: 'Use example' }).click();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function run(d) {
|
|
34
|
-
await d.at(1);
|
|
35
|
-
await d.click(d.page.getByRole('button', { name: 'Preview' }));
|
|
36
|
-
await d.at(5);
|
|
37
|
-
return { previewOpened: true }; // Prefer evidence checked against the real UI.
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Only `name` and `url` are required in config. Other fields use the shown defaults. Capture FPS accepts 30 or 60. Resolution scale accepts 1 or 2. Widths and heights must be even. There is no audio capture.
|
|
42
|
-
|
|
43
|
-
## Director
|
|
44
|
-
|
|
45
|
-
| API | Behavior |
|
|
46
|
-
| --- | --- |
|
|
47
|
-
| `page` | The isolated Playwright page; use its locators and assertions. |
|
|
48
|
-
| `at(seconds)` | Wait until a time relative to the capture start. Past times return immediately. |
|
|
49
|
-
| `wait(ms)` | Hold the current state. |
|
|
50
|
-
| `move(x, y, durationMs=500)` | Move along a smooth path using viewport CSS coordinates. |
|
|
51
|
-
| `click(locator, { duration=450, focus })` | Move to a visible locator and click. A CSS selector also works. |
|
|
52
|
-
| `type(locator, text, { msPerChar=70, focus })` | Click a field, then type with a visible per-character delay. |
|
|
53
|
-
| `drag({x,y}, {x,y}, { duration=1200, focus })` | Move to the start, press, move, then release. |
|
|
54
|
-
| `focus({x,y,width,height}, seconds?)` | Add a camera target; defaults to the current time. |
|
|
55
|
-
| `time()` | Seconds elapsed since capture started. |
|
|
56
|
-
|
|
57
|
-
`move` starts from (0,0). If preparation positioned the cursor elsewhere, initialize it with `await d.move(x, y, 0)` at the start of `run`.
|
|
58
|
-
|
|
59
|
-
The camera works like Screen Studio's auto zoom. It follows the clicks, typing and drags the page observed, whether they came from the director or from Playwright input directly:
|
|
60
|
-
|
|
61
|
-
- It arrives `lead` seconds before each action, so the zoom is in place when the action happens.
|
|
62
|
-
- Actions whose zoom windows sit within `chainGap` seconds share one zoom segment: the camera stays zoomed and moves between them instead of zooming out and back in.
|
|
63
|
-
- It holds `hold` seconds after the segment's last action (after typing ends, for typing), then returns to the wide shot.
|
|
64
|
-
- While zoomed it follows the cursor, keeping it in the central 70% of the view (`follow: false` turns this off).
|
|
65
|
-
- Movement is a critically damped spring that settles in about `response` seconds and never overshoots.
|
|
66
|
-
- Every Final ends wide: the camera heads back `endWide` seconds before the end, so leave at least 2 seconds after the last action for the result to be seen in context.
|
|
67
|
-
|
|
68
|
-
Each target is framed with `padding` CSS px around its box, zooming at most `maxZoom`; boxes too large to reach `minZoom` stay wide. Set `zoom` on a target in `edit.json` to fix it. Pass `focus: false` to an action to keep the camera wide for it; a bare number still works as the action's timing. `d.focus(box)` adds a deliberate target and, like a manual zoom in Screen Studio, replaces only the automatic targets within its own span; the rest of the Take keeps following actions. Focus boxes always use CSS pixels, even when the source is captured at 2× scale.
|
|
69
|
-
|
|
70
|
-
Use actual locators for clicks. Canvas drags often require coordinates; derive or validate them for the configured viewport. Keep setup outside capture, hold important states, and assert meaningful application changes. An exception marks the take failed and closes the isolated browser.
|
|
71
|
-
|
|
72
|
-
## Take folder
|
|
73
|
-
|
|
74
|
-
```text
|
|
75
|
-
<output>/<scenario>/<take>/
|
|
76
|
-
project.json Scenario config, status, application evidence, duration
|
|
77
|
-
scenario.mjs Snapshot of the original scenario module
|
|
78
|
-
source.webm Source: original high-resolution VP9 capture
|
|
79
|
-
capture.json Track settings and video frame callback observations
|
|
80
|
-
timeline.json Timeline: pointer path, clicks, drags, typing and focus, in seconds and CSS pixels
|
|
81
|
-
edit.json Edit: camera targets and settings, cursor, click effect, frame, output
|
|
82
|
-
poster.png Final page state at native capture resolution
|
|
83
|
-
final.mp4 Final: H.264 camera composition
|
|
84
|
-
render.json Encoder, rate control and GPU used by the last Render
|
|
85
|
-
verification.json Output metadata, decode result, capture observations
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
A copied scenario snapshot may import helper modules from its original project. It is a record of the scenario, not a bundled runnable archive. Keep business scenarios in their application repository.
|
|
89
|
-
|
|
90
|
-
To edit a completed take, change `edit.json` (camera settings, target boxes and times, cursor, click effect, frame, output), then run `cuetake render <take>`. The Scenario config only seeds the first Edit. Changing what happens on the page requires recording again. `render` automatically runs verification; `verify` checks without rendering.
|
|
91
|
-
|
|
92
|
-
`output.size` names the Final's short side (`1080p`, `1440p`, `2160p`, or an even pixel count) and `output.aspect` is `16:9`, `1:1` or `9:16`; both are independent of device scale. `frame` places the page in a window on a background: `window` is `browser` (with an address bar showing `url`, which defaults to the Scenario's host), `macos` or `none`; `background` is `aurora`, `sunset`, `ocean`, `graphite`, `paper`, `auto` (a mesh around the page's brand color) or `blur` (the page itself, blurred); `padding` is a fraction of the short side; `radius` is in 1080p pixels. Set `frame: false` to let the page fill the Final at the viewport's aspect. The camera zooms the whole stage, so background may show beside the page when a target sits near its edge. `edit.json` also carries `output.fps`, the Final's frame rate, which a new Take takes from `capture.fps`. `output.quality` is the H.264 quantizer (10–40, default 22): lower is sharper and larger. Encoders without a quantizer mode fall back to a bitrate, recorded in `render.json`.
|
|
93
|
-
|
|
94
|
-
Click effects default to a white, dark-outlined spark matching the arrow. Set style to `none` to disable. Geometry is in CSS pixels and duration is milliseconds. Login is passed separately as a named runtime auth profile, never embedded in scenario config; see [authentication.md](authentication.md).
|
package/skills/cuetake/setup.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Setting up CueTake on the user's machine
|
|
2
|
-
|
|
3
|
-
CueTake needs Node 20.10 or newer and the Chromium build its Playwright drives. Nothing installs without the user's agreement. Offer the choices below, say what each one changes and roughly how large it is, and act only after the user picks one. With the user's agreement you may run the installers yourself, including a graphical installer through computer use. The user may also prefer to install it themselves.
|
|
4
|
-
|
|
5
|
-
## Node
|
|
6
|
-
|
|
7
|
-
Check what already exists before offering anything: `node --version`, then the version managers `fnm`, `nvm`, `volta`, then `brew`. If one exists, use it:
|
|
8
|
-
|
|
9
|
-
| Found | Install Node with |
|
|
10
|
-
| --- | --- |
|
|
11
|
-
| fnm | `fnm install --lts && fnm use lts-latest` |
|
|
12
|
-
| nvm | `nvm install --lts` |
|
|
13
|
-
| volta | `volta install node` |
|
|
14
|
-
| Homebrew only | `brew install node` |
|
|
15
|
-
|
|
16
|
-
With none of them, offer:
|
|
17
|
-
|
|
18
|
-
- **fnm**, for developers who want to switch Node versions: `brew install fnm`, or the installer at https://github.com/Schniz/fnm.
|
|
19
|
-
- **Homebrew**: `brew install node`, if the user wants Homebrew anyway.
|
|
20
|
-
- **The official installer** from https://nodejs.org (LTS). It asks for the administrator password, which only the user can type.
|
|
21
|
-
|
|
22
|
-
## Browser
|
|
23
|
-
|
|
24
|
-
Run `cuetake install-browser` (about 150 MB into Playwright's cache in the user's Library). It downloads the exact build this CueTake version drives, so do not substitute `npx playwright install`, which may fetch a different build. The user's own Chrome is never used or modified.
|
|
25
|
-
|
|
26
|
-
## Check
|
|
27
|
-
|
|
28
|
-
Run `cuetake doctor` again. Every check must report `ok`; a `platform` note means that platform is not yet verified.
|