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.mjs: progress messages and a local preview in shots/
R.7f450aa3d777
diff --git a/scripts/publish.mjs b/scripts/publish.mjsindex a6f24de..c21390d 100644--- a/scripts/publish.mjs+++ b/scripts/publish.mjs@@ -20,7 +20,7 @@ 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] [--force]+ [--build build.mjs] [--pages dark.html,light.html] [--kind "SVG + WebGL"] [--audit] [--no-preview] [--force]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.@@ -43,6 +43,7 @@ function parse(argv) {else if (arg === "--pages") options.pages = take(index++).split(",").map((page) => page.trim());else if (arg === "--audit") options.audit = true;else if (arg === "--force") options.force = true;+ else if (arg === "--no-preview") options.noPreview = true;else if (arg.startsWith("--")) usage(`unknown option ${arg}`);else if (!options.source) options.source = arg;else usage(`unexpected argument ${arg}`);@@ -109,6 +110,7 @@ function run(args, cwd) {}export function publish(options) {+ const log = options.log ?? (() => {});const source = resolve(options.source);const repo = resolve(options.into);if (!existsSync(join(source, options.build))) throw new Error(`no ${options.build} in ${source}`);@@ -163,7 +165,18 @@ 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);+ for (const command of build) {+ log(`building the ${command.includes("--light") ? "light" : "dark"} page (heavy figures take a minute or two)…`);+ run(command, dest);+ }+ let preview = null;+ if (!options.noPreview) {+ log("taking a preview of the light page…");+ const shots = join(repo, "shots", `${author.toLowerCase()}-${options.id}`);+ mkdirSync(shots, { recursive: true });+ preview = join(shots, "preview.png");+ run([join(SKILL, "scripts", "capture.mjs"), join(dest, "src", pages.light), "--reduced", "--width", "1200", "--out", preview], 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 = {@@ -184,17 +197,19 @@ export function publish(options) {};writeFileSync(join(dest, "figure.json"), JSON.stringify(figure, null, 2) + "\n");- return { dest, figure, skipped, linked };+ return { dest, figure, skipped, linked, preview };}if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {const options = parse(process.argv.slice(2));try {- const { dest, figure, skipped, linked } = publish(options);+ console.log(`publishing ${options.id}…`);+ const { dest, figure, skipped, linked, preview } = publish({ ...options, log: (line) => console.log(` ${line}`) });const repo = resolve(options.into);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}`);+ if (preview) console.log(` preview: ${preview} (not committed; CI makes the real one)`);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`);diff --git a/scripts/publish.test.mjs b/scripts/publish.test.mjsindex 7e78f49..a4c070e 100644--- a/scripts/publish.test.mjs+++ b/scripts/publish.test.mjs@@ -39,7 +39,7 @@ test("skill paths are rewritten to the gallery's .skill link, and nothing else",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: [], 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", noPreview: true });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");@@ -50,7 +50,7 @@ test("publishing copies only the source, under the author, and it rebuilds bytefor (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: "octo-cat", agent: "Codex", license: "MIT", build: "build.mjs", tags: [] }), /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: [], noPreview: true }), /already exists/);} finally {rmSync(repo, { recursive: true, force: true });}@@ -59,7 +59,7 @@ test("publishing copies only the source, under the author, and it rebuilds bytetest("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: [] }), /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: [], noPreview: true }), /doesn't look like a clone of anatomy-community/);} finally {rmSync(empty, { recursive: true, force: true });}