@devries-cameron20 / t3code Mirror · read-only / commits / 77a553ab2c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

chore(skills): launch-video staging tools for seeded data and gestures (#40000)

Julius Marminge committed Nov 20, 2026 at 17:57 UTC 77a553ab2cd861db9eb51c026fa8ab353f0187c9
8 files changed +203 -35
.agents/skills/launch-video/SKILL.md
+22 -6
@@ -39,10 +39,21 @@ There are two ways to build one:
39 and tool rows. Each turn is `{ match, steps }`: `think`, `text`, `bash` (+ `output`, `ms`),
40 `wait`, and `tool` (+ `input`), which calls that T3 MCP tool for real, e.g.
41 `delegate_task`. Match generated titles with a `{ match: "title", repeat: true }` turn.
42 - `<var:name>` is filled from the JSON file at `T3_DEV_REPLAY_VARS`, for ids that change
42 + `<var:name>` is filled from the JSON file at `FAKE_CLAUDE_VARS`, for ids that change
43 every run. `fake-claude.log` in the home records the protocol, for debugging.
44 - - The free replay agent (`apps/server/scripts/dev-replay-agent.ts`) still works without
45 - `claude`, but it shows as an ACP provider.
44 + - Data a real flow can't produce cheaply goes into the app's own stores, never into pixels.
45 + `insertPeerLinks` writes link rows into a stopped server; `serveDescriptors` makes fake
46 + machines answer the reachability probe. The client's saved environments and routes live
47 + in IndexedDB (`t3code:connection-runtime` / `catalog` / `document`): write the document
48 + from the page after its first load, then reload. Route kinds come from hostnames
49 + (`*.localhost` is LAN, `*.ts.net` Tailscale); Chrome's
50 + `--host-resolver-rules=MAP *.tail-demo.ts.net 127.0.0.1` makes fake tailnet names work.
51 + - Gestures: hold the mouse down, move in steps, and `saveBeat` mid-drag to freeze the
52 + app's own drag line and highlight; animate between those beats with `Kit.reveal`.
53 + - A capped, scrolling modal freezes at different scroll offsets per beat. Freeze at a
54 + viewport tall enough that nothing scrolls, and size `.app` to match.
55 + - Without `claude`, turns go to the dev replay agent (`apps/server/scripts/dev-replay-agent.ts`),
56 + which shows as an ACP provider.
57 4. **Create the story:** `scripts/new.sh ~/launch-videos/<slug>`, then copy the beats in, or
58 pass that directory as the staging's `<out>`. Add one `<iframe data-beat>` per beat and
59 write `setup()` and `placeCursor()` (see Anatomy).
@@ -130,10 +141,14 @@ seeks every animation (in the story and inside each beat) to each frame's time.
141 1440×720 and `.app` scales them 1.0556× into the 1520×760 window, so beat point (x, y) is
142 canvas (40 + 1.0556·x, 26 + 1.0556·y).
143 - **Targets** are `"<beat> >> <css>"` (or `"* >> <css>"` for every beat). Prefer the app's
133 - `data-*` and `aria-label` attributes; `find.mjs` prints them.
144 + `data-*` and `aria-label` attributes; `find.mjs` prints them. A trailing `:text(words)`
145 + keeps the matches containing those words, e.g. `[role=menuitem]:text(From MacBook)`.
146 +- **Beat size.** Each beat records the viewport it was frozen at (`kit-viewport` meta).
147 + Size `.app` and its iframes to match and scale them to the 1520×760 window
148 + (1440×720 → 1.0556, 1600×800 → .95).
149 - **`setup()`**: `Kit.beats([[name, at, fade?], ...])` gives each beat one visibility window.
150 Then the motion, all at absolute times:
136 - `Kit.pop / rise / slide / stagger / type / press / punch / fadeIn` animate elements inside
151 + `Kit.pop / rise / slide / stagger / type / press / punch / fadeIn / draw` animate elements inside
152 a beat; `Kit.glow(target, at)` draws a ring on the story layer, so app overflow can't
153 clip it; `Kit.anim` takes raw keyframes; `Kit.text` makes a static edit (say so at
154 handback).
@@ -143,7 +158,8 @@ seeks every animation (in the story and inside each beat) to each frame's time.
158 finished. Camera steps centre `on` at screen height `y` (default 420, clear of the captions)
159 at scale `s`; repeat a step to hold. Cursor clicks draw a ripple.
160 - **Captions** `.cap`: a numbered chip, a bold lead phrase and a muted rest. Short enough to
146 - read in two seconds.
161 + read in two seconds. Play them with `Kit.captions([[selector, from, to], ...])`, which
162 + throws if two overlap; two captions crossfading read as garbled text.
163 - **Pacing**: `Kit.timeline([[realSeconds, animFrom, animTo], ...])` maps video time to
164 animation time; `animFrom == animTo` holds a frame. It also sets the video length.
165 - **Outro** `.outro`: logo, a two-line headline, "Available now in **T3 Code** `<version>`",
.agents/skills/launch-video/assets/kit.js
+88 -8
@@ -28,28 +28,52 @@ window.Kit = (() => {
28 if (!f) throw new Error(`Kit: no beat named ${name}`);
29 return f;
30 };
31 + // CSS plus a trailing `:text(words)`, which keeps the matches whose text contains `words`.
32 + const query = (doc, selector) => {
33 + const match = /^(.*?):text\((.+)\)$/.exec(selector.trim());
34 + if (!match) return [...doc.querySelectorAll(selector)];
35 + return [...doc.querySelectorAll(match[1] || "*")].filter(
36 + (node) =>
37 + node.textContent.includes(match[2]) &&
38 + ![...node.children].some(
39 + (c) => c.textContent.includes(match[2]) && c.matches(match[1] || "*"),
40 + ),
41 + );
42 + };
43 const resolve = (target) => {
32 - if (target instanceof Element) return { el: target, frame: null };
44 + // Nodes from a beat belong to its iframe's realm, so `instanceof Element` misses them.
45 + if (typeof target !== "string") {
46 + const view = target.ownerDocument.defaultView;
47 + return { el: target, frame: view === window ? null : view.frameElement };
48 + }
49 const split = target.indexOf(" >> ");
50 if (split === -1) {
35 - const el = document.querySelector(target);
51 + const [el] = query(document, target);
52 if (!el) throw new Error(`Kit: no element matches ${target}`);
53 return { el, frame: null };
54 }
55 const frame = beat(target.slice(0, split));
56 const sel = target.slice(split + 4);
41 - const el = frame.contentDocument.querySelector(sel);
57 + const [el] = query(frame.contentDocument, sel);
58 if (!el) throw new Error(`Kit: no element matches ${sel} in beat ${frame.dataset.beat}`);
59 return { el, frame };
60 };
61 // "* >> <selector>" matches in every beat.
62 const all = (target) => {
63 const split = target.indexOf(" >> ");
48 - if (split === -1) return [...document.querySelectorAll(target)];
64 + if (split === -1) return query(document, target);
65 const name = target.slice(0, split);
66 const docs =
67 name === "*" ? frames().map((f) => f.contentDocument) : [beat(name).contentDocument];
52 - return docs.flatMap((doc) => [...doc.querySelectorAll(target.slice(split + 4))]);
68 + return docs.flatMap((doc) => query(doc, target.slice(split + 4)));
69 + };
70 + // Extra CSS in beats ("*" for all), e.g. to uncap a scrolling modal so the whole page shows.
71 + const css = (name, text) => {
72 + for (const f of name === "*" ? frames() : [beat(name)]) {
73 + const style = f.contentDocument.createElement("style");
74 + style.textContent = text;
75 + f.contentDocument.head.append(style);
76 + }
77 };
78 // A static edit to the frozen page, e.g. a dev-only label. Say so when you hand the video back.
79 const text = (targets, value) => {
@@ -80,14 +104,19 @@ window.Kit = (() => {
104 );
105 for (const cam of cams) cam.style.animation = "none";
106 for (const a of scripted) a.cancel();
107 + // Everything is measured with the camera at rest; camera moves start only afterwards.
108 + measuring = true;
109 try {
84 - const result = fn();
110 for (const place of overlays.splice(0)) place();
86 - return result;
111 + return fn();
112 } finally {
113 + measuring = false;
114 + for (const start of afterMeasure.splice(0)) start();
115 for (const cam of cams) cam.style.animation = "";
116 }
117 };
118 + let measuring = false;
119 + const afterMeasure = [];
120 // Overlays drawn on the story page over a target (so the app's own overflow cannot clip
121 // them). They are measured and placed when placeCursor runs Kit.measure.
122 const overlays = [];
@@ -146,6 +175,23 @@ window.Kit = (() => {
175 ];
176 return anim(target, keys, { at: 0, dur: end, ease: "linear" });
177 };
178 + // Captions in order: [[selector, from, to], ...]. Each fades in and out inside its window,
179 + // and overlapping windows throw, since two captions on screen read as garbled text.
180 + const captions = (list) =>
181 + list.forEach(([target, from, to], i) => {
182 + const next = list[i + 1];
183 + if (next && next[1] < to) throw new Error(`Kit: caption ${target} overlaps ${next[0]}`);
184 + anim(
185 + target,
186 + [
187 + { opacity: 0, transform: "translateY(14px)" },
188 + { opacity: 1, transform: "none", offset: 0.06 },
189 + { opacity: 1, transform: "none", offset: 0.94 },
190 + { opacity: 0, transform: "translateY(-8px)" },
191 + ],
192 + { at: from, dur: to - from, ease: "linear" },
193 + );
194 + });
195 // The beats in order: [[name, at, fade?], ...]. Each shows from its `at` until the next beat
196 // has finished fading in over it.
197 const beats = (sequence) =>
@@ -226,6 +272,36 @@ window.Kit = (() => {
272 ],
273 { at, dur, ease: "ease-out" },
274 ),
275 + // Draws solid SVG strokes in (dashed ones keep their dashes and just fade in).
276 + draw: (targets, at, dur = 0.6, step = 0.08) =>
277 + all(targets).map((path, i) => {
278 + const start = at + i * step;
279 + const view = path.ownerDocument.defaultView;
280 + if (view.getComputedStyle(path).strokeDasharray !== "none" || !path.getTotalLength) {
281 + return anim(path, [{ opacity: 0 }, { opacity: 1 }], { at: start, dur });
282 + }
283 + const length = path.getTotalLength();
284 + path.style.strokeDasharray = `${length}`;
285 + return anim(path, [{ strokeDashoffset: length }, { strokeDashoffset: 0 }], {
286 + at: start,
287 + dur,
288 + ease: "cubic-bezier(.4,0,.2,1)",
289 + });
290 + }),
291 + // Wipes an element in from one side (dashed lines, a drag line following the pointer).
292 + reveal: (t, at, dur = 0.5, from = "left") => {
293 + const start = {
294 + left: "inset(0 100% 0 0)",
295 + right: "inset(0 0 0 100%)",
296 + top: "inset(0 0 100% 0)",
297 + bottom: "inset(100% 0 0 0)",
298 + }[from];
299 + return anim(t, [{ clipPath: start }, { clipPath: "inset(0 0 0 0)" }], {
300 + at,
301 + dur,
302 + ease: "linear",
303 + });
304 + },
305 // A punch: brief scale-up pulse that draws the eye.
306 punch: (t, at, scale = 1.06) =>
307 anim(
@@ -322,7 +398,9 @@ window.Kit = (() => {
398 }
399 return { offset: step.t / end, transform, easing: step.ease ?? "cubic-bezier(.65,0,.35,1)" };
400 });
325 - cam.animate(keys, { duration: end * 1000, fill: "both" });
401 + const start = () => cam.animate(keys, { duration: end * 1000, fill: "both" });
402 + if (measuring) afterMeasure.push(start);
403 + else start();
404 };
405
406 // Segments: [realSeconds, animFrom, animTo]; animFrom == animTo holds the frame.
@@ -345,6 +423,8 @@ window.Kit = (() => {
423 visible,
424 el,
425 all,
426 + css,
427 + captions,
428 text,
429 rect,
430 centerOf,
.agents/skills/launch-video/scripts/fake-claude.mjs
+1 -1
@@ -31,7 +31,7 @@ const readJson = (file, fallback) => {
31 const script = readJson(process.env.FAKE_CLAUDE_SCRIPT ?? "", []);
32 const played = new Set();
33 const fill = (value) => {
34 - const vars = readJson(process.env.T3_DEV_REPLAY_VARS ?? "", {});
34 + const vars = readJson(process.env.FAKE_CLAUDE_VARS ?? "", {});
35 const walk = (v) =>
36 typeof v === "string"
37 ? v.replace(/<var:([\w-]+)>/g, (m, name) => vars[name] ?? m)
.agents/skills/launch-video/scripts/find.mjs
+8 -1
@@ -36,7 +36,14 @@ const browser = await chromium.launch({
36 args: ["--no-sandbox"],
37 });
38 try {
39 - const page = await browser.newPage({ viewport: { width: 1440, height: 720 } });
39 + const [width, height] = (
40 + /name="kit-viewport" content="(\d+)x(\d+)"/.exec(NodeFS.readFileSync(file, "utf8")) ?? [
41 + 0, 1440, 720,
42 + ]
43 + )
44 + .slice(1)
45 + .map(Number);
46 + const page = await browser.newPage({ viewport: { width, height } });
47 await page.goto(`http://127.0.0.1:${server.address().port}/${NodePath.basename(file)}`);
48 const found = await page.evaluate((needle) => {
49 // Short, stable selectors: data attributes and aria labels over generated classes.
.agents/skills/launch-video/scripts/snapshot.mjs
+4
@@ -86,6 +86,10 @@ async function freeze(known) {
86 const styleEl = document.createElement("style");
87 styleEl.textContent = css;
88 head.append(styleEl);
89 + const viewport = document.createElement("meta");
90 + viewport.name = "kit-viewport";
91 + viewport.content = `${innerWidth}x${innerHeight}`;
92 + head.append(viewport);
93 const restore = document.createElement("script");
94 restore.textContent = `for (const el of document.querySelectorAll("[data-kit-scroll]")) { const [x, y] = el.dataset.kitScroll.split(",").map(Number); el.scrollLeft = x; el.scrollTop = y; }`;
95 clone.querySelector("body").append(restore);
.agents/skills/launch-video/scripts/stage-env.mjs
+75 -9
@@ -3,6 +3,7 @@
3 import * as NodeChildProcess from "node:child_process";
4 import * as NodeCrypto from "node:crypto";
5 import * as NodeFS from "node:fs";
6 +import * as NodeHttp from "node:http";
7 import * as NodeNet from "node:net";
8 import * as NodePath from "node:path";
9 import * as NodeURL from "node:url";
@@ -99,25 +100,33 @@ function spawn(args, env, log) {
100 // Its own process group, so stopping it ends the dev runner's children too.
101 detached: true,
102 });
102 - children.push({
103 + const handle = {
104 kill: (s) => {
105 try {
106 process.kill(-child.pid, s);
107 } catch {}
108 },
108 - });
109 + };
110 + children.push(handle);
111 + child.stopGroup = () =>
112 + new Promise((resolve) => {
113 + if (child.exitCode !== null) return resolve();
114 + child.once("exit", () => resolve());
115 + handle.kill("SIGTERM");
116 + });
117 return child;
118 }
119
120 /**
121 * Starts a dev server on `home` (and the web client when `web` is set). Resolves when it listens,
114 - * with its origin, the web origin and the startup pairing URL.
122 + * with its origin, the web origin, the startup pairing URL, and `stop()`. Pass the previous
123 + * `port` to restart a server where saved routes expect it.
124 */
125 export async function startEnvironment(
126 home,
118 - { host = "127.0.0.1", web = false, allowedOrigins = [], env = {} } = {},
127 + { host = "127.0.0.1", port, web = false, allowedOrigins = [], env = {} } = {},
128 ) {
120 - const serverPort = await freePort();
129 + const serverPort = port ?? (await freePort());
130 const webPort = web ? await freePort() : await freePort();
131 const webOrigin = `http://127.0.0.1:${webPort}`;
132 const token = NodeCrypto.randomUUID().replaceAll("-", "").repeat(2);
@@ -173,8 +182,9 @@ export async function startEnvironment(
182 reject(new Error(`server on ${home} exited ${code}; see ${log}`)),
183 );
184 });
185 + const processes = [server];
186 if (web) {
177 - spawn(runner("dev:web", ["--", "--host", "127.0.0.1"]), baseEnv, log);
187 + processes.push(spawn(runner("dev:web", ["--", "--host", "127.0.0.1"]), baseEnv, log));
188 for (let i = 0; ; i++) {
189 try {
190 if ((await fetch(`${webOrigin}/.well-known/t3/environment`)).ok) break;
@@ -183,11 +193,14 @@ export async function startEnvironment(
193 await new Promise((r) => setTimeout(r, 500));
194 }
195 }
186 - const origin = `http://127.0.0.1:${serverPort}`;
196 + const reachableHost = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host;
197 + const origin = `http://${reachableHost.includes(":") ? `[${reachableHost}]` : reachableHost}:${serverPort}`;
198 const descriptor = await (await fetch(`${origin}/.well-known/t3/environment`)).json();
199 return {
200 home,
201 origin,
202 + descriptor,
203 + stop: () => Promise.all(processes.map((p) => p.stopGroup())),
204 serverPort,
205 webOrigin,
206 pairingUrl,
@@ -258,7 +271,7 @@ export async function createProject(environment, title, files = { "README.md": "
271 }
272
273 /** A Playwright page at the size beats are frozen at, dark, with production branding. */
261 -export async function openBrowser({ width = 1440, height = 720 } = {}) {
274 +export async function openBrowser({ width = 1440, height = 720, args = [] } = {}) {
275 const { createRequire } = await import("node:module");
276 const { chromium } = createRequire(NodePath.join(REPO, "scripts/package.json"))(
277 "playwright-core",
@@ -266,7 +279,7 @@ export async function openBrowser({ width = 1440, height = 720 } = {}) {
279 const { findChrome } = await import("./chrome.mjs");
280 const browser = await chromium.launch({
281 executablePath: findChrome(chromium),
269 - args: ["--no-sandbox"],
282 + args: ["--no-sandbox", ...args],
283 });
284 const context = await browser.newContext({ viewport: { width, height }, colorScheme: "dark" });
285 await context.addInitScript(() => {
@@ -281,3 +294,56 @@ export async function openBrowser({ width = 1440, height = 720 } = {}) {
294 const page = await context.newPage();
295 return { browser, context, page };
296 }
297 +
298 +/**
299 + * Writes link rows straight into a stopped server's database, as if `t3 environment link` had
300 + * made them. The server must have started once (migrations). The map probes each row's URLs
301 + * live: a row is "reachable" only while something there answers as that environment.
302 + * Rows: { environmentId, label, urls, access = "full-access", lastError = null }.
303 + */
304 +export async function insertPeerLinks(home, rows) {
305 + const { DatabaseSync } = await import("node:sqlite");
306 + const db = new DatabaseSync(NodePath.join(home, "userdata/statev2.sqlite"));
307 + const now = Date.now();
308 + const insert = db.prepare(
309 + `INSERT OR REPLACE INTO peer_environment_links
310 + (environment_id, secret_name, label, urls_json, access, linked_at, expires_at, last_reached_at, last_error, fenced)
311 + VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, 1)`,
312 + );
313 + for (const row of rows) {
314 + insert.run(
315 + row.environmentId,
316 + `peer-link:${row.environmentId}`,
317 + row.label,
318 + JSON.stringify(row.urls),
319 + row.access ?? "full-access",
320 + new Date(now - 86_400_000).toISOString(),
321 + new Date(now + 60 * 86_400_000).toISOString(),
322 + row.lastError ?? null,
323 + );
324 + }
325 + db.close();
326 +}
327 +
328 +/**
329 + * Answers the descriptor probe for machines that only need to look alive: one port per
330 + * machine, each serving `template` (a real server's descriptor) under that machine's id and
331 + * label. Returns the URL for each machine, by environment id.
332 + */
333 +export async function serveDescriptors(template, machines) {
334 + const urls = {};
335 + for (const machine of machines) {
336 + const body = JSON.stringify({
337 + ...template,
338 + environmentId: machine.environmentId,
339 + label: machine.label,
340 + });
341 + const server = NodeHttp.createServer((req, res) =>
342 + res.writeHead(200, { "content-type": "application/json" }).end(body),
343 + );
344 + await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
345 + children.push({ kill: () => server.close() });
346 + urls[machine.environmentId] = `http://127.0.0.1:${server.address().port}`;
347 + }
348 + return urls;
349 +}
.agents/skills/launch-video/stagings/linked-environments/serve.mjs
+1 -1
@@ -117,7 +117,7 @@ NodeFS.writeFileSync(vars, "{}");
117
118 const macbook = await startEnvironment(NodePath.join(root, "macbook"), {
119 web: true,
120 - env: { T3_DEV_REPLAY_VARS: vars },
120 + env: { FAKE_CLAUDE_VARS: vars },
121 });
122 console.log(`MacBook: ${macbook.label} ${macbook.environmentId} web ${macbook.webOrigin}`);
123 const devbox = await startEnvironment(NodePath.join(root, "devbox"), {
.agents/skills/launch-video/template/real.html
+4 -9
@@ -232,15 +232,10 @@
232 <script>
233 // Everything here is in animation seconds. capture.mjs calls setup() once the beats have loaded.
234 window.setup = () => {
235 - Kit.show("iframe[data-beat=BEAT_ONE]", 0);
236 - Kit.anim(
237 - "#cap1",
238 - [
239 - { opacity: 0, transform: "translateY(10px)" },
240 - { opacity: 1, transform: "none" },
241 - ],
242 - { at: 0.4, dur: 0.3 },
243 - );
235 + // One visibility window per beat; never pair Kit.show and Kit.hide on one element.
236 + Kit.beats([["BEAT_ONE", 0]]);
237 + // Captions play in order and must not overlap.
238 + Kit.captions([["#cap1", 0.4, 5.8]]);
239 Kit.anim(".outro", [{ opacity: 0 }, { opacity: 1 }], { at: 6, dur: 0.5 });
240 Kit.stagger(".outro .logo, .outro h2, .outro p, .outro .url", 6.05, 0.08, "rise", {
241 y: 18,