cuetake 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mcpware
4
+ Copyright (c) 2026 CueTake contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,78 @@
1
- # Temporary Holding Version
1
+ # CueTake
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Script the flow. Keep the take.**
4
+
5
+ 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.
6
+
7
+ ![A CueTake Final: the page in a browser window on a gradient, the camera zooming to the field being typed into](docs/media/demo.gif)
8
+
9
+ - Retina tab capture at 30 or 60 fps and a 2× pixel scale, headless by default.
10
+ - 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
+ - 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
+ - Cursor and click sparks drawn at Render time, so a Take can be restyled without recording again.
13
+ - Rendering in Chromium with WebGL and WebCodecs: no FFmpeg, 4K60 by default.
14
+ - A separate folder for every Take: Source, Timeline, Edit, Final MP4, and verification.
15
+
16
+ ## For AI agents
17
+
18
+ If a user hands you this repository to set up CueTake:
19
+
20
+ 1. Install the skill with `npx skills add levyxdev/cuetake`. In Claude Code you can instead run `/plugin marketplace add levyxdev/cuetake`, then `/plugin install cuetake`.
21
+ 2. The skill's `scripts/cuetake` runs the pinned [`cuetake`](https://www.npmjs.com/package/cuetake) package with `npx`, so nothing else needs installing besides Node. To run a source checkout instead, export `CUETAKE_BIN="node /absolute/path/to/cuetake/src/cli.js"`.
22
+ 3. Follow the skill's [setup guide](skills/cuetake/setup.md): run `scripts/cuetake doctor`, and install Node or the browser only after the user agrees to the option they pick.
23
+ 4. Write a Scenario for the user's product with the [scenario API](skills/cuetake/scenarios.md), record it, and review the frames with `scripts/cuetake frame`.
24
+
25
+ ## Run from source
26
+
27
+ Requirements: Bun for development (users run the CLI on Node 20.10+) and the Chromium build CueTake's Playwright drives. Verified on macOS, headless and headed.
28
+
29
+ ```sh
30
+ bun install --frozen-lockfile
31
+ bun run doctor
32
+ # Only if doctor reports Chromium missing (about 150 MB):
33
+ bun src/cli.js install-browser
34
+
35
+ bun src/cli.js record examples/basic.mjs --out ./recordings/first-take
36
+ ```
37
+
38
+ The example opens `https://example.com` only for a stable HTTPS origin, then replaces the page with a small invite form, types an email and sends it, so it works without a local application server. For your own product, write a scenario using the [scenario API](skills/cuetake/scenarios.md).
39
+
40
+ Playwright is a local package dependency. Browser binaries use Playwright's normal OS cache. CueTake does not install global packages or start your application server.
41
+
42
+ ## Commands
43
+
44
+ ```sh
45
+ bun src/cli.js doctor
46
+ bun src/cli.js install-browser
47
+ bun src/cli.js record ./my-scenario.mjs --out ./recordings/my-take [--headed]
48
+ bun src/cli.js render ./recordings/my-take
49
+ bun src/cli.js verify ./recordings/my-take
50
+ bun src/cli.js frame ./recordings/my-take 2.5
51
+ bun src/cli.js login product-demo https://your-app.example/login
52
+ ```
53
+
54
+ `record` completes capture → render → verification and refuses an existing output folder. `render` uses the saved Source, Timeline and Edit; it replaces the final video only after encoding succeeds. Copy a Take folder to keep several edits.
55
+
56
+ A successful command is a technical check, not an editorial approval. Watch the result before publishing.
57
+
58
+ ## How it works
59
+
60
+ Playwright drives an isolated Chromium tab. Chromium captures the tab at device-pixel resolution using `getDisplayMedia`; a VP9 `MediaRecorder` saves the source. An in-page probe records the pointer path, clicks, drags and typing into the Timeline. Render then composes the camera path in a headless Chromium page with WebGL and encodes H.264 with WebCodecs; see [ADR 0001](docs/adr/0001-render-in-browser-with-webgl-and-webcodecs.md).
61
+
62
+ Source capture is variable frame rate. Static scenes may drop to approximately one captured frame per second, and busy scenes can drop frames. A 60 fps output does not imply 60 unique source frames every second. Capture callback statistics and output metadata are retained in each take. No motion interpolation is used.
63
+
64
+ ## Current scope
65
+
66
+ The supported workflow is a short, same-document browser demo, including SPA interactions. A full page navigation or reload destroys the in-page recorder; record those as separate takes. Audio and desktop/window capture are outside this workflow. Input inside cross-origin iframes is not seen by the Timeline probe, so the cursor and camera do not follow it there. Headless Chromium renders the generic `monospace` family as Courier rather than Menlo; record with `--headed` when a page relies on it. Browser automation and captured data stay local; the visited website still receives normal browser requests.
67
+
68
+ The bundled [agent skill](skills/cuetake/SKILL.md) teaches planning and operation; site-specific scenarios stay in your application project. See [distribution](docs/distribution.md) and [login](skills/cuetake/authentication.md).
69
+
70
+ ## Development
71
+
72
+ ```sh
73
+ bun test tests/pipeline.test.js
74
+ # With Playwright Chromium installed:
75
+ bun test tests/browser.test.js
76
+ ```
77
+
78
+ `pipeline.test.js` covers configuration and camera math; `browser.test.js` covers the probe, Auth profiles, and Render geometry, cursor and sparks at a 2× capture scale. No build step is required. Do not commit recordings, browser profiles, credentials, or product-specific scenarios into this generic tool repository.
@@ -0,0 +1,47 @@
1
+ // example.com only supplies a stable HTTPS origin. prepare() replaces the page
2
+ // with a self-contained fixture, so this take never depends on that site's markup.
3
+ export const config = { name: 'basic', url: 'https://example.com' };
4
+
5
+ const fixture = `<!doctype html>
6
+ <style>
7
+ body { margin:0; height:100vh; display:grid; place-items:center; font:16px/1.5 system-ui, sans-serif;
8
+ background:linear-gradient(135deg,#eef2ff,#fdf2f8); color:#111827 }
9
+ .card { width:460px; padding:32px; border-radius:20px; background:white; box-shadow:0 20px 50px #1f29371f }
10
+ h1 { margin:0 0 4px; font-size:24px } p { margin:0 0 24px; color:#6b7280 }
11
+ label { display:block; margin-bottom:6px; font-size:14px; font-weight:600 }
12
+ input { box-sizing:border-box; width:100%; padding:12px 14px; border:1px solid #d1d5db; border-radius:10px; font:inherit }
13
+ input:focus { outline:2px solid #6366f1; border-color:transparent }
14
+ button { margin-top:20px; width:100%; padding:14px; border:0; border-radius:10px; background:#4f46e5; color:white; font:600 16px system-ui }
15
+ .toast { margin-top:20px; padding:12px 14px; border-radius:10px; background:#ecfdf5; color:#065f46; display:none }
16
+ </style>
17
+ <main class="card">
18
+ <h1>Invite a teammate</h1>
19
+ <p>They will get access to the Launch workspace.</p>
20
+ <label for="email">Email</label>
21
+ <input id="email" type="email" placeholder="name@company.com">
22
+ <button>Send invite</button>
23
+ <div class="toast" role="status"></div>
24
+ </main>
25
+ <script>
26
+ document.querySelector('button').onclick = () => {
27
+ const toast = document.querySelector('.toast');
28
+ toast.textContent = 'Invite sent to ' + document.querySelector('#email').value;
29
+ toast.style.display = 'block';
30
+ };
31
+ </script>`;
32
+
33
+ export async function prepare(page) {
34
+ await page.setContent(fixture);
35
+ }
36
+
37
+ export async function run(d) {
38
+ await d.move(720, 640, 0);
39
+ await d.at(0.8);
40
+ await d.type(d.page.getByLabel('Email'), 'ada@example.com');
41
+ await d.wait(400);
42
+ await d.click(d.page.getByRole('button', { name: 'Send invite' }));
43
+ await d.wait(3000);
44
+ const status = await d.page.getByRole('status').textContent();
45
+ if (status !== 'Invite sent to ada@example.com') throw new Error(`Unexpected status: ${status}`);
46
+ return { status };
47
+ }
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "cuetake",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Local recording runtime for AI agents: plan a browser demo, capture it, and render a finished take.",
5
+ "type": "module",
6
+ "bin": {
7
+ "cuetake": "./src/cli.js"
8
+ },
9
+ "files": [
10
+ "src",
11
+ "skills",
12
+ "examples",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "start": "bun src/cli.js",
18
+ "test": "bun test tests/pipeline.test.js",
19
+ "doctor": "bun src/cli.js doctor"
20
+ },
21
+ "keywords": [
22
+ "browser",
23
+ "recording",
24
+ "demo",
25
+ "playwright",
26
+ "cuetake"
27
+ ],
28
+ "author": "CueTake contributors",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/levyxdev/cuetake.git"
33
+ },
34
+ "homepage": "https://github.com/levyxdev/cuetake",
35
+ "dependencies": {
36
+ "mediabunny": "1.62.0",
37
+ "playwright": "1.63.0",
38
+ "zod": "^3.23.0"
39
+ },
40
+ "engines": {
41
+ "node": ">=20.10.0"
42
+ },
43
+ "packageManager": "bun@1.3.14"
44
+ }
@@ -0,0 +1,52 @@
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
+ ```
@@ -0,0 +1,18 @@
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.
@@ -0,0 +1,94 @@
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).
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ # Runs the CueTake CLI pinned to the version this skill was released with.
3
+ # CUETAKE_BIN overrides the command, e.g. CUETAKE_BIN="node /path/to/cuetake/src/cli.js" for a source checkout.
4
+ exec ${CUETAKE_BIN:-npx -y cuetake@0.1.0} "$@"
@@ -0,0 +1,28 @@
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.
package/src/auth.js ADDED
@@ -0,0 +1,48 @@
1
+ import { chromium } from 'playwright';
2
+ import fs from 'node:fs/promises';
3
+ import { homedir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { randomUUID } from 'node:crypto';
6
+ import { setTimeout as sleep } from 'node:timers/promises';
7
+ const root = () => process.env.CUETAKE_AUTH_DIR || join(homedir(), '.local/share/cuetake/auth');
8
+ function profilePath(profile) {
9
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(profile)) throw new Error('Use a short lowercase profile name, such as product-demo');
10
+ return join(root(), `${profile}.json`);
11
+ }
12
+ export async function resolveAuthProfile(profile) {
13
+ const path = profilePath(profile);
14
+ await fs.access(path).catch(() => { throw new Error(`Auth profile '${profile}' is missing. Run: cuetake login ${profile} <login-url>`); });
15
+ return path;
16
+ }
17
+ /** Accepts a browser context or an already-read storage state. */
18
+ export async function saveAuthState(source, profile) {
19
+ const path = profilePath(profile);
20
+ await fs.mkdir(root(), { recursive: true, mode: 0o700 });
21
+ const state = typeof source.storageState === 'function' ? await source.storageState({ indexedDB: true }) : source;
22
+ const temporary = `${path}.${randomUUID()}.tmp`;
23
+ try {
24
+ await fs.writeFile(temporary, JSON.stringify(state), { mode: 0o600 });
25
+ await fs.rename(temporary, path);
26
+ } finally { await fs.rm(temporary, { force: true }); }
27
+ return { profile, saved: true, note: 'Auth profile saved locally. Confirm authentication against the target page before recording.' };
28
+ }
29
+ /** Opens a headed login window and saves its state when the user closes the window. */
30
+ export async function login(url, profile) {
31
+ profilePath(profile);
32
+ if (!/^https?:$/.test(new URL(url).protocol)) throw new Error('Login requires HTTP(S)');
33
+ const browser = await chromium.launch({ headless: false });
34
+ try {
35
+ const context = await browser.newContext();
36
+ const page = await context.newPage();
37
+ await page.goto(url, { waitUntil: 'domcontentloaded' });
38
+ console.error('Complete login in the opened browser, then close its window. No recording is active.');
39
+ // The window can close at any moment, so keep the latest readable state and save that.
40
+ let state, open = true;
41
+ const closed = new Promise(resolve => { page.once('close', resolve); browser.once('disconnected', resolve); }).then(() => { open = false; });
42
+ while (open) {
43
+ state = await context.storageState({ indexedDB: true }).catch(() => state);
44
+ await Promise.race([closed, sleep(1000)]);
45
+ }
46
+ return await saveAuthState(state, profile);
47
+ } finally { await browser.close().catch(() => {}); }
48
+ }
package/src/camera.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Camera math shared by Node and the render page. Pure functions, no imports.
3
+ *
4
+ * Modeled on Screen Studio's auto zoom: zooms come from actions; actions close together form one
5
+ * zoom segment that moves between them and follows the cursor; the camera moves on a critically
6
+ * damped spring, so it never overshoots and settles quickly enough to keep text readable. Because
7
+ * the whole Timeline is known in advance, the camera starts moving `lead` seconds before each
8
+ * action and every Final ends on the wide shot.
9
+ *
10
+ * Everything here is in CSS pixels of the captured viewport and seconds since capture start.
11
+ */
12
+
13
+ const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
14
+ const SAFE_AREA = 0.7; // while zoomed, the cursor stays within this central fraction of the view
15
+
16
+ /** The zoom that frames `box` with `padding` on every side, between 1 and `maxZoom`. */
17
+ export function fitZoom(box, viewport, { maxZoom, padding }) {
18
+ return clamp(Math.min(viewport.width / (box.width + 2 * padding), viewport.height / (box.height + 2 * padding)), 1, maxZoom);
19
+ }
20
+
21
+ /** The viewport crop centered on (x, y) at `zoom`, kept inside the viewport. */
22
+ export function cropAround(x, y, zoom, viewport) {
23
+ zoom = Math.max(1, zoom);
24
+ const w = viewport.width / zoom, h = viewport.height / zoom;
25
+ return { x: clamp(x - w / 2, 0, viewport.width - w), y: clamp(y - h / 2, 0, viewport.height - h), w, h };
26
+ }
27
+
28
+ /**
29
+ * Zoom segments: each target wants the camera from `lead` before it until `hold` after it (or after
30
+ * its typing ends); targets whose windows touch or sit within `chainGap` share one segment. Segments
31
+ * stop `endWide` before the Final ends, and targets that would barely zoom (below `minZoom`) stay wide.
32
+ */
33
+ export function zoomSegments(targets, viewport, camera, duration) {
34
+ const { lead, hold, chainGap, minZoom, endWide } = camera;
35
+ const last = duration - endWide;
36
+ const segments = [];
37
+ for (const target of targets.toSorted((a, b) => a.t - b.t)) {
38
+ const zoom = target.zoom ?? fitZoom(target.box, viewport, camera);
39
+ if (zoom < minZoom || target.t - lead >= last) continue;
40
+ const shot = { t: target.t, box: target.box, zoom };
41
+ const start = Math.max(0, target.t - lead), end = Math.min(last, Math.max(target.t, target.until ?? target.t) + hold);
42
+ const segment = segments.at(-1);
43
+ if (segment && start - segment.end <= chainGap) { segment.shots.push(shot); segment.end = Math.max(segment.end, end); }
44
+ else segments.push({ start, end, shots: [shot] });
45
+ }
46
+ return segments;
47
+ }
48
+
49
+ /** Where the camera wants to be at `t` (center and zoom) before spring smoothing. `pointerAt(t)` may be null. */
50
+ export function intentAt(segments, viewport, camera, t, pointerAt) {
51
+ const segment = segments.find(s => t >= s.start && t < s.end);
52
+ if (!segment) return { x: viewport.width / 2, y: viewport.height / 2, zoom: 1 };
53
+ // Move to each shot `lead` before its action, so the camera arrives as the action happens.
54
+ const shot = segment.shots.findLast(s => s.t - camera.lead <= t) ?? segment.shots[0];
55
+ const { zoom } = shot;
56
+ const half = { x: viewport.width / (2 * zoom), y: viewport.height / (2 * zoom) };
57
+ let x = shot.box.x + shot.box.width / 2, y = shot.box.y + shot.box.height / 2;
58
+ const pointer = camera.follow ? pointerAt?.(t) : null;
59
+ if (pointer) {
60
+ x = clamp(x, pointer.x - half.x * SAFE_AREA, pointer.x + half.x * SAFE_AREA);
61
+ y = clamp(y, pointer.y - half.y * SAFE_AREA, pointer.y + half.y * SAFE_AREA);
62
+ }
63
+ return { x: clamp(x, half.x, viewport.width - half.x), y: clamp(y, half.y, viewport.height - half.y), zoom };
64
+ }
65
+
66
+ /**
67
+ * The visible viewport crop for every output frame. The intent is followed by a critically damped
68
+ * spring on center and log-zoom that settles in about `response` seconds.
69
+ */
70
+ export function cameraTrack({ targets, viewport, camera, duration, fps, pointerAt }) {
71
+ const segments = zoomSegments(targets, viewport, camera, duration);
72
+ const omega = 4 / camera.response, steps = 4, dt = 1 / (fps * steps);
73
+ const start = intentAt(segments, viewport, camera, 0, pointerAt);
74
+ const state = { x: start.x, y: start.y, z: Math.log(start.zoom) }, velocity = { x: 0, y: 0, z: 0 };
75
+ const track = [];
76
+ for (let i = 0, frames = Math.round(duration * fps); i < frames; i++) {
77
+ const goal = intentAt(segments, viewport, camera, i / fps, pointerAt);
78
+ const target = { x: goal.x, y: goal.y, z: Math.log(goal.zoom) };
79
+ for (let step = 0; step < steps; step++) for (const key of ['x', 'y', 'z']) {
80
+ velocity[key] += (omega * omega * (target[key] - state[key]) - 2 * omega * velocity[key]) * dt;
81
+ state[key] += velocity[key] * dt;
82
+ }
83
+ track.push(cropAround(state.x, state.y, Math.exp(state.z), viewport));
84
+ }
85
+ return track;
86
+ }
package/src/cli.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ import pkg from '../package.json' with { type: 'json' };
4
+ import { recordScenario, renderTake, verifyTake } from './pipeline.js';
5
+ import { doctor, installBrowser } from './environment.js';
6
+ import { login } from './auth.js';
7
+ import { extractFrame } from './render.js';
8
+ import { writeFile } from 'node:fs/promises';
9
+ import { join, resolve } from 'node:path';
10
+
11
+ const help = `CueTake ${pkg.version} — browser demos directed by code
12
+
13
+ cuetake doctor
14
+ cuetake install-browser
15
+ cuetake record <scenario.mjs> [--out <new-directory>] [--auth-profile <name>] [--headed]
16
+ cuetake render <take-directory>
17
+ cuetake verify <take-directory>
18
+ cuetake frame <take-directory> <seconds> [--out <file.png>]
19
+ cuetake login <profile> <login-url>
20
+
21
+ install-browser downloads the Chromium build this CueTake version drives (about 150 MB).
22
+ record captures, renders and verifies a new take; an existing directory is never overwritten.
23
+ Capture runs headless; --headed shows the browser window while recording.
24
+ render reuses source.webm, timeline.json and edit.json, replacing final.mp4 only on success.
25
+ frame saves one Final frame as a PNG for inspection.
26
+ login opens a separate browser; close its window after logging in to save the profile.
27
+ Scenario files are trusted JavaScript. Recording runs locally, without audio.
28
+ `;
29
+ 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;
32
+ if (values.help || !command) console.log(help);
33
+ else if (command === 'doctor') { const result = await doctor(); console.log(JSON.stringify(result, null, 2)); if (!result.ok) process.exitCode = 1; }
34
+ else if (command === 'install-browser') console.log(JSON.stringify(await installBrowser(), null, 2));
35
+ else if (command === 'record' && target) console.log(JSON.stringify(await recordScenario(target, values.out, { authProfile: values['auth-profile'], headed: values.headed }), null, 2));
36
+ else if (command === 'render' && target) { await renderTake(target); console.log(JSON.stringify(await verifyTake(target), null, 2)); }
37
+ else if (command === 'verify' && target) console.log(JSON.stringify(await verifyTake(target), null, 2));
38
+ else if (command === 'frame' && target && positionals[2]) {
39
+ const out = resolve(values.out || join(target, `frame-${positionals[2]}s.png`));
40
+ await writeFile(out, await extractFrame(join(target, 'final.mp4'), Number(positionals[2])));
41
+ console.log(out);
42
+ }
43
+ else if (command === 'login' && target && positionals[2]) console.log(JSON.stringify(await login(positionals[2], target), null, 2));
44
+ else throw new Error(`Unknown or incomplete command.\n${help}`);
45
+ } catch (error) { console.error(`CueTake: ${error.message}`); process.exitCode = 1; }