Skip to content

An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.

Publish source only, under figures/<author>/<id>/

R.4bab673bfb14
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a420885..aa19fb9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha
### Added
-- `scripts/publish.mjs` and `references/publish.md`: share a finished framework-free figure in the community gallery, `wheresryan22/anatomy-community`. The script copies the figure, points its kit imports at the gallery's `.skill/` link, records the kit fingerprint (`scripts/fingerprint.mjs`) so the gallery can rebuild it with the same kit version, rebuilds the pages and takes the poster. It never pushes.
+- `scripts/publish.mjs` and `references/publish.md`: share a finished framework-free figure in the community gallery, `wheresryan22/anatomy-community`. The script copies the figure, points its kit imports at the gallery's `.skill/` link, records the kit fingerprint (`scripts/fingerprint.mjs`) so the gallery can rebuild it with the same kit version, and copies only the source, under `figures/<author>/<id>/`. The gallery builds the pages in a locked sandbox. It never pushes.
- OpenCode and Codex support, alongside Claude Code. `SKILL.md` exposes `/anatomy` to OpenCode through `metadata`, `agents/openai.yaml` gives Codex its display name, and the README, CONTRIBUTING and the bug report form cover all three agents.
- `examples/arcade-cabinet/`, an upright arcade cabinet with its side panel off. A quarter rolls down the coin chute past the coin-switch wire into the cash box, the switch's pulse runs along its cable to the board, and the CRT warms up, self-tests and runs an attract mode drawn in the plane of the tilted monitor; the stick closes a microswitch under the panel. It draws in the light and dark themes and passes `--audit`.
- `examples/spot-plate/`, a second React figure from the same site as `test-rig`: six pairs of glass drops that run together into one piece of glass as a fan of feeler blades sets `merge`. It draws in the light and dark themes.
diff --git a/references/publish.md b/references/publish.md
index 634ee99..2ce79aa 100644
--- a/references/publish.md
+++ b/references/publish.md
@@ -21,11 +21,11 @@ Publish only when the user asks to share or publish a figure. Never push, fork o
[--agent "Claude Code"|OpenCode|Codex|Other] [--model "..."] [--license MIT|CC-BY-4.0] \
[--tags a,b] [--audit] [--pages dark.html,light.html]
```
- Pass `--agent` for the agent you are running in. It copies the figure's source into `figures/<id>/src/`, points its kit imports at the clone's `.skill/` link, records the kit fingerprint, rebuilds the pages there and takes `poster.png`.
+ Pass `--agent` for the agent you are running in. It copies only the figure's source into `figures/<author>/<id>/src/`, points its kit imports at the clone's `.skill/` link, records the kit fingerprint, checks the build works and removes what it built: the gallery keeps source only, and its CI builds the pages and the poster.
- If it says a file reaches outside the figure folder and the skill, copy what that file needs into the figure folder, rebuild, and publish again.
- If it can't tell which pages are the figure, pass `--pages`.
-5. **Validate inside the clone:** `node scripts/validate.mjs figures/<id>` must end `passed`. Fix what it names. It runs the same checks as the gallery's CI, which also fetches the exact skill version from GitHub.
-6. **Show the user** the poster and the result, then give them the git and `gh` commands the publish script printed. They run them.
+5. **Validate inside the clone:** `node scripts/validate.mjs figures/<author>/<id>` must end `passed`. Fix what it names. With Docker running (`docker build --platform linux/amd64 -t anatomy-sandbox:local sandbox` once), it runs the build in the same locked, network-less container as the gallery's CI; without Docker it still checks everything except the network isolation.
+6. **Show the user** the poster and screenshots in `shots/<author>-<id>/`, then give them the git and `gh` commands the publish script printed. They run them.
## What the gallery rejects
@@ -34,6 +34,7 @@ Publish only when the user asks to share or publish a figure. Never push, fork o
- frames, cookies, or reaching the page around the figure;
- build imports other than the skill, the figure's own files and `node:fs`, `node:path`, `node:url`, `node:crypto` or `node:process`;
- reading environment variables;
-- files other than source text under `src/`;
-- pages that the build does not reproduce exactly.
+- files other than source text under `src/`, or committed built pages;
+- builds that write anything but their pages, or that differ between two runs;
+- figures that keep moving with reduced motion on.
Write figures that way from the start if the user plans to share them.
diff --git a/scripts/publish.mjs b/scripts/publish.mjs
index d91aed4..a6f24de 100644
--- a/scripts/publish.mjs
+++ b/scripts/publish.mjs
@@ -1,5 +1,5 @@
import { spawnSync } from "node:child_process";
-import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
+import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
import { fileURLToPath } from "node:url";
import { fingerprintOfSkill } from "./fingerprint.mjs";
@@ -20,9 +20,10 @@ function usage(message) {
node scripts/publish.mjs <figure folder> --into <anatomy-community clone> --id <kebab-id> --title "..." --prompt "..." --author <github user>
[--agent "Claude Code"|OpenCode|Codex|Other] [--model "..."] [--license MIT|CC-BY-4.0] [--tags a,b]
- [--build build.mjs] [--pages dark.html,light.html] [--kind "SVG + WebGL"] [--audit] [--no-poster] [--force]
+ [--build build.mjs] [--pages dark.html,light.html] [--kind "SVG + WebGL"] [--audit] [--force]
-The figure must be framework-free: a build script that writes standalone pages next to itself.
+The figure must be plain HTML: a build script that writes standalone pages next to itself, with a light page.
+Only the source is copied, to figures/<author>/<id>/: the gallery's CI builds the pages and the poster.
Nothing is pushed: the command prints the git and gh commands to run when you are ready.`);
process.exit(message ? 1 : 0);
}
@@ -41,7 +42,6 @@ function parse(argv) {
else if (arg === "--tags") options.tags = take(index++).split(",").map((tag) => tag.trim()).filter(Boolean);
else if (arg === "--pages") options.pages = take(index++).split(",").map((page) => page.trim());
else if (arg === "--audit") options.audit = true;
- else if (arg === "--no-poster") options.noPoster = true;
else if (arg === "--force") options.force = true;
else if (arg.startsWith("--")) usage(`unknown option ${arg}`);
else if (!options.source) options.source = arg;
@@ -114,21 +114,25 @@ export function publish(options) {
if (!existsSync(join(source, options.build))) throw new Error(`no ${options.build} in ${source}`);
if (!existsSync(join(repo, "figures")) || !existsSync(join(repo, "scripts", "validate.mjs"))) throw new Error(`${repo} doesn't look like a clone of anatomy-community (no figures/ or scripts/validate.mjs)`);
if (inside(SKILL, source) && !inside(join(SKILL, "examples"), source)) throw new Error("the figure folder is inside the skill itself; publish the folder where the figure was built");
- const dest = join(repo, "figures", options.id);
+ const author = options.author.replace(/^@/, "");
+ if (!/^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/.test(author)) throw new Error("--author must be a GitHub username");
+ const dest = join(repo, "figures", author.toLowerCase(), options.id);
if (existsSync(dest)) {
- if (!options.force) throw new Error(`figures/${options.id} already exists; pick another --id or pass --force to replace it`);
+ if (!options.force) throw new Error(`figures/${author.toLowerCase()}/${options.id} already exists; pick another --id or pass --force to replace it`);
rmSync(dest, { recursive: true, force: true });
}
const all = listFiles(source);
- const files = all.filter((file) => SOURCE_TYPES.includes(extname(file).toLowerCase()));
- const skipped = all.filter((file) => !files.includes(file));
- const pages = detectPages(source, files, options.pages);
- for (const page of Object.values(pages)) if (page && !files.includes(page)) throw new Error(`page ${page} not found in ${source}; build the figure first`);
+ const typed = all.filter((file) => SOURCE_TYPES.includes(extname(file).toLowerCase()));
+ const pages = detectPages(source, typed, options.pages);
+ for (const page of Object.values(pages)) if (page && !typed.includes(page)) throw new Error(`page ${page} not found in ${source}; build the figure first`);
const themeOf = (page) => (readFileSync(join(source, page), "utf8").match(/<body[^>]*\bdata-theme="(light|dark)"/) ?? [])[1] ?? "dark";
if (pages.dark && !pages.light && themeOf(pages.dark) === "light") [pages.light, pages.dark] = [pages.dark, undefined];
if (!pages.light) throw new Error("the gallery shows figures in the light theme: build the light page too (node build.mjs --light), then publish again");
for (const [key, page] of Object.entries(pages)) if (page && themeOf(page) !== key) throw new Error(`${page} is a ${themeOf(page)} page, not ${key}; pass --pages dark.html,light.html in that order`);
+ const outputs = new Set(Object.values(pages).filter(Boolean));
+ const files = typed.filter((file) => !outputs.has(file) && !/-verify(?:-light)?\.html$/.test(file));
+ const skipped = all.filter((file) => !files.includes(file) && !outputs.has(file));
const skillLink = join(repo, ".skill");
const kit = fingerprintOfSkill(SKILL);
@@ -160,12 +164,12 @@ export function publish(options) {
const build = [[`src/${options.build}`, "--light"]];
if (pages.dark) build.push([`src/${options.build}`]);
for (const command of build) run(command, dest);
-
const pageText = Object.values(pages).filter(Boolean).map((page) => readFileSync(join(dest, "src", page), "utf8")).join("\n");
+ for (const page of outputs) rmSync(join(dest, "src", page), { force: true });
const figure = {
id: options.id,
title: options.title.trim(),
- author: options.author.replace(/^@/, ""),
+ author,
prompt: options.prompt.trim(),
kind: options.kind ?? detectKind(pageText),
agent: options.agent,
@@ -180,12 +184,6 @@ export function publish(options) {
};
writeFileSync(join(dest, "figure.json"), JSON.stringify(figure, null, 2) + "\n");
- if (!options.noPoster) {
- const page = join(dest, "src", pages.light);
- run([join(SKILL, "scripts", "capture.mjs"), page, "--width", "1200", "--out", join(dest, "poster.png")], dest);
- const size = statSync(join(dest, "poster.png")).size;
- if (size > 600 << 10) throw new Error(`poster.png is ${(size / 1024).toFixed(0)} KB, over 600 KB; retake it smaller with scripts/capture.mjs --width 900`);
- }
return { dest, figure, skipped, linked };
}
@@ -194,11 +192,12 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
try {
const { dest, figure, skipped, linked } = publish(options);
const repo = resolve(options.into);
- console.log(`published figures/${figure.id} (${figure.kind}, kit ${figure.skill.kit.slice(7, 19)})`);
+ console.log(`published figures/${figure.author.toLowerCase()}/${figure.id} (${figure.kind}, kit ${figure.skill.kit.slice(7, 19)}): source only, the gallery builds the pages`);
if (skipped.length) console.log(` left out (not a source type): ${skipped.join(", ")}`);
console.log(` .skill link: ${linked}`);
- console.log(`\nCheck it:\n cd ${repo}\n node scripts/validate.mjs figures/${figure.id}`);
- console.log(`\nWhen you are happy with it, from your fork of anatomy-community:\n git switch -c figure/${figure.id}\n git add figures/${figure.id}\n git commit -m "Add ${figure.title.replace(/"/g, "'")}"\n git push -u origin figure/${figure.id}\n gh pr create --repo wheresryan22/anatomy-community --fill`);
+ const where = `figures/${figure.author.toLowerCase()}/${figure.id}`;
+ console.log(`\nCheck it:\n cd ${repo}\n node scripts/validate.mjs ${where}`);
+ console.log(`\nWhen you are happy with it, from your fork of anatomy-community:\n git switch -c figure/${figure.id}\n git add ${where}\n git commit -m "Add ${figure.title.replace(/"/g, "'")}"\n git push -u origin figure/${figure.id}\n gh pr create --repo wheresryan22/anatomy-community --fill`);
} catch (error) {
console.error(`publish: ${error.message}`);
process.exit(1);
diff --git a/scripts/publish.test.mjs b/scripts/publish.test.mjs
index f0ce7d9..7e78f49 100644
--- a/scripts/publish.test.mjs
+++ b/scripts/publish.test.mjs
@@ -1,4 +1,5 @@
import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
@@ -35,17 +36,21 @@ test("skill paths are rewritten to the gallery's .skill link, and nothing else",
assert.deepEqual(away.outside, ["../../elsewhere/x.mjs"]);
});
-test("publishing an example rebuilds it byte for byte in the gallery", () => {
+test("publishing copies only the source, under the author, and it rebuilds byte for byte", () => {
const repo = gallery();
try {
- const { dest, figure } = publish({ source: join(SKILL, "examples", "dial-indicator"), into: repo, id: "dial-indicator", title: "Dial indicator", prompt: "/anatomy a dial indicator", author: "octo-cat", agent: "Codex", license: "MIT", build: "build.mjs", tags: [], noPoster: true, date: "2026-10-12" });
+ const { dest, figure } = publish({ source: join(SKILL, "examples", "dial-indicator"), into: repo, id: "dial-indicator", title: "Dial indicator", prompt: "/anatomy a dial indicator", author: "Octo-Cat", agent: "Codex", license: "MIT", build: "build.mjs", tags: [], date: "2026-10-12" });
+ assert.equal(dest, join(repo, "figures", "octo-cat", "dial-indicator"));
+ assert.equal(figure.author, "Octo-Cat");
+ assert.ok(!existsSync(join(dest, "src", "dial-indicator.html")) && !existsSync(join(dest, "src", "dial-indicator-light.html")) && !existsSync(join(dest, "poster.png")), "no built pages or poster are left");
assert.equal(figure.kind, "SVG");
assert.equal(figure.skill.kit, fingerprintOfSkill(SKILL));
assert.deepEqual(figure.build, [["src/build.mjs", "--light"], ["src/build.mjs"]]);
assert.deepEqual(figure.pages, { dark: "src/dial-indicator.html", light: "src/dial-indicator-light.html" });
+ for (const command of figure.build) assert.equal(spawnSync(process.execPath, command, { cwd: dest }).status, 0);
for (const page of ["dial-indicator.html", "dial-indicator-light.html"]) assert.ok(readFileSync(join(dest, "src", page)).equals(readFileSync(join(SKILL, "examples", "dial-indicator", page))), page);
assert.ok(existsSync(join(repo, ".skill", "kit", "iso-kit.mjs")));
- assert.throws(() => publish({ source: join(SKILL, "examples", "dial-indicator"), into: repo, id: "dial-indicator", title: "x", prompt: "x", author: "x", agent: "Codex", license: "MIT", build: "build.mjs", tags: [], noPoster: true }), /already exists/);
+ assert.throws(() => publish({ source: join(SKILL, "examples", "dial-indicator"), into: repo, id: "dial-indicator", title: "x", prompt: "x", author: "octo-cat", agent: "Codex", license: "MIT", build: "build.mjs", tags: [] }), /already exists/);
} finally {
rmSync(repo, { recursive: true, force: true });
}
@@ -54,7 +59,7 @@ test("publishing an example rebuilds it byte for byte in the gallery", () => {
test("publishing refuses a folder that is not a gallery clone", () => {
const empty = mkdtempSync(join(tmpdir(), "not-gallery-"));
try {
- assert.throws(() => publish({ source: join(SKILL, "examples", "dial-indicator"), into: empty, id: "x", title: "x", prompt: "x", author: "x", agent: "Codex", license: "MIT", build: "build.mjs", tags: [], noPoster: true }), /doesn't look like a clone of anatomy-community/);
+ assert.throws(() => publish({ source: join(SKILL, "examples", "dial-indicator"), into: empty, id: "x", title: "x", prompt: "x", author: "x", agent: "Codex", license: "MIT", build: "build.mjs", tags: [] }), /doesn't look like a clone of anatomy-community/);
} finally {
rmSync(empty, { recursive: true, force: true });
}