#!/usr/bin/env node // Private on-demand channel catalogue. No semantic guessing or execution authority. import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..'); const read = p => JSON.parse(fs.readFileSync(path.join(root, p), 'utf8')); const context = read('routing/persona-channel-context-map.json'); const registrations = read('routing/fifth-domain-number-registry.json').registrations; const channels = context.channels.map(c => { const profile = read(c.profile), registered = registrations.find(r => r.id === c.id); if (!registered || profile.channel_id !== c.id || profile.world_path !== registered.world_path) throw Error('CHANNEL_REGISTRATION_MISMATCH'); return { ...c, world_path: registered.world_path }; }); const [action = 'list', id] = process.argv.slice(2); if (!['list', 'show'].includes(action)) throw Error('USAGE: list | show '); const selected = action === 'show' ? channels.find(c => c.id === id) : null; if (action === 'show' && !selected) throw Error('UNKNOWN_CHANNEL'); console.log(JSON.stringify({ schema: context.schema, map_id: context.map_id, interpretation_owner: context.interpretation_owner, authority_granted: false, channels: selected ? [selected] : channels }, null, 2));