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/lib/playwright-loader.mjs

View on GitHub
import path from "node:path";
import { createRequire } from "node:module";
import fs from "node:fs";
import os from "node:os";
import { systemChromium } from "./system-browser.mjs";

// Reuse an already-provided Playwright runtime when one is available: explicit
// package paths first, then dependencies visible from the script or process
// cwd. Product runs otherwise fall back to the zero-dependency CDP adapter, so
// a web-clone task never mutates the user's project or downloads a browser.
export function loadPlaywright() {
  const requireFromScript = createRequire(import.meta.url);
  const requireFromCwd = createRequire(path.join(process.cwd(), "noop.js"));
  const attempts = [
    () => {
      const p = process.env.OD_PLAYWRIGHT_PACKAGE;
      if (!p) throw new Error("OD_PLAYWRIGHT_PACKAGE unset");
      return requireFromScript(p);
    },
    () => {
      const p = process.env.OD_PLAYWRIGHT_PATH;
      if (!p) throw new Error("OD_PLAYWRIGHT_PATH unset");
      return requireFromScript(p);
    },
    () => requireFromScript("playwright"),
    () => requireFromScript("playwright-core"),
    () => requireFromCwd("playwright"),
    () => requireFromCwd("playwright-core"),
  ];
  for (const attempt of attempts) {
    try {
      return attempt();
    } catch {
      // Try next candidate.
    }
  }
  return { chromium: systemChromium };
}

function firstExisting(candidates) {
  return candidates.find((candidate) => candidate && fs.existsSync(candidate)) || null;
}

function executableFromPath(names, env = process.env, platform = process.platform) {
  const pathValue = env.PATH || env.Path || "";
  const extensions = platform === "win32"
    ? (env.PATHEXT || ".EXE;.CMD;.BAT").split(";")
    : [""];
  for (const directory of pathValue.split(path.delimiter).filter(Boolean)) {
    for (const name of names) {
      for (const extension of extensions) {
        const candidate = path.join(directory, `${name}${extension}`);
        if (fs.existsSync(candidate)) return candidate;
      }
    }
  }
  return null;
}

export function findSystemChromiumExecutable({
  platform = process.platform,
  env = process.env,
  homeDir = os.homedir(),
} = {}) {
  const configured = env.OD_BROWSER_EXECUTABLE_PATH;
  if (configured) {
    if (fs.existsSync(configured)) return configured;
    throw new Error(`OD_BROWSER_EXECUTABLE_PATH does not exist: ${configured}`);
  }

  if (platform === "darwin") {
    return firstExisting([
      "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
      "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
      "/Applications/Chromium.app/Contents/MacOS/Chromium",
      path.join(homeDir, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
      path.join(homeDir, "Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"),
    ]);
  }

  if (platform === "win32") {
    const roots = [env.PROGRAMFILES, env["PROGRAMFILES(X86)"], env.LOCALAPPDATA].filter(Boolean);
    return firstExisting(roots.flatMap((root) => [
      path.join(root, "Google/Chrome/Application/chrome.exe"),
      path.join(root, "Microsoft/Edge/Application/msedge.exe"),
      path.join(root, "Chromium/Application/chrome.exe"),
    ]));
  }

  return executableFromPath([
    "google-chrome-stable",
    "google-chrome",
    "microsoft-edge-stable",
    "microsoft-edge",
    "chromium",
    "chromium-browser",
  ], env, platform);
}

export async function launchChromium(chromium, options = {}) {
  // A staged skill can still see Playwright from a source checkout (notably in
  // CI). That must not bypass the product path: agent sandboxes frequently
  // cannot spawn Chrome, while the daemon owns a trusted browser process. Use
  // the zero-dependency adapter for daemon brokering even when the caller's
  // chromium object came from an already-installed Playwright package.
  const daemonChromium = typeof chromium.connectOverDaemon === "function"
    ? chromium
    : systemChromium;
  if (
    typeof daemonChromium.connectOverDaemon === "function"
    && process.env.OD_DAEMON_URL
    && process.env.OD_PROJECT_ID
  ) {
    try {
      return await daemonChromium.connectOverDaemon({
        daemonUrl: process.env.OD_DAEMON_URL,
        projectId: process.env.OD_PROJECT_ID,
      });
    } catch {
      // Older daemons may not expose the broker. Fall back to direct launch.
    }
  }
  const executablePath = findSystemChromiumExecutable(options.discovery);
  let systemBrowserError = null;
  if (executablePath) {
    try {
      return await chromium.launch({ headless: true, executablePath });
    } catch (error) {
      systemBrowserError = error;
    }
  }

  // Source checkouts may already have a Playwright-managed browser. Trying it
  // is safe: launch never downloads a browser; it only uses an existing one.
  try {
    return await chromium.launch({ headless: true });
  } catch (error) {
    throw new Error(
      "No compatible Chrome, Edge, or Chromium executable is available. " +
        "Open Design does not download a browser during web-clone tasks. " +
        "Install a system browser or set OD_BROWSER_EXECUTABLE_PATH to its executable. " +
        `Browser launch detail: ${systemBrowserError?.message || error.message}`,
    );
  }
}
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