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.

8.1 KB
Raw Blame
#!/usr/bin/env node
// announce-plan.mjs - turn the ranked backlog into a dated posting calendar.
//
// The ledger (`npm run announce:rank -- --write`) says what is worth
// announcing. This says when each one goes out, in which lane, in which shape,
// and which ones need owner approval on their media before they can be
// committed. It is the piece that was missing between "322 surfaces have never
// been posted" and "the account posts three times a day without anyone writing
// a schedule".
//
// The calendar is derived, never invented: slot times come from the cadence in
// data/x-content/queue.json, rotation comes from that file's quality block, and
// the order comes from the ledger's scores. Re-running with the same start date
// produces the same plan, so a batch that is already drafted keeps its dates.
// Surfaces already queued, already packed, or listed in
// data/announce-deferred.json are dropped: the plan covers what is left, and a
// surface listed in data/announce-priority.json takes the earliest slot its own
// tier owns rather than waiting for its score to come round.
//
//   node scripts/announce-plan.mjs                      # the next 30 slots
//   node scripts/announce-plan.mjs --batch 1            # one week's batch in full
//   node scripts/announce-plan.mjs --write              # plan.json + CALENDAR.md
//   node scripts/announce-plan.mjs --start 2026-10-01   # anchor the calendar
//   node scripts/announce-plan.mjs --hold-gated          # date only what the factory can pack alone
//   node scripts/announce-plan.mjs --json               # machine-readable
//
// Wired as `npm run announce:plan`. It never drafts, never writes into the
// queue, and never posts.

import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { MissingLedgerError, PLAN_DIR, planFor, writePlan } from '../api/_lib/announce/ledger.js';

const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');

const argv = process.argv.slice(2);
const flag = (name) => argv.includes(name);
const option = (name, fallback = null) => {
	const index = argv.indexOf(name);
	return index >= 0 && argv[index + 1] && !argv[index + 1].startsWith('--') ? argv[index + 1] : fallback;
};

const start = option('--start', new Date(Date.now() + 86_400_000).toISOString().slice(0, 10));

let plan;
try {
	plan = planFor(root, { start, holdGated: flag('--hold-gated') });
} catch (error) {
	if (error instanceof MissingLedgerError) {
		console.error(error.message);
		process.exit(1);
	}
	throw error;
}

function calendarMarkdown() {
	const batches = Math.ceil(plan.days / 7);
	const lines = [
		'# The announcement calendar',
		'',
		`Generated by \`npm run announce:plan -- --write\` on ${plan.generatedAt.slice(0, 10)} from \`data/announcements.json\`. The same ledger and the same start date always produce this same calendar, so it can be regenerated rather than maintained.`,
		'',
		`**${plan.totals.slots} surfaces that have never been announced**, ${plan.perDay} a day at ${plan.times.join(', ')} UTC, starting ${plan.start}: ${plan.days} days of posting, ${batches} weekly batches. ${plan.totals.gated} of them capture media from a surface that renders live third-party market data, so those frames need owner approval before they can be committed.`,
		'',
		`Tier mix: ${Object.entries(plan.totals.byTier).map(([tier, count]) => `T${tier} ${count}`).join(', ')}. Each slot is owned by one tier, and a surface is planned into the slot its own tier owns, so the flagship slot gets flagship material and a package announcement takes the proof-of-work slot.`,
		`Lane mix: ${Object.entries(plan.totals.byLane).map(([lane, count]) => `${lane} ${count}`).join(', ')}.`,
		`Pattern mix: ${Object.entries(plan.totals.byPattern).map(([pattern, count]) => `${pattern} ${count}`).join(', ')}.`,
		'',
		'Slot times, lane rotation and pattern rotation all come from `data/x-content/queue.json`, which is the same file the publisher obeys, so nothing here can promise a slot the scheduler would refuse.',
		'',
		'Each row becomes a full announcement pack with one command:',
		'',
		'```bash',
		'npm run announce:kit -- --batch 1        # brief, draft, pack, media recipe, queue item',
		'```',
		'',
	];
	const pins = plan.slots.filter((slot) => slot.pinned);
	if (pins.length) {
		lines.push(
			`## Asked for next (${pins.length})`,
			'',
			'Listed in `data/announce-priority.json`, so each one enters the sequencer ahead of the backlog and takes the earliest slot its own tier owns. The pin buys position only: tier, lane rotation and shape rotation are unchanged, and nothing here skips review or approval.',
			'',
			'| Surface | Slot (UTC) | Why |',
			'|---|---|---|',
		);
		for (const slot of pins) lines.push(`| \`${slot.key}\` | ${slot.notBefore.slice(0, 16).replace('T', ' ')} | ${slot.pinned} |`);
		lines.push('');
	}
	if (plan.held?.length) {
		lines.push(
			`## Held for owner approval (${plan.held.length})`,
			'',
			'Each of these captures its frame from a surface that renders live third-party market data, so committing that frame is the operating rules\' coin gate rather than a normal capture. They are out of the dated calendar on purpose: dating them would promise slots the factory cannot fill on its own and push everything it can produce weeks later. Clearing a frame moves that surface back into the next plan.',
			'',
			'| Surface | Tier | Lane | Score |',
			'|---|---|---|---|',
		);
		for (const row of plan.held) lines.push(`| \`${row.key}\` | T${row.tier} | ${row.lane} | ${row.score} |`);
		lines.push('');
	}
	if (plan.deferred?.length) {
		lines.push('## Deferred', '', '| Surface | Why |', '|---|---|');
		for (const row of plan.deferred) lines.push(`| \`${row.key}\` | ${row.why} |`);
		lines.push('');
	}
	let batch = 0;
	for (const slot of plan.slots) {
		if (slot.batch !== batch) {
			batch = slot.batch;
			const rows = plan.slots.filter((row) => row.batch === batch);
			lines.push('', `## Batch ${batch}: ${rows[0].notBefore.slice(0, 10)} to ${rows[rows.length - 1].notBefore.slice(0, 10)}`, '');
			lines.push('| Slot (UTC) | Tier | Surface | Lane | Pattern | Shot | Gate |');
			lines.push('|---|---|---|---|---|---|---|');
		}
		lines.push(
			`| ${slot.notBefore.slice(0, 16).replace('T', ' ')} | T${slot.tier}${slot.tier === slot.slotTier ? '' : ` (in the T${slot.slotTier} slot)`} | \`${slot.key}\`${slot.pinned ? ' (pinned)' : ''} | ${slot.lane} | ${slot.pattern} | \`${slot.shot}\`${slot.motion ? ' (motion)' : ''} | ${slot.mediaGate || ''} |`,
		);
	}
	return `${lines.join('\n')}\n`;
}

if (flag('--write')) {
	writePlan(root, plan, calendarMarkdown());
	console.error(`wrote ${PLAN_DIR}/plan.json and ${PLAN_DIR}/CALENDAR.md`);
}

if (flag('--json')) {
	console.log(JSON.stringify(plan, null, 2));
	process.exit(0);
}

const only = option('--batch') ? Number(option('--batch')) : null;
const rows = only ? plan.slots.filter((slot) => slot.batch === only) : plan.slots.slice(0, Number(option('--top', 30)));

console.log(
	`${plan.totals.slots} unannounced surfaces, ${plan.perDay}/day at ${plan.times.join(', ')} UTC from ${plan.start}: ${plan.days} days, ${Math.ceil(plan.days / 7)} batches.`,
);
console.log(
	`tiers ${Object.entries(plan.totals.byTier).map(([tier, count]) => `T${tier}:${count}`).join(' ')}  lanes ${Object.entries(plan.totals.byLane).map(([lane, count]) => `${lane}:${count}`).join(' ')}  patterns ${Object.entries(plan.totals.byPattern).map(([pattern, count]) => `${pattern}:${count}`).join(' ')}  owner-gated media ${plan.totals.gated}${plan.totals.held ? ` (${plan.totals.held} held out of the calendar)` : ''}  pinned ${plan.totals.pinned || 0}  deferred ${plan.deferred?.length || 0}\n`,
);
console.log(`${'when'.padEnd(17)} ${'tier'.padEnd(5)} ${'surface'.padEnd(32)} ${'lane'.padEnd(10)} ${'pattern'.padEnd(11)} gate`);
for (const slot of rows) {
	console.log(
		`${slot.notBefore.slice(0, 16).replace('T', ' ').padEnd(17)} ${`T${slot.tier}`.padEnd(5)} ${slot.key.padEnd(32)} ${slot.lane.padEnd(10)} ${slot.pattern.padEnd(11)} ${slot.mediaGate || (slot.pinned ? 'pinned' : '')}`,
	);
}
if (!only) console.log(`\n... ${Math.max(0, plan.totals.slots - rows.length)} more. Full calendar: npm run announce:plan -- --write`);