Skip to content

BuilderIO/agent-native / .agents/skills/design-editor-repro

design-editor-repro

Verified

Reproduce and verify Design editor issues against the application itself.

FileKindSize
SKILL.mdskill md2.2 KB
harness-recipes.mdmarkdown1.2 KB
harness/dlib.mjsscript27.1 KB
harness/doctor.mjsscript3.1 KB
harness/harness-env.mjsscript5.1 KB
harness/lock.mjsscript1.9 KB
harness/osmouse-linuxexecutablescript1.7 KB
harness/osmouse.swiftscript3.7 KB
harness/sheet.mjsscript3.1 KB
harness/shot.mjsscript2.6 KB
harness/start-dev.shexecutablescript1.6 KB
reference/fixing.mdmarkdown947 B
reference/input-and-osmouse.mdmarkdown938 B
reference/performance.mdmarkdown1.0 KB
reference/tests-and-blast-radius.mdmarkdown719 B
reference/verification.mdmarkdown578 B
scripts/clip.mjsscript4.2 KB
scripts/copy-design.mjsscript7.2 KB

scripts/clip.mjs

View on GitHub
// Saves a Clips recording's context, transcript and frames under
// templates/design/.tmp/editor-repro/clip-<id>/ and lays the frames out as one
// contact sheet, captioned with what was said at each moment.
//
//   node .agents/skills/design-editor-repro/scripts/clip.mjs <clip link> [atMs,atMs,...]
//
// Without timestamps it saves the clip's recommended frames.
import { mkdirSync, writeFileSync } from "node:fs";
import { relative } from "node:path";

import { WORKTREE } from "../harness/harness-env.mjs";
import { sheet } from "../harness/sheet.mjs";

const [link, times] = process.argv.slice(2);
if (!link) {
  console.error("usage: clip.mjs <clip link> [atMs,atMs,...]");
  process.exit(2);
}
const url = new URL(link);
const id = url.pathname.split("/").filter(Boolean).pop();
const contextUrl = new URL("/api/agent-context.json", url.origin);
contextUrl.searchParams.set("id", id);
const token = url.searchParams.get("agent_access");
// The context's frame URLs already carry their own scoped token.
if (token) contextUrl.searchParams.set("agent_access", token);

/** Fetch that waits out 429s (Retry-After, capped) instead of hammering the clips API. */
async function get(u) {
  for (let attempt = 1; ; attempt++) {
    const res = await fetch(u);
    if (res.status !== 429 || attempt > 3) return res;
    await new Promise((r) =>
      setTimeout(
        r,
        Math.min(Number(res.headers.get("retry-after")) || 10, 30) * 1000,
      ),
    );
  }
}

const ctxRes = await get(contextUrl);
if (!ctxRes.ok)
  throw new Error(
    `clip context ${ctxRes.status}: private clips need their agent_access link`,
  );
const context = await ctxRes.json();

const dir = `${WORKTREE}/templates/design/.tmp/editor-repro/clip-${id}`;
mkdirSync(dir, { recursive: true });
writeFileSync(`${dir}/context.json`, JSON.stringify(context, null, 2));
const segments = context.transcript?.segments ?? [];
writeFileSync(
  `${dir}/transcript.txt`,
  segments.map((s) => `[${s.timestamp}] ${s.text}`).join("\n"),
);

const frameTemplate = context.apis.frame.urlTemplate;
const frameOrigin = new URL(frameTemplate, url).origin;
if (frameOrigin !== url.origin) {
  throw new Error(
    `clip frames are served from ${frameOrigin}, not ${url.origin}; refusing to fetch them`,
  );
}

const wanted = times
  ? times.split(",").map((t) => ({ atMs: Number(t) }))
  : (context.recommendedFrames ?? []);
const frames = [];
const failed = [];
for (const f of wanted) {
  const res = await get(frameTemplate.replace("{timestampMs}", String(f.atMs)));
  if (!res.ok) {
    failed.push(`${f.atMs}ms: HTTP ${res.status}`);
    continue;
  }
  const path = `${dir}/f-${String(f.atMs).padStart(7, "0")}.jpg`;
  writeFileSync(path, Buffer.from(await res.arrayBuffer()));
  const said = segments
    .filter((s) => s.endMs >= f.atMs - 3000 && s.startMs <= f.atMs + 3000)
    .map((s) => s.text)
    .join(" ");
  frames.push({
    path,
    label: `${Math.floor(f.atMs / 60000)}:${String(Math.floor(f.atMs / 1000) % 60).padStart(2, "0")}`,
    said,
  });
}
const contact = await sheet(
  `clip ${id}: ${context.clip?.title ?? ""}`,
  frames.map((f) => ({ label: f.label, image: f.path, caption: f.said })),
  { columns: 3, cellWidth: 560, out: `${dir}/contact-sheet.jpg` },
);

const clip = context.clip ?? {};
const designIds = [
  ...new Set(
    (
      JSON.stringify(context).match(
        /design\.agent-native\.com\/design\/[A-Za-z0-9_-]+/g,
      ) ?? []
    ).map((u) => u.split("/").pop()),
  ),
];
console.log(`clip: ${clip.title} (${clip.duration})`);
if (clip.description) console.log(`description: ${clip.description}`);
if (context.bugReport)
  console.log(`bugReport: ${JSON.stringify(context.bugReport).slice(0, 800)}`);
console.log(
  designIds.length > 0
    ? `design ids: ${designIds.join(", ")}`
    : "design id: not in the clip; read the URL bar in the frames, or ask the user",
);
const rel = (p) => relative(WORKTREE, p);
console.log(`transcript: ${rel(`${dir}/transcript.txt`)}`);
console.log(`contact sheet (open this first): ${rel(contact)}`);
console.log(
  `frames (open one only for detail): ${frames.map((f) => `${f.label} ${rel(f.path)}`).join(" | ")}`,
);
if (failed.length > 0)
  console.log(`frames that failed to download: ${failed.join(", ")}`);
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall