cuetake 0.6.0 → 0.7.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 CHANGED
@@ -21,7 +21,7 @@ https://github.com/user-attachments/assets/a4a56ac4-2ef4-476c-b9d7-de8142f98984
21
21
 
22
22
  If a user hands you this repository to set up CueTake:
23
23
 
24
- 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`.
24
+ 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`. The skill loads only when you call it, with `/cuetake` in Claude Code, `$cuetake` in Codex or `@cuetake` in ChatGPT, so it stays out of sessions that do not record demos.
25
25
  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"`.
26
26
  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.
27
27
  4. Write a Scenario for the user's product with the [scenario API](skills/cuetake/scenarios.md), record it, and read the verification report it prints.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cuetake",
3
- "version": "0.6.0",
3
+ "version": "0.7.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": {
package/src/director.js CHANGED
@@ -2,6 +2,7 @@ import { ease, landing, pauseMs, random, reach, scrollMs, typingDelays } from '.
2
2
  import { boxOnPage, onPage, placeOf } from './frames.js';
3
3
  import { carried, seenBy, windowMaps } from './tabs.js';
4
4
  import { EFFECT_NAMES, MASK_EFFECTS } from './masks.js';
5
+ import { wordInLine } from './narration.js';
5
6
 
6
7
  /** Milliseconds between the Director's checks of what a mask's locator matches, so a replaced element is followed. */
7
8
  const REWATCH_MS = 100;
@@ -119,6 +120,9 @@ function scrollPlan(target, { block, inline, point, margin }) {
119
120
  return { steps };
120
121
  }
121
122
 
123
+ /** How long after the voice said a word the Scenario may wait for it before `verify` warns. */
124
+ const LATE_WORD_S = 0.2;
125
+
122
126
  /** Options may be a bare number for the action's main timing; `focus: false` keeps the camera wide. */
123
127
  export const options = (value, key) => typeof value === 'number' ? { [key]: value } : value ?? {};
124
128
 
@@ -147,21 +151,42 @@ export function clockOf({ startedAt, voiced = null }, { focus: focusTargets, sai
147
151
  try { return await action(); }
148
152
  finally { forwarded.push({ t: state.forwarding.t, end: time(), rate }); state.forwarding = null; }
149
153
  }
150
- /** Starts a Line. With a Narration it holds for the Line's audio, so the picture follows the voice. */
151
- async function say(id, text) {
152
- const t = time(), earlier = said.find(line => line.id === id);
153
- if (earlier) throw new Error(`Line '${id}' was already said at ${earlier.t.toFixed(2)} s`);
154
- if (state.forwarding) throw new Error(`Line '${id}' is said inside d.fastForward, which the Final plays faster than speech; say it before the wait`);
155
- if (voiced) {
156
- if (!voiced.has(id)) throw new Error(`The Narration has no Line '${id}'; its Lines are ${[...voiced.keys()].join(', ')}`);
157
- said.push({ t, id });
158
- await wait((t + voiced.get(id)) * 1000 - (Date.now() - startedAt));
159
- } else {
160
- if (typeof text !== 'string' || !text) throw new Error(`d.say('${id}') needs the Line's text when recording without --narration`);
161
- said.push({ t, id, text });
154
+ const at = seconds => wait(seconds * 1000 - (Date.now() - startedAt));
155
+ /**
156
+ * Starts a Line. With a Narration it holds for the Line's audio, so the picture follows the voice.
157
+ * The promise's `word(text)` resolves when the voice reaches `text`, each looked for after the last.
158
+ */
159
+ function say(id, text) {
160
+ const t = time();
161
+ let line, entry, from = 0;
162
+ try {
163
+ const earlier = said.find(previous => previous.id === id);
164
+ if (earlier) throw new Error(`Line '${id}' was already said at ${earlier.t.toFixed(2)} s`);
165
+ if (state.forwarding) throw new Error(`Line '${id}' is said inside d.fastForward, which the Final plays faster than speech; say it before the wait`);
166
+ if (voiced) {
167
+ if (!voiced.has(id)) throw new Error(`The Narration has no Line '${id}'; its Lines are ${[...voiced.keys()].join(', ')}`);
168
+ said.push(entry = { t, id });
169
+ line = voiced.get(id);
170
+ } else {
171
+ if (typeof text !== 'string' || !text) throw new Error(`d.say('${id}') needs the Line's text when recording without --narration`);
172
+ said.push({ t, id, text });
173
+ line = { id, text, duration: 0 };
174
+ }
175
+ } catch (error) {
176
+ return Object.assign(Promise.reject(error), { word: () => Promise.reject(error) });
177
+ }
178
+ async function word(phrase) {
179
+ if (typeof phrase !== 'string' || !phrase) throw new Error(`d.say('${id}').word() needs the text to wait for`);
180
+ const found = wordInLine(line, phrase, from);
181
+ from = found.next;
182
+ if (!voiced) return;
183
+ const spoken = t + found.at, late = time() - spoken;
184
+ if (late > LATE_WORD_S) (entry.late ??= []).push({ text: phrase, t: spoken, by: late });
185
+ await at(spoken);
162
186
  }
187
+ return Object.assign(voiced ? at(t + line.duration) : Promise.resolve(), { word });
163
188
  }
164
- return { state, wait, time, at: seconds => wait(seconds * 1000 - (Date.now() - startedAt)), focus, fastForward, say };
189
+ return { state, wait, time, at, focus, fastForward, say };
165
190
  }
166
191
 
167
192
  /**
@@ -171,7 +196,7 @@ export function clockOf({ startedAt, voiced = null }, { focus: focusTargets, sai
171
196
  * where each Line starts (`said`),
172
197
  * each fast-forwarded wait (`forwarded`) and the pointer path no Tab could see (`pointer`, as
173
198
  * [epoch ms, x, y, tab]), and each element masked (`elements`, { id, tab, name }) with its mask
174
- * (`masks`). `voiced` maps the Narration's Line ids to their audio's seconds, or is null
199
+ * (`masks`). `voiced` maps the Narration's Line ids to their Lines ({ id, text, duration, words? }), or is null
175
200
  * without one. `speed` scales every move, pause and typing delay it chooses; `seed` picks one of many
176
201
  * equally human ways to move. `signal` aborts once the Scenario has run, when masks stop following.
177
202
  */
package/src/narration.js CHANGED
@@ -82,6 +82,20 @@ function clock(line) {
82
82
  return { start: k => at(k, false), end: k => at(k, true) };
83
83
  }
84
84
 
85
+ /**
86
+ * Where `text` is said in `line`, a case-insensitive substring of its text found at or after
87
+ * character `from`: `at` is seconds from the start of the Line's audio, by the clock Subtitles use,
88
+ * and `next` is where to look for the next word.
89
+ */
90
+ export function wordInLine(line, text, from = 0) {
91
+ // A case-insensitive match on the text itself, so indices stay those of the text in every language.
92
+ const pattern = new RegExp(text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'giu');
93
+ pattern.lastIndex = from;
94
+ const match = pattern.exec(line.text), index = match?.index ?? -1;
95
+ if (index < 0) throw new Error(`Line '${line.id}' does not say '${text}'${from ? ' after the word before' : ''}; its text is "${line.text}"`);
96
+ return { at: clock(line).start(spoken(line.text.slice(0, index))), next: index + match[0].length };
97
+ }
98
+
85
99
  /**
86
100
  * Subtitle cues for placed Lines: each Line's rows, `maxRows` to a cue (a cue also ends after a
87
101
  * sentence), shown while they are spoken. A cue shorter than `minDuration` takes time from the next
package/src/pipeline.js CHANGED
@@ -284,7 +284,7 @@ export async function recordScenario(scenarioPath, outputDir, options = {}) {
284
284
  try {
285
285
  // The Narration is voiced before Capture, so d.say can hold each Line for its audio (ADR 0006).
286
286
  const imported = options.narration ? await intoTakeNarration(options.narration, dir) : null;
287
- const voiced = imported && new Map(Object.entries(imported.durations));
287
+ const voiced = imported && new Map(imported.narration.lines.map(line => [line.id, { ...line, duration: imported.durations[line.id] }]));
288
288
  captured = config.app ? await captureApp(scenario, config, dir, { voiced, useRunning: options.useRunning }) : await capturePage(scenario, config, dir, { authState, headed: options.headed, voiced });
289
289
  const { timeline, notes: { focus, wide }, evidence } = captured;
290
290
  await writeJson(join(dir, 'timeline.json'), timeline);
@@ -478,7 +478,7 @@ export function captureWarnings(capture, scale, tab = null) {
478
478
  /**
479
479
  * Warns when input landed inside an iframe Capture could not place exactly: one rotated, skewed or
480
480
  * 3D-transformed, placed as if it were only scaled, or one it could not place at all, which the Cursor
481
- * and camera do not follow.
481
+ * and camera do not follow; and when the Scenario waited for a word of a Line after the voice said it.
482
482
  */
483
483
  export function timelineWarnings(timeline) {
484
484
  const { turned = [], unplaced = [] } = timeline.frameInput ?? {};
@@ -486,6 +486,8 @@ export function timelineWarnings(timeline) {
486
486
  return [
487
487
  turned.length && `Input at ${at(turned)} landed inside an iframe that is rotated, skewed or 3D-transformed, which Capture places as if it were only scaled, so the Cursor and camera there may sit off what the page shows. Check those moments with frame, and record again once the iframe is upright, after any opening animation.`,
488
488
  unplaced.length && `Input at ${at(unplaced)} landed inside an iframe Capture could not place, so the Cursor and camera do not follow it there. Check those moments with frame.`,
489
+ ...(timeline.events ?? []).filter(event => event.type === 'say').flatMap(line => (line.late ?? []).map(word =>
490
+ `Line '${line.id}' said '${word.text}' at ${word.t.toFixed(2)} s, but the Scenario waited for it ${word.by.toFixed(2)} s later, so what follows lands after the voice. Start the actions before that word sooner, or wait for an earlier word.`)),
489
491
  ].filter(Boolean);
490
492
  }
491
493