Skip to content

anbeime/skill / skills/anatomy/anatomy

anatomy

Unverified

Build crafted, highly detailed, interactive isometric SVG figures that explain a technical idea as a real physical object (a test rig, a dial gauge, a cabinet of drawers, a plotter, a lock), with many small precise solid parts, four-tone shading, correct painter's order, a framed card with title, hint and live readout, and calm eased motion. Use this whenever someone wants an isometric illustration, an explanatory diagram or figure for docs, a blog post, a landing page or an article, a "Linear-style" or "premium" technical drawing, an interactive explainer, or an SVG that shows how a system, algorithm or component works, even if they never say "isometric". Works framework-free (TypeScript/JS that writes SVG and HTML) and in React/Next.js, and can add realistic WebGL shaders (fire, exhaust, water, caustics, lamp light) that live inside the drawing in the same isometric perspective. Also prints a figure as an A4 PDF (poster, drawing or handout) and publishes it to the Anatomy community gallery when asked.

FileKindSize
.gitattributesother89 B
.github/ISSUE_TEMPLATE/bug_report.ymlconfig2.7 KB
.github/ISSUE_TEMPLATE/config.ymlconfig213 B
.github/ISSUE_TEMPLATE/figure_request.ymlconfig1.9 KB
.github/PULL_REQUEST_TEMPLATE.mdmarkdown1005 B
.github/assets/dial-indicator.webpbinary17.0 KB
.github/assets/raptor-engine-apart.webpbinary34.3 KB
.github/assets/raptor-engine-firing.webpbinary36.9 KB
.github/assets/ripple-tank.webpbinary33.9 KB
.github/assets/turning-dial.webpbinary29.3 KB
.github/workflows/ci.ymlconfig2.0 KB
.gitignoreother216 B
CHANGELOG.mdmarkdown14.6 KB
CODE_OF_CONDUCT.mdmarkdown5.5 KB
CONTRIBUTING.mdmarkdown8.7 KB
LICENSEother1.0 KB
README.mdmarkdown25.6 KB
SECURITY.mdmarkdown1.2 KB
SKILL.mdskill md32.8 KB
agents/openai.yamlconfig120 B
evals/evals.jsonconfig8.0 KB
examples/arcade-cabinet/arcade-cabinet-detailed-a4.pdfbinary2.2 MB
examples/arcade-cabinet/arcade-cabinet-drawing-a4.pdfbinary1.8 MB
examples/arcade-cabinet/arcade-cabinet-light.htmlother985.3 KB
examples/arcade-cabinet/arcade-cabinet-poster-a4.pdfbinary709.6 KB
examples/arcade-cabinet/arcade-cabinet.cssother3.1 KB
examples/arcade-cabinet/arcade-cabinet.htmlother985.3 KB
examples/arcade-cabinet/build.mjsscript50.5 KB
examples/arcade-cabinet/live.jsscript20.8 KB
examples/arcade-cabinet/parts.mjsscript4.2 KB
examples/arcade-cabinet/screen.mjsscript6.5 KB
examples/arcade-cabinet/sheet.mjsscript5.4 KB
examples/desk-computer/build.mjsscript22.5 KB
examples/desk-computer/desk-computer-light.htmlother231.8 KB
examples/desk-computer/desk-computer.htmlother231.8 KB
examples/dial-indicator/build.mjsscript14.6 KB
examples/dial-indicator/dial-indicator-light.htmlother133.3 KB
examples/dial-indicator/dial-indicator.htmlother133.3 KB
examples/push-button/build.mjsscript15.9 KB
examples/push-button/push-button-detailed-a4.pdfbinary933.7 KB
examples/push-button/push-button-drawing-a4.pdfbinary680.6 KB
examples/push-button/push-button-light.htmlother124.5 KB
examples/push-button/push-button-poster-a4.pdfbinary453.1 KB
examples/push-button/push-button.htmlother124.5 KB
examples/push-button/sheet.mjsscript4.0 KB
examples/raptor-engine/build.mjsscript69.2 KB
examples/raptor-engine/live.jsscript30.0 KB
examples/raptor-engine/raptor-engine-detailed-a4.pdfbinary4.1 MB
examples/raptor-engine/raptor-engine-drawing-a4.pdfbinary2.8 MB
examples/raptor-engine/raptor-engine-light.htmlother1.5 MB
examples/raptor-engine/raptor-engine-poster-a4.pdfbinary599.0 KB
examples/raptor-engine/raptor-engine.htmlother1.5 MB
examples/raptor-engine/raptor.cssother6.6 KB
examples/raptor-engine/sheet.mjsscript6.2 KB
examples/ripple-tank/build.mjsscript31.3 KB
examples/ripple-tank/live.jsscript21.2 KB
examples/ripple-tank/model.mjsscript4.9 KB
examples/ripple-tank/ripple-tank-light.htmlother493.7 KB
examples/ripple-tank/ripple-tank.htmlother493.7 KB
examples/ripple-tank/ripple.cssother1.6 KB
examples/spot-plate/art.tsxother4.4 KB
examples/spot-plate/drops.tsscript18.7 KB
examples/spot-plate/fan.tsscript2.7 KB
examples/spot-plate/figure.tsxother1.1 KB
examples/spot-plate/geometry.tsscript10.7 KB
examples/spot-plate/live.tsxother11.4 KB
examples/spot-plate/rig.tsscript8.0 KB
examples/spot-plate/spot-plate.cssother1.5 KB
examples/test-rig/art.tsxother7.2 KB
examples/test-rig/figure.tsxother850 B
examples/test-rig/geometry.tsscript12.8 KB
examples/test-rig/live.tsxother17.1 KB
examples/test-rig/pose.tsscript3.8 KB
examples/test-rig/rig.tsscript5.5 KB
examples/test-rig/stretch.cssother1.2 KB
examples/test-rig/view.tsscript3.0 KB
examples/turning-dial/build.mjsscript31.3 KB
examples/turning-dial/dial.cssother509 B
examples/turning-dial/live.jsscript12.2 KB
examples/turning-dial/stress.mjsscript19.0 KB
examples/turning-dial/turning-dial-light.htmlother658.1 KB
examples/turning-dial/turning-dial-verify-light.htmlother685.3 KB
examples/turning-dial/turning-dial.htmlother658.1 KB
examples/turning-dial/turning-stress-light.htmlother1.2 MB
kit/audit.mjsscript90.4 KB
kit/canvas-painter.mjsscript26.9 KB
kit/gl-shared.mjsscript8.7 KB
kit/gl.mjsscript8.6 KB
kit/iso-kit.mjsscript34.4 KB
kit/iso-kit.tsscript37.7 KB
kit/iso.cssother7.5 KB
kit/lathe.mjsscript46.9 KB
kit/pdf-button.mjsscript1.3 KB
kit/react/draw.tsxother6.4 KB
kit/react/live.tsxother4.3 KB
kit/tube.mjsscript13.9 KB
kit/turn-audit.mjsscript56.0 KB
kit/turn-build.mjsscript64.4 KB
kit/turn-fixed.mjsscript143.6 KB
kit/turn.mjsscript136.5 KB
references/3d.mdmarkdown43.6 KB
references/craft.mdmarkdown49.1 KB
references/kit.mdmarkdown66.3 KB
references/motion.mdmarkdown22.1 KB
references/print.mdmarkdown6.9 KB
references/publish.mdmarkdown4.0 KB
references/react.mdmarkdown3.5 KB
references/verify.mdmarkdown42.6 KB
references/walkthrough.mdmarkdown5.2 KB
references/webgl.mdmarkdown59.7 KB
scripts/audit-affine-bounds.test.mjsscript4.1 KB
scripts/audit-cache.test.mjsscript1.6 KB
scripts/audit-clearance-envelope.test.mjsscript2.4 KB
scripts/audit-empty-clipping.test.mjsscript3.8 KB
scripts/audit-order-convergence.test.mjsscript2.8 KB
scripts/audit-path-origin.test.mjsscript1.6 KB
scripts/audit-profile.test.mjsscript2.1 KB
scripts/audit-projection.test.mjsscript1.9 KB
scripts/audit-slide-clearance.test.mjsscript2.8 KB
scripts/audit-svg-attributes.test.mjsscript3.4 KB
scripts/audit-taper.test.mjsscript1.2 KB
scripts/audit-tube-support.test.mjsscript2.6 KB
scripts/capture-current-geometry.test.mjsscript5.0 KB
scripts/capture-selector.test.mjsscript7.5 KB
scripts/capture.mjsscript14.7 KB
scripts/capture.test.mjsscript3.1 KB
scripts/chrome-port.mjsscript1.1 KB
scripts/chrome-startup.test.mjsscript1.8 KB
scripts/curve-density.test.mjsscript4.1 KB
scripts/drive-actions.test.mjsscript3.0 KB
scripts/drive-async-until.test.mjsscript2.7 KB
scripts/drive-page-load.test.mjsscript1.3 KB
scripts/drive-turn-controller.test.mjsscript2.6 KB
scripts/drive.mjsscript23.3 KB
scripts/drive.test.mjsscript3.6 KB
scripts/enter-key.test.mjsscript2.5 KB
scripts/fidelity-cut.test.mjsscript4.7 KB
scripts/fidelity-tube-coverage.test.mjsscript3.1 KB
scripts/fingerprint.mjsscript1.2 KB
scripts/inline-kit.mjsscript648 B
scripts/line-ends.mjsscript15.8 KB
scripts/lines-arcs.test.mjsscript2.0 KB
scripts/lines-bezier.test.mjsscript1.7 KB
scripts/lines-round.test.mjsscript2.4 KB
scripts/lines-rounded-rect.test.mjsscript2.5 KB
scripts/lines.mjsscript1.7 KB
scripts/lines.test.mjsscript1.5 KB
scripts/navigation.test.mjsscript2.2 KB
scripts/orbit-sampling.test.mjsscript2.7 KB
scripts/print-sheet.mjsscript28.3 KB
scripts/print-sheet.test.mjsscript6.6 KB
scripts/print.mjsscript14.5 KB
scripts/publish.mjsscript19.8 KB
scripts/publish.test.mjsscript7.6 KB
scripts/react-dots-opacity.test.mjsscript2.8 KB
scripts/react-readout-first-write.test.mjsscript3.8 KB
scripts/react-readout-target.test.mjsscript4.5 KB
scripts/react-solid-seamless.test.mjsscript2.7 KB
scripts/react-visibility-target.test.mjsscript3.8 KB
scripts/session.mjsscript4.7 KB
scripts/session.test.mjsscript2.6 KB
scripts/turn-audit-samples.test.mjsscript1.3 KB
scripts/turn-bench.mjsscript3.8 KB
scripts/turn-check.mjsscript37.5 KB
scripts/turn-convex-check.test.mjsscript1.8 KB
scripts/turn-fidelity.mjsscript19.9 KB
scripts/turn-group-reference.test.mjsscript2.1 KB
scripts/turn-rounded-polygon.test.mjsscript1.5 KB
scripts/turn-split-owner.test.mjsscript3.3 KB
tests/fixtures/react-dots-dark.pngbinary3.9 KB
tests/fixtures/react-dots-light.pngbinary3.8 KB
tests/fixtures/react-solid-dark.pngbinary9.2 KB
tests/fixtures/react-solid-light.pngbinary9.6 KB

scripts/print.mjs

View on GitHub
import { spawnSync } from "node:child_process";
import { closeSync, existsSync, mkdtempSync, openSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
import { homedir, tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { FORMATS, PAPER, pagesOf, sheetHtml } from "./print-sheet.mjs";

const HERE = dirname(fileURLToPath(import.meta.url));
const DRIVE = join(HERE, "drive.mjs");

function usage() {
  console.log(`Print a figure as an explained drawing on one A4 sheet: an HTML page and a PDF.

  node print.mjs <sheet.mjs> [--format poster|drawing|detailed|all] [--letter] [--png] [--out name]

  sheet.mjs     a module whose default export names the built page, the poses to capture, the parts and the text
                (see references/print.md and examples/raptor-engine/sheet.mjs)
  --format f    poster (one page, big title, numbers and a legend; the default), drawing (one page, parts list,
                specification and a strip of steps), detailed (two pages: the figure with every part, then the steps,
                close-ups and the why), or all
  --letter      US Letter instead of A4
  --png         also write a preview PNG of the sheet
  --out name    output base name (default: the spec's out, else the page name)

Writes <name>-<format>-a4.html and .pdf next to the spec.`);
}

export function chromePath() {
  const candidates = [
    process.env.CHROME_PATH,
    "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
    "/Applications/Chromium.app/Contents/MacOS/Chromium",
    "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
    "/usr/bin/google-chrome",
    "/usr/bin/google-chrome-stable",
    "/usr/bin/chromium",
    "/usr/bin/chromium-browser",
    "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
    "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
    ...(process.env.LOCALAPPDATA ? [join(process.env.LOCALAPPDATA, "Google\\Chrome\\Application\\chrome.exe")] : []),
    "C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe",
    "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
  ].filter(Boolean);
  const playwright = join(homedir(), "Library/Caches/ms-playwright");
  if (existsSync(playwright)) {
    for (const dir of readdirSync(playwright).sort().reverse()) {
      for (const sub of ["chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing", "chrome-mac/Chromium.app/Contents/MacOS/Chromium", "chrome-linux/chrome"]) {
        candidates.push(join(playwright, dir, sub));
      }
    }
  }
  const linux = join(homedir(), ".cache/ms-playwright");
  if (existsSync(linux)) for (const dir of readdirSync(linux).sort().reverse()) for (const sub of ["chrome-linux64/chrome", "chrome-linux/chrome"]) candidates.push(join(linux, dir, sub));
  return candidates.find((path) => existsSync(path));
}

export function captureScript(spec) {
  const config = {
    layers: spec.layers ?? ".iso-stage svg.iso-svg, .iso-plate svg.iso-svg",
    strip: spec.strip ?? [],
    parts: (spec.parts ?? []).filter((part) => part.select).map(({ id, select }) => ({ id, select })),
    frame: spec.rasterSelector ?? ".iso-stage",
  };
  return `(() => {
  const C = ${JSON.stringify(config)};
  const TONES = ["hi", "mid", "lo", "dot"];
  const layers = [...document.querySelectorAll(C.layers)].filter((svg) => svg.viewBox && svg.viewBox.baseVal && svg.viewBox.baseVal.width);
  if (!layers.length) return { __print: true, error: "no layers match " + C.layers };
  const base = layers[0];
  const vbox = base.viewBox.baseVal;
  const rect = base.getBoundingClientRect();
  const k = vbox.width / rect.width;
  const toVb = (b) => [vbox.x + (b.left - rect.left) * k, vbox.y + (b.top - rect.top) * k, vbox.x + (b.right - rect.left) * k, vbox.y + (b.bottom - rect.top) * k];
  const sets = C.parts.map((part) => ({ id: part.id, els: layers.map((svg) => [...svg.querySelectorAll(part.select)]) }));
  const boxes = {};
  const anchors = {};
  for (const set of sets) {
    let box = null;
    let best = null;
    for (const el of set.els.flat()) {
      const b = el.getBoundingClientRect();
      if (!b.width && !b.height) continue;
      const v = toVb(b);
      box = box ? [Math.min(box[0], v[0]), Math.min(box[1], v[1]), Math.max(box[2], v[2]), Math.max(box[3], v[3])] : v;
      for (const shape of el.matches("path,circle,ellipse,rect,polygon") ? [el] : el.querySelectorAll("path,circle,ellipse,rect,polygon")) {
        if (shape.closest(".iso-halo, [class*=halo]")) continue;
        const s = shape.getBoundingClientRect();
        const area = s.width * s.height;
        if (!best || area > best.area) best = { area, at: [(toVb(s)[0] + toVb(s)[2]) / 2, (toVb(s)[1] + toVb(s)[3]) / 2] };
      }
    }
    if (box) boxes[set.id] = box.map((n) => Math.round(n * 10) / 10);
    if (best) anchors[set.id] = best.at.map((n) => Math.round(n * 10) / 10);
  }
  const html = layers.map((svg, index) => {
    const live = new Map();
    for (const set of sets) for (const el of set.els[index]) live.set(el, set.id);
    const clone = svg.cloneNode(true);
    const walkLive = [...svg.querySelectorAll("*")];
    const walkClone = [...clone.querySelectorAll("*")];
    walkLive.forEach((el, at) => {
      const id = live.get(el);
      if (!id) return;
      const cs = getComputedStyle(el);
      const tokens = TONES.map((tone) => "--anatomy-" + tone + ":var(--on-" + id + "-" + tone + ",var(--part-" + tone + "," + (cs.getPropertyValue("--anatomy-" + tone).trim() || "currentColor") + "))").join(";");
      const target = walkClone[at];
      const own = target.getAttribute("style");
      target.setAttribute("style", (own ? own.replace(/;?\\s*$/, ";") : "") + tokens + ";display:var(--show-" + id + "," + (cs.display === "none" ? "none" : "inline") + ")");
      target.setAttribute("data-print-part", id);
    });
    for (const sel of C.strip) clone.querySelectorAll(sel).forEach((el) => el.remove());
    clone.querySelectorAll("title,desc").forEach((el) => el.remove());
    clone.querySelectorAll("[id]").forEach((el) => el.setAttribute("id", "ps" + index + "-" + el.id));
    let inner = clone.innerHTML;
    clone.querySelectorAll("[id]").forEach((el) => {
      const old = el.id.slice(("ps" + index + "-").length);
      inner = inner.split("url(#" + old + ")").join("url(#" + el.id + ")").split('href="#' + old + '"').join('href="#' + el.id + '"');
    });
    return inner;
  });
  let content = null;
  for (const svg of layers) for (const el of svg.children) {
    if (el.tagName === "defs" || el.tagName === "title" || el.tagName === "desc") continue;
    const b = el.getBoundingClientRect();
    if (!b.width || !b.height) continue;
    const v = toVb(b);
    content = content ? [Math.min(content[0], v[0]), Math.min(content[1], v[1]), Math.max(content[2], v[2]), Math.max(content[3], v[3])] : v;
  }
  const css = [...document.querySelectorAll("style")].map((s) => s.textContent).join("\\n");
  const r = (document.querySelector(C.frame) || base.parentElement).getBoundingClientRect();
  return { __print: true, vb: [vbox.x, vbox.y, vbox.width, vbox.height], content: content && [content[0], content[1], content[2] - content[0], content[3] - content[1]].map((n) => Math.round(n * 10) / 10), k, offset: [(rect.left - r.left), (rect.top - r.top)], layers: html, boxes, anchors, css, readout: (document.querySelector("[data-readout]") || {}).textContent || "" };
})()`;
}

function drive(page, actions, { reduced, width, height }) {
  const profile = mkdtempSync(join(tmpdir(), "iso-print-"));
  const file = join(profile, "actions.json");
  writeFileSync(file, JSON.stringify(actions));
  const args = [DRIVE, page, "--actions", file, "--width", String(width), "--height", String(height)];
  if (reduced) args.push("--reduced");
  const log = join(profile, "out.txt");
  const fd = openSync(log, "w");
  const run = spawnSync(process.execPath, args, { stdio: ["ignore", fd, "pipe"], encoding: "utf8", maxBuffer: 1 << 26 });
  closeSync(fd);
  const stdout = readFileSync(log, "utf8");
  rmSync(profile, { recursive: true, force: true });
  if (run.status !== 0) throw new Error(`drive.mjs failed:\n${(run.stderr || stdout || "").slice(-2000)}`);
  return stdout
    .split("\n")
    .filter((line) => line.startsWith("eval: "))
    .map((line) => JSON.parse(line.slice(6)));
}

export async function capture(spec, pagePath) {
  const options = { reduced: spec.reduced ?? true, width: spec.width ?? 1200, height: spec.height ?? 1200 };
  const views = Object.entries(spec.views ?? { rest: {} });
  const script = captureScript(spec);
  const actions = [["wait", spec.settle ?? 1200]];
  for (const [, view] of views) actions.push(...(view.actions ?? []), ["eval", script], ...(view.reset ?? []));
  const results = drive(pagePath, actions, options).filter((result) => result && result.__print);
  if (results.length !== views.length) throw new Error(`expected ${views.length} captures, got ${results.length}`);
  const out = { views: {}, css: "" };
  results.forEach((result, index) => {
    if (result.error) throw new Error(result.error);
    out.css = result.css;
    const [name, view] = views[index];
    out.views[name] = { vb: result.vb, content: result.content, layers: result.layers, boxes: result.boxes, anchors: result.anchors, k: result.k, offset: result.offset, readout: result.readout, raster: view.raster ? true : undefined };
  });
  const rasters = views.filter(([, view]) => view.raster);
  if (rasters.length) {
    const dir = mkdtempSync(join(tmpdir(), "iso-print-shots-"));
    const shots = [["wait", spec.settle ?? 1200]];
    for (const [name, view] of views) {
      shots.push(...(view.actions ?? []));
      if (view.raster) {
        const captured = out.views[name];
        const region = view.raster.region ?? captured.vb;
        const [vx, vy] = captured.vb;
        const box = [(region[0] - vx) / captured.k + captured.offset[0], (region[1] - vy) / captured.k + captured.offset[1], region[2] / captured.k, region[3] / captured.k].map((n) => Math.round(n));
        shots.push(["shot", join(dir, `${name}.png`), view.raster.selector ?? spec.rasterSelector ?? ".iso-stage", view.raster.scale ?? 2, box]);
        out.views[name].raster = { region, file: join(dir, `${name}.png`) };
      }
      shots.push(...(view.reset ?? []));
    }
    drive(pagePath, shots, options);
    for (const [name] of rasters) {
      const raster = out.views[name].raster;
      if (!existsSync(raster.file)) throw new Error(`raster shot for ${name} was not written`);
      raster.href = `data:image/png;base64,${readFileSync(raster.file).toString("base64")}`;
      delete raster.file;
    }
    rmSync(dir, { recursive: true, force: true });
  }
  return out;
}

export function printPdf(htmlFile, pdfFile, { png, paper, pages: expected = 1 } = {}) {
  const binary = chromePath();
  if (!binary) throw new Error("No Chrome found. Set CHROME_PATH to a Chrome or Chromium binary.");
  const profile = mkdtempSync(join(tmpdir(), "iso-print-pdf-"));
  const common = ["--headless=new", ...(process.platform === "linux" ? ["--no-sandbox"] : []), "--disable-gpu", "--hide-scrollbars", "--no-first-run", "--no-default-browser-check", "--mute-audio", "--allow-file-access-from-files", `--user-data-dir=${profile}`];
  const url = pathToFileURL(htmlFile).href;
  if (existsSync(pdfFile)) rmSync(pdfFile);
  spawnSync(binary, [...common, "--no-pdf-header-footer", `--print-to-pdf=${pdfFile}`, url], { stdio: "ignore", timeout: 120000 });
  if (png) spawnSync(binary, [...common, "--force-device-scale-factor=2", `--window-size=${paper.px[0]},${paper.px[1] * expected}`, `--screenshot=${png}`, `${url}?print`], { stdio: "ignore", timeout: 120000 });
  rmSync(profile, { recursive: true, force: true });
  if (!existsSync(pdfFile) || !statSync(pdfFile).size) throw new Error(`Chrome did not write ${pdfFile}`);
  const pages = (readFileSync(pdfFile, "latin1").match(/\/Type\s*\/Page(?![s\w])/g) ?? []).length;
  return { pages, bytes: statSync(pdfFile).size };
}

async function main() {
  const argv = process.argv.slice(2);
  if (!argv.length || argv.includes("--help") || argv.includes("-h")) {
    usage();
    process.exit(argv.length ? 0 : 1);
  }
  const rest = [];
  const options = { letter: false, png: false, out: null, format: null };
  for (let index = 0; index < argv.length; index++) {
    const arg = argv[index];
    if (arg === "--letter") options.letter = true;
    else if (arg === "--png") options.png = true;
    else if (arg === "--out") options.out = argv[++index];
    else if (arg === "--format") options.format = argv[++index];
    else rest.push(arg);
  }
  const specFile = resolve(rest[0]);
  const spec = (await import(pathToFileURL(specFile).href)).default;
  const dir = dirname(specFile);
  const pagePath = resolve(dir, spec.page);
  if (!existsSync(pagePath)) throw new Error(`no built page at ${pagePath}; build the figure with --light first`);
  const paper = options.letter ? PAPER.letter : PAPER.a4;
  const formats = options.format === "all" ? FORMATS : [options.format ?? spec.format ?? "poster"];
  for (const format of formats) if (!FORMATS.includes(format)) throw new Error(`unknown format "${format}"; use one of ${FORMATS.join(", ")} or all`);
  const base = options.out ?? spec.out ?? spec.page.replace(/(-light)?\.html$/, "");
  const captured = await capture(spec, pagePath);
  for (const part of spec.parts ?? []) {
    if (part.select && !captured.views[spec.main.view].boxes[part.id]) console.warn(`warning: part ${part.id} matched nothing in view ${spec.main.view}`);
  }
  let failed = false;
  for (const format of formats) {
    const name = `${base}-${format}-${options.letter ? "letter" : "a4"}`;
    const html = sheetHtml(captured, spec, paper, format);
    const htmlFile = join(dir, `${name}.html`);
    writeFileSync(htmlFile, html);
    const pdfFile = join(dir, `${name}.pdf`);
    const png = options.png ? join(dir, `${name}.png`) : null;
    const expected = pagesOf(format, spec);
    const { pages, bytes } = printPdf(htmlFile, pdfFile, { png, paper, pages: expected });
    console.log(`wrote ${name}.html (${(html.length / 1024).toFixed(0)} KB) and ${name}.pdf (${(bytes / 1024).toFixed(0)} KB, ${pages} page${pages === 1 ? "" : "s"})${png ? ` and ${name}.png` : ""}`);
    if (pages !== expected) {
      console.error(`${format} should print on ${expected} page${expected === 1 ? "" : "s"} but runs to ${pages}; shorten the text or the steps until it fits`);
      failed = true;
    }
  }
  if (failed) process.exit(1);
}

if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await main();
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall