Skip to content

nexu-io/openmotion / library/design/skills/web-clone

web-clone

Unverified

网站复刻 / 克隆方法论。USE WHEN 用户说 复刻网站、克隆网站、clone website、抄个站、仿站、 照着这个站做一个、reproduce site、还原某个网页效果、把这个站搬下来改成我的、 复刻某个交互/WebGL/Canvas/Three.js 效果。提供「先拿真源码 → 判路径 → 逆向拆解 → 搭工程 → 替换内容」的可移植决策树,覆盖静态站 / React-Vue-Next 内容站 / WebGL-Canvas 重前端站三大分支,并强制核对任何 AI 二手分析里的可执行代码。

FileKindSize
LICENSEother1.1 KB
SKILL.mdskill md20.8 KB
references/assessment.mdmarkdown3.5 KB
references/complex-playbooks.mdmarkdown2.3 KB
references/deliverables.mdmarkdown4.9 KB
references/design-dna.mdmarkdown11.4 KB
references/effect-extraction.mdmarkdown5.2 KB
references/marbles-case.mdmarkdown3.3 KB
references/reverse-engineering.mdmarkdown3.5 KB
references/static-mirror.mdmarkdown4.8 KB
scripts/asset-harvest.mjsexecutablescript14.4 KB
scripts/audit-clone.mjsexecutablescript11.0 KB
scripts/compare-recon.mjsexecutablescript10.8 KB
scripts/dna-scaffold.mjsscript11.6 KB
scripts/init-clone.mjsexecutablescript3.4 KB
scripts/interaction-probe.mjsscript12.2 KB
scripts/lib/playwright-loader.mjsexecutablescript5.1 KB
scripts/lib/system-browser.mjsscript19.4 KB
scripts/mirror-site.mjsscript6.2 KB
scripts/network-capture.mjsexecutablescript4.2 KB
scripts/od-preview-rewrite.mjsscript5.6 KB
scripts/recon-site.mjsexecutablescript16.4 KB
scripts/route-crawl.mjsscript7.8 KB
scripts/sourcemap-hunt.mjsexecutablescript3.6 KB
scripts/visual-diff.mjsexecutablescript5.8 KB

scripts/visual-diff.mjs

View on GitHub
#!/usr/bin/env node
import fs from "node:fs";
import path from "node:path";
import { loadPlaywright, launchChromium } from "./lib/playwright-loader.mjs";

function usage() {
  console.log(`Usage:
  node scripts/visual-diff.mjs --original <png> --clone <png> --out visual-diff.json [--diff visual-diff.png] [--threshold 0.08]

Compares screenshots in a real browser canvas and outputs numeric visual-diff metrics.
`);
}

function parseArgs(argv) {
  const out = { original: "", clone: "", out: "visual-diff.json", diff: "", threshold: 0.08 };
  for (let i = 0; i < argv.length; i += 1) {
    const arg = argv[i];
    if (arg === "--help" || arg === "-h") out.help = true;
    else if (arg === "--original") out.original = argv[++i] || "";
    else if (arg === "--clone") out.clone = argv[++i] || "";
    else if (arg === "--out") out.out = argv[++i] || "visual-diff.json";
    else if (arg === "--diff") out.diff = argv[++i] || "";
    else if (arg === "--threshold") out.threshold = Number(argv[++i] || "0.08");
    else throw new Error(`Unexpected argument: ${arg}`);
  }
  return out;
}

function imageDataUrl(file) {
  const ext = path.extname(file).slice(1).toLowerCase() || "png";
  const mime = ext === "jpg" || ext === "jpeg" ? "image/jpeg" : "image/png";
  return `data:${mime};base64,${fs.readFileSync(file).toString("base64")}`;
}

function scoreFromDiff(diffRatio, meanAbsDiff) {
  if (diffRatio <= 0.01 && meanAbsDiff <= 0.01) return 5;
  if (diffRatio <= 0.04 && meanAbsDiff <= 0.025) return 4.5;
  if (diffRatio <= 0.08 && meanAbsDiff <= 0.05) return 4;
  if (diffRatio <= 0.16 && meanAbsDiff <= 0.08) return 3;
  if (diffRatio <= 0.3 && meanAbsDiff <= 0.14) return 2;
  return 1;
}

async function compareInBrowser(page, original, clone, threshold) {
  return page.evaluate(async ({ original, clone, threshold }) => {
    const loadImage = (src) => new Promise((resolve, reject) => {
      const image = new Image();
      image.onload = () => resolve(image);
      image.onerror = () => reject(new Error(`Failed to load image: ${src.slice(0, 80)}`));
      image.src = src;
    });

    const [left, right] = await Promise.all([loadImage(original), loadImage(clone)]);
    const width = Math.max(left.naturalWidth, right.naturalWidth);
    const height = Math.max(left.naturalHeight, right.naturalHeight);

    const canvasA = document.createElement("canvas");
    const canvasB = document.createElement("canvas");
    const canvasD = document.createElement("canvas");
    for (const canvas of [canvasA, canvasB, canvasD]) {
      canvas.width = width;
      canvas.height = height;
    }

    const ctxA = canvasA.getContext("2d");
    const ctxB = canvasB.getContext("2d");
    const ctxD = canvasD.getContext("2d");
    ctxA.fillStyle = "white";
    ctxB.fillStyle = "white";
    ctxA.fillRect(0, 0, width, height);
    ctxB.fillRect(0, 0, width, height);
    ctxA.drawImage(left, 0, 0);
    ctxB.drawImage(right, 0, 0);

    const a = ctxA.getImageData(0, 0, width, height);
    const b = ctxB.getImageData(0, 0, width, height);
    const d = ctxD.createImageData(width, height);
    let changed = 0;
    let sumAbs = 0;
    let sumSq = 0;

    for (let i = 0; i < a.data.length; i += 4) {
      const dr = Math.abs(a.data[i] - b.data[i]);
      const dg = Math.abs(a.data[i + 1] - b.data[i + 1]);
      const db = Math.abs(a.data[i + 2] - b.data[i + 2]);
      const da = Math.abs(a.data[i + 3] - b.data[i + 3]);
      const delta = (dr + dg + db + da) / 1020;
      sumAbs += delta;
      sumSq += delta * delta;
      if (delta > threshold) changed += 1;

      if (delta > threshold) {
        d.data[i] = 255;
        d.data[i + 1] = Math.max(0, 80 - delta * 80);
        d.data[i + 2] = Math.max(0, 80 - delta * 80);
        d.data[i + 3] = 255;
      } else {
        d.data[i] = Math.round(a.data[i] * 0.25 + 245 * 0.75);
        d.data[i + 1] = Math.round(a.data[i + 1] * 0.25 + 245 * 0.75);
        d.data[i + 2] = Math.round(a.data[i + 2] * 0.25 + 245 * 0.75);
        d.data[i + 3] = 255;
      }
    }

    ctxD.putImageData(d, 0, 0);
    const pixels = width * height;
    const diffPixelRatio = changed / pixels;
    const meanAbsDiff = sumAbs / pixels;
    const rmse = Math.sqrt(sumSq / pixels);

    return {
      original: { width: left.naturalWidth, height: left.naturalHeight },
      clone: { width: right.naturalWidth, height: right.naturalHeight },
      comparedCanvas: { width, height },
      threshold,
      changedPixels: changed,
      totalPixels: pixels,
      diffPixelRatio,
      meanAbsDiff,
      rmse,
      diffPngDataUrl: canvasD.toDataURL("image/png"),
    };
  }, { original, clone, threshold });
}

try {
  const args = parseArgs(process.argv.slice(2));
  if (args.help || !args.original || !args.clone) {
    usage();
    process.exit(args.help ? 0 : 1);
  }

  const { chromium } = loadPlaywright();
  const browser = await launchChromium(chromium);
  const page = await browser.newPage();
  const result = await compareInBrowser(page, imageDataUrl(args.original), imageDataUrl(args.clone), args.threshold);
  await browser.close();

  const diffDataUrl = result.diffPngDataUrl;
  delete result.diffPngDataUrl;
  result.visualScore = scoreFromDiff(result.diffPixelRatio, result.meanAbsDiff);
  result.files = {
    original: path.resolve(args.original),
    clone: path.resolve(args.clone),
    diff: args.diff ? path.resolve(args.diff) : "",
  };

  fs.mkdirSync(path.dirname(path.resolve(args.out)), { recursive: true });
  fs.writeFileSync(args.out, `${JSON.stringify(result, null, 2)}\n`);

  if (args.diff) {
    const base64 = diffDataUrl.replace(/^data:image\/png;base64,/, "");
    fs.mkdirSync(path.dirname(path.resolve(args.diff)), { recursive: true });
    fs.writeFileSync(args.diff, Buffer.from(base64, "base64"));
  }

  console.log(path.resolve(args.out));
} catch (error) {
  console.error(`visual-diff failed: ${error.message}`);
  process.exit(1);
}
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall