Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(skills): lock the skill-pack contract and make the repo builder importable
ni3a41632745cad8
diff --git a/scripts/build-standalone-skill-repos.mjs b/scripts/build-standalone-skill-repos.mjsindex f8723c35f..6aa3480e0 100644--- a/scripts/build-standalone-skill-repos.mjs+++ b/scripts/build-standalone-skill-repos.mjs@@ -14,6 +14,7 @@// node scripts/build-standalone-skill-repos.mjs --check # validate, write nothing// node scripts/build-standalone-skill-repos.mjs --only three-ws-3d-skills// node scripts/build-standalone-skill-repos.mjs --out <dir> # override output root+// node scripts/build-standalone-skill-repos.mjs --owner <gh login>//// Publishing is owner-gated and deliberately NOT automated here: the script// prints the exact `gh repo create` command per repo when it finishes.@@ -26,13 +27,16 @@ import { fileURLToPath } from 'node:url';import { collectSkills } from './build-skills-pack.mjs';const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');-const OWNER = 'nirholas';+// The GitHub account the repos live under, and the one every generated install+// line and repository URL points at. Override with --owner when publishing from+// a different account than the canonical one.+const DEFAULT_OWNER = 'nirholas';const SKILL_FILES_SKIP = new Set(['.DS_Store']);// Every repo selects skills from the canonical pack by predicate. Only// three.ws-origin skills ship: vendored partner drops belong to their publishers,// and the ops/production skill is for maintainers of this repo, not its users.-const REPOS = [+export const REPO_SPECS = [{repo: 'three-ws-skills',plugin: 'three-ws',@@ -72,86 +76,95 @@ const REPOS = [},];-const argv = process.argv.slice(2);-const CHECK = argv.includes('--check');-const only = valueOf('--only');-const outRoot = path.resolve(ROOT, valueOf('--out') || path.join('.data', 'standalone-repos'));--function valueOf(flag) {- const i = argv.indexOf(flag);- return i >= 0 ? argv[i + 1] : null;-}+// Importable as a library (the tests read REPO_SPECS): only build when this file+// is the entry point.+const invokedDirectly =+ process.argv[1] && path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));+if (invokedDirectly) main();++function main() {+ const argv = process.argv.slice(2);+ const CHECK = argv.includes('--check');+ const OWNER = valueOf('--owner') || DEFAULT_OWNER;+ const only = valueOf('--only');+ const outRoot = path.resolve(ROOT, valueOf('--out') || path.join('.data', 'standalone-repos'));++ function valueOf(flag) {+ const i = argv.indexOf(flag);+ return i >= 0 ? argv[i + 1] : null;+ }-const allSkills = collectSkills();-const specs = only ? REPOS.filter((r) => r.repo === only) : REPOS;-if (!specs.length) {- console.error(`no repo spec named "${only}". Known: ${REPOS.map((r) => r.repo).join(', ')}`);- process.exit(1);-}+ const allSkills = collectSkills();+ const specs = only ? REPO_SPECS.filter((r) => r.repo === only) : REPO_SPECS;+ if (!specs.length) {+ console.error(`no repo spec named "${only}". Known: ${REPO_SPECS.map((r) => r.repo).join(', ')}`);+ process.exit(1);+ }-const built = [];-let failed = false;+ const built = [];+ let failed = false;-for (const spec of specs) {- const skills = allSkills.filter(spec.select).sort((a, b) => a.name.localeCompare(b.name));- if (!skills.length) {- console.error(`${spec.repo}: selects no skills: the predicate no longer matches the pack`);- failed = true;- continue;- }- for (const skill of skills) {- const src = path.join(ROOT, skill.path);- if (!fs.existsSync(path.join(src, 'SKILL.md'))) {- console.error(`${spec.repo}: ${skill.name} has no SKILL.md at ${skill.path}`);+ for (const spec of specs) {+ const skills = allSkills.filter(spec.select).sort((a, b) => a.name.localeCompare(b.name));+ if (!skills.length) {+ console.error(`${spec.repo}: selects no skills: the predicate no longer matches the pack`);failed = true;+ continue;}- }- if (failed) continue;-- const dest = path.join(outRoot, spec.repo);- if (!CHECK) {- fs.rmSync(dest, { recursive: true, force: true });- fs.mkdirSync(path.join(dest, '.claude-plugin'), { recursive: true });for (const skill of skills) {- copyTree(path.join(ROOT, skill.path), path.join(dest, 'skills', skill.name));+ const src = path.join(ROOT, skill.path);+ if (!fs.existsSync(path.join(src, 'SKILL.md'))) {+ console.error(`${spec.repo}: ${skill.name} has no SKILL.md at ${skill.path}`);+ failed = true;+ }}- write(path.join(dest, '.claude-plugin', 'marketplace.json'), marketplaceJson(spec));- write(path.join(dest, '.claude-plugin', 'plugin.json'), pluginJson(spec));- write(path.join(dest, 'README.md'), readme(spec, skills));- fs.copyFileSync(path.join(ROOT, 'LICENSE'), path.join(dest, 'LICENSE'));- write(path.join(dest, '.gitignore'), 'node_modules/\n.DS_Store\n');+ if (failed) continue;++ const dest = path.join(outRoot, spec.repo);+ if (!CHECK) {+ fs.rmSync(dest, { recursive: true, force: true });+ fs.mkdirSync(path.join(dest, '.claude-plugin'), { recursive: true });+ for (const skill of skills) {+ copyTree(path.join(ROOT, skill.path), path.join(dest, 'skills', skill.name));+ }+ write(path.join(dest, '.claude-plugin', 'marketplace.json'), marketplaceJson(spec, OWNER));+ write(path.join(dest, '.claude-plugin', 'plugin.json'), pluginJson(spec, OWNER));+ write(path.join(dest, 'README.md'), readme(spec, skills, OWNER));+ fs.copyFileSync(path.join(ROOT, 'LICENSE'), path.join(dest, 'LICENSE'));+ write(path.join(dest, '.gitignore'), 'node_modules/\n.DS_Store\n');+ }+ built.push({ spec, skills, dest });}- built.push({ spec, skills, dest });-}-if (failed) process.exit(1);+ if (failed) process.exit(1);-for (const { spec, skills, dest } of built) {- console.log(- `${CHECK ? 'ok' : 'built'} ${spec.repo} ${skills.length} skills ${- CHECK ? '' : path.relative(ROOT, dest)- }`.trimEnd(),- );- console.log(` ${skills.map((s) => s.name).join(', ')}`);-}+ for (const { spec, skills, dest } of built) {+ console.log(+ `${CHECK ? 'ok' : 'built'} ${spec.repo} ${skills.length} skills ${+ CHECK ? '' : path.relative(ROOT, dest)+ }`.trimEnd(),+ );+ console.log(` ${skills.map((s) => s.name).join(', ')}`);+ }-if (CHECK) {- console.log(`\n${built.length} repo spec(s) resolve against ${allSkills.length} packed skills.`);- process.exit(0);-}+ if (CHECK) {+ console.log(`\n${built.length} repo spec(s) resolve against ${allSkills.length} packed skills.`);+ process.exit(0);+ }-console.log('\nPublish one (owner-gated, run from the generated directory):\n');-for (const { spec, dest } of built) {- console.log(` cd ${path.relative(ROOT, dest)} && git init -b main && git add -A \\`);- console.log(` && git commit -m 'feat: ${spec.displayName} for Claude' \\`);- // Single-quote the description: a double-quoted shell string would expand- // "$THREE" in any repo blurb that names the coin.- console.log(- ` && gh repo create ${OWNER}/${spec.repo} --public --source=. --push --description ${shellQuote(spec.description)}`,- );- console.log('');+ console.log('\nPublish one (owner-gated, run from the generated directory):\n');+ for (const { spec, dest } of built) {+ console.log(` cd ${path.relative(ROOT, dest)} && git init -b main && git add -A \\`);+ console.log(` && git commit -m 'feat: ${spec.displayName} for Claude' \\`);+ // Single-quote the description: a double-quoted shell string would expand+ // "$THREE" in any repo blurb that names the coin.+ console.log(+ ` && gh repo create ${OWNER}/${spec.repo} --public --source=. --push --description ${shellQuote(spec.description)}`,+ );+ console.log('');+ }+ console.log(`Users then install with:\n /plugin marketplace add ${OWNER}/${built[0].spec.repo}`);}-console.log(`Users then install with:\n /plugin marketplace add ${OWNER}/${built[0].spec.repo}`);// ── helpers ────────────────────────────────────────────────────────────────@@ -175,7 +188,7 @@ function copyTree(src, dest) {}}-function pluginBody(spec) {+function pluginBody(spec, OWNER) {return {name: spec.plugin,description: spec.description,@@ -188,11 +201,11 @@ function pluginBody(spec) {};}-function pluginJson(spec) {- return `${JSON.stringify({ ...pluginBody(spec), skills: './skills' }, null, '\t')}\n`;+function pluginJson(spec, OWNER) {+ return `${JSON.stringify({ ...pluginBody(spec, OWNER), skills: './skills' }, null, '\t')}\n`;}-function marketplaceJson(spec) {+function marketplaceJson(spec, OWNER) {return `${JSON.stringify({name: spec.plugin,@@ -201,7 +214,7 @@ function marketplaceJson(spec) {version: '1.0.0',plugins: [{- ...pluginBody(spec),+ ...pluginBody(spec, OWNER),source: './',displayName: spec.displayName,category: spec.category,@@ -214,7 +227,7 @@ function marketplaceJson(spec) {)}\n`;}-function readme(spec, skills) {+function readme(spec, skills, OWNER) {const rows = skills.map((s) => `| \`${s.name}\` | ${s.description.replace(/\|/g, '\\|').replace(/\s+/g, ' ')} |`).join('\n');diff --git a/tests/agent-skills-pack.test.js b/tests/agent-skills-pack.test.jsnew file mode 100644index 000000000..e2a7cd4bf--- /dev/null+++ b/tests/agent-skills-pack.test.js@@ -0,0 +1,75 @@+// The Agent Skills pack and the standalone repos it generates are how every+// external Claude surface learns three.ws, and both are assembled by a script+// rather than hand-maintained. These tests lock the two contracts that silently+// break a distributed skill: frontmatter that a client cannot route on, and a+// standalone repo that ships a skill the platform never vetted.+import { describe, it, expect } from 'vitest';+import fs from 'node:fs';+import path from 'node:path';++import { collectSkills } from '../scripts/build-skills-pack.mjs';++const ROOT = path.resolve(import.meta.dirname, '..');+const pack = JSON.parse(fs.readFileSync(path.join(ROOT, '.agents/skills/skills-pack.json'), 'utf8'));+const skills = collectSkills();++describe('agent skills pack', () => {+ it('is in sync with the skill folders on disk', () => {+ expect(pack.skills.map((s) => s.name)).toEqual(skills.map((s) => s.name));+ });++ it('describes every category it counts', () => {+ for (const category of Object.keys(pack.counts)) {+ expect(pack.categories[category], `no description for ${category}`).toBeTruthy();+ }+ });++ it('gives every skill a trigger a client can route on', () => {+ for (const skill of skills) {+ expect(skill.description.length, `${skill.name}: description too short to trigger on`).toBeGreaterThan(40);+ expect(skill.name).toMatch(/^[a-z0-9][a-z0-9-]{0,63}$/);+ }+ });++ it('keeps our own triggers inside the spec length limit', () => {+ // Only our skills: vendored partner drops stay byte-identical to what their+ // publisher shipped, and several of theirs run past the spec's 1024 chars.+ for (const skill of skills.filter((s) => s.origin === 'three.ws')) {+ expect(skill.description.length, `${skill.name}: description over the 1024-char spec limit`).toBeLessThanOrEqual(1024);+ }+ });++ it('keeps the cross-platform-safe subset free of coin and payment-rail content', () => {+ // This subset is what ships to non-crypto tracks, so the markers that matter+ // are the unambiguous ones. "no payment required" is fine; naming a token,+ // a chain, or the payment protocol is not.+ const banned = /(\$THREE|\bUSDC\b|\bx402\b|\bSolana\b|\bpump\.fun\b|\bmainnet\b|private key)/i;+ for (const skill of skills.filter((s) => s.crossPlatformSafe)) {+ const body = fs.readFileSync(path.join(ROOT, skill.path, 'SKILL.md'), 'utf8');+ const hit = body.split('\n').find((line) => banned.test(line));+ expect(hit, `${skill.name} is marked cross-platform-safe but mentions: ${hit}`).toBeUndefined();+ }+ });+});++describe('standalone skill repos', () => {+ it('only ever select three.ws-origin skills', async () => {+ const { REPO_SPECS } = await import('../scripts/build-standalone-skill-repos.mjs');+ for (const spec of REPO_SPECS) {+ const selected = skills.filter(spec.select);+ expect(selected.length, `${spec.repo} selects nothing`).toBeGreaterThan(0);+ for (const skill of selected) {+ expect(skill.origin, `${spec.repo} would republish a vendored skill: ${skill.name}`).toBe('three.ws');+ }+ }+ });++ it('never publish the maintainer-only ops skills', async () => {+ const { REPO_SPECS } = await import('../scripts/build-standalone-skill-repos.mjs');+ for (const spec of REPO_SPECS) {+ for (const skill of skills.filter(spec.select)) {+ expect(skill.category, `${spec.repo} includes ${skill.name}`).not.toBe('ops/production');+ }+ }+ });+});