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.

7.6 KB
Raw Blame
#!/usr/bin/env node
/**
 * Listings registry: the machine-readable record of every place three.ws is
 * listed (directories, registries, marketplaces, awesome-lists, programs, press).
 *
 *   node scripts/listings.mjs --validate   schema, duplicate ids, ordering (default)
 *   node scripts/listings.mjs --build      regenerate docs/listings-registry.md
 *   node scripts/listings.mjs --check      --build in dry mode: fail if the doc is stale
 *   node scripts/listings.mjs --verify     fetch every live entry, confirm it still renders
 *                                          three.ws, and write the result back to the data file
 *   node scripts/listings.mjs --verify --id <id>   verify one entry
 *
 * Source of truth: data/listings.json. Edit it, then run --build.
 */
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
const DATA = join(ROOT, 'data/listings.json');
const DOC = join(ROOT, 'docs/listings-registry.md');

export const STATUSES = {
	live: 'Live',
	pr_open: 'PR open',
	pending: 'Submitted, pending',
	prerequisites: 'Ready to submit',
	not_listed: 'Not listed',
	declined: 'Declined or closed',
	unverified: 'Unverified',
};
const CATEGORIES = {
	'mcp': 'MCP directories',
	'x402': 'x402 and agent payments',
	'awesome-list': 'GitHub awesome-lists',
	'crypto': 'Crypto and token',
	'ai-directory': 'AI tool directories',
	'dev-registry': 'Developer registries and stores',
	'cloud': 'Cloud marketplaces',
	'program': 'Startup and credit programs',
	'ecosystem': 'Ecosystem directories',
	'press': 'Press, blogs and media',
	'social': 'Social and profiles',
	'3d': '3D, WebXR and three.js',
	'agent-registry': 'Agent registries and identity',
};
const VERIFIABLE = new Set(['live']);
const MATCH = /three\.ws|threews|three-ws|nirholas|FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump/i;

export function load() {
	return JSON.parse(readFileSync(DATA, 'utf8'));
}

export function validate(db) {
	const errs = [];
	const ids = new Set();
	for (const e of db.entries) {
		const at = `entry ${e.id || e.name || '?'}`;
		if (!/^[a-z0-9][a-z0-9-]*$/.test(e.id || '')) errs.push(`${at}: id must be kebab-case`);
		if (ids.has(e.id)) errs.push(`${at}: duplicate id`);
		ids.add(e.id);
		if (!e.name) errs.push(`${at}: name required`);
		if (!CATEGORIES[e.category]) errs.push(`${at}: unknown category "${e.category}"`);
		if (!STATUSES[e.status]) errs.push(`${at}: unknown status "${e.status}"`);
		if (e.status === 'live' && !e.manual && !/^https?:\/\//.test(e.url || '')) errs.push(`${at}: live entry needs an http(s) url or manual:true (membership with no public page)`);
		if (!/^\d{4}-\d{2}-\d{2}$/.test(e.checked || '')) errs.push(`${at}: checked must be YYYY-MM-DD`);
		if (!e.evidence) errs.push(`${at}: evidence required (what was seen, or why the status holds)`);
		for (const k of ['name', 'evidence', 'next']) {
			if (e[k] && /[\u2013\u2014]/.test(e[k])) errs.push(`${at}: ${k} contains a dash glyph`);
		}
	}
	return errs;
}

const esc = (s) => String(s ?? '').replace(/\|/g, '\\|').replace(/\n/g, ' ');

export function render(db) {
	const by = new Map();
	for (const e of db.entries) (by.get(e.category) || by.set(e.category, []).get(e.category)).push(e);
	const count = (s) => db.entries.filter((e) => e.status === s).length;
	const out = [];
	out.push('# Listings registry', '');
	out.push(
		'<!-- Generated by scripts/listings.mjs from data/listings.json. Do not edit by hand. -->',
		'',
		'Every place three.ws is listed, submitted to, or known to be absent from. This is the master index; the prose record with announcements and context is [listings.md](./listings.md), and the action list for stuck items is [partners/opportunities.md](./partners/opportunities.md).',
		'',
		`**${db.entries.length} tracked surfaces.** ` +
			Object.keys(STATUSES)
				.filter((s) => count(s))
				.map((s) => `${count(s)} ${STATUSES[s].toLowerCase()}`)
				.join(', ') +
			'.',
		'',
		'Maintain it:',
		'',
		'```',
		'npm run listings:verify    # re-fetch every live entry and stamp the result',
		'npm run listings:build     # regenerate this page after editing data/listings.json',
		'```',
		'',
		'A `live` entry is only ever set after the page was fetched and rendered three.ws content. `verify` downgrades an entry to `unverified` when its page stops matching, so a dropped listing surfaces instead of lingering.',
		'',
	);
	for (const [cat, title] of Object.entries(CATEGORIES)) {
		const rows = by.get(cat);
		if (!rows) continue;
		out.push(`## ${title}`, '', '| Surface | Status | Evidence | Next | Checked |', '|---|---|---|---|---|');
		const order = Object.keys(STATUSES);
		rows.sort((a, b) => order.indexOf(a.status) - order.indexOf(b.status) || a.name.localeCompare(b.name));
		for (const e of rows) {
			const name = e.url ? `[${esc(e.name)}](${e.url})` : esc(e.name);
			out.push(`| ${name} | ${STATUSES[e.status]} | ${esc(e.evidence)} | ${esc(e.next || '')} | ${e.checked} |`);
		}
		out.push('');
	}
	return out.join('\n');
}

async function verifyOne(e) {
	try {
		const res = await fetch(e.verify_url || e.url, {
			redirect: 'follow',
			signal: AbortSignal.timeout(20000),
			headers: { 'user-agent': 'Mozilla/5.0 (compatible; three.ws-listings-check)' },
		});
		const body = await res.text();
		if (res.status === 404 || res.status === 410) return { ok: false, note: `HTTP ${res.status}, the page is gone` };
		if (res.status >= 400) return { ok: null, note: `HTTP ${res.status}` };
		const re = e.match ? new RegExp(e.match, 'i') : MATCH;
		// Many directories render client side, so a missing name in the raw HTML is not proof of removal.
		return re.test(body) ? { ok: true } : { ok: null, note: 'name not in the server-rendered HTML, check by hand' };
	} catch (err) {
		return { ok: null, note: `fetch failed: ${err.message}` };
	}
}

async function main() {
	const args = process.argv.slice(2);
	const db = load();
	const errs = validate(db);
	if (errs.length) {
		console.error(errs.join('\n'));
		process.exit(1);
	}
	if (args.includes('--build')) {
		writeFileSync(DOC, render(db) + '\n');
		console.log(`wrote docs/listings-registry.md (${db.entries.length} entries)`);
	} else if (args.includes('--check')) {
		const cur = existsSync(DOC) ? readFileSync(DOC, 'utf8') : '';
		if (cur !== render(db) + '\n') {
			console.error('docs/listings-registry.md is stale: run npm run listings:build');
			process.exit(1);
		}
		console.log(`listings registry ok (${db.entries.length} entries)`);
	} else if (args.includes('--verify')) {
		const only = args.includes('--id') ? args[args.indexOf('--id') + 1] : null;
		const today = new Date().toISOString().slice(0, 10);
		const targets = db.entries.filter((e) => VERIFIABLE.has(e.status) && !e.manual && (!only || e.id === only));
		let bad = 0;
		for (let i = 0; i < targets.length; i += 6) {
			await Promise.all(
				targets.slice(i, i + 6).map(async (e) => {
					const r = await verifyOne(e);
					if (r.ok === true) {
						e.checked = today;
						console.log(`ok       ${e.id}`);
					} else if (r.ok === false) {
						e.status = 'unverified';
						e.checked = today;
						e.evidence = `${r.note} (was live until ${today})`;
						bad++;
						console.log(`DROPPED  ${e.id}: ${r.note}`);
					} else {
						bad++;
						console.log(`unknown  ${e.id}: ${r.note} (status left as is)`);
					}
				}),
			);
		}
		writeFileSync(DATA, JSON.stringify(db, null, '\t') + '\n');
		writeFileSync(DOC, render(db) + '\n');
		console.log(`${targets.length - bad}/${targets.length} verified`);
	} else {
		console.log(`listings.json valid (${db.entries.length} entries)`);
	}
}

if (process.argv[1] === fileURLToPath(import.meta.url)) await main();