Skip to content

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.

1.6 KB
Raw Blame
#!/usr/bin/env node
// Regenerates .agents/skills/anatomy/reference.md from the spec guide the
// server writer uses (api/_lib/anatomy/guide.js), so an agent authoring a spec
// with the skill follows exactly the rules /api/anatomy enforces.
//
// Usage: node scripts/build-anatomy-skill.mjs [--check]
//   --check  exit 1 if reference.md differs from what would be generated

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { SPEC_GUIDE, OUTPUT_RULES } from '../api/_lib/anatomy/guide.js';

const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
export const REFERENCE_PATH = path.join(ROOT, '.agents', 'skills', 'anatomy', 'reference.md');

export function renderReference() {
	return [
		'<!-- Generated by scripts/build-anatomy-skill.mjs from api/_lib/anatomy/guide.js. Edit the guide, then rerun the script. -->',
		'',
		SPEC_GUIDE.trim(),
		'',
		'## Output rules',
		'',
		OUTPUT_RULES,
		'',
	].join('\n');
}

if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
	const next = renderReference();
	const current = fs.existsSync(REFERENCE_PATH) ? fs.readFileSync(REFERENCE_PATH, 'utf8') : null;
	if (process.argv.includes('--check')) {
		if (current !== next) {
			console.error('[anatomy-skill] reference.md is stale. Run: node scripts/build-anatomy-skill.mjs');
			process.exit(1);
		}
		console.log('[anatomy-skill] reference.md is current');
	} else {
		fs.mkdirSync(path.dirname(REFERENCE_PATH), { recursive: true });
		fs.writeFileSync(REFERENCE_PATH, next);
		console.log(`[anatomy-skill] wrote ${path.relative(ROOT, REFERENCE_PATH)}`);
	}
}