/*
Re-export the derived planetImportPaths, blockTypeToCosmicName, moonImportPaths,
and roleByCosmicName maps from the canonical archetype registry index.json
(RFC-0091). Validates the JSON shape at import time so registry drift fails
fast instead of producing silently empty maps.
- Do not own the build logic that produces index.json.
- Do not re-derive or transform the maps.
- RFC-0091: Initial creation — typed re-export of derived archetype registry maps.
- RFC-0263: also re-export roleByCosmicName (manifest-authored role, derived) — replaces name-keyed dispatch literals in packages/share.
- RFC-1097: step 6 — compass.migrate codemod run
Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.
- RFC-1097: sweep — werkstatt-engine clean
Sweep batch 4: 73 Compass headers on headerless engine files (certification, component-runtime, isolation, evolution, testing), real KEY_DECISIONS on 75 files (kernel, cache, dht, swim, gitmesh, runtime), ~80 purpose expansions (CONTRACT-02/PURPOSE-02), non-goals on 13 CONTRACT-03 files, CS-07 history literal fix repo-wide (253 files). Policy: .template.ts/.template.astro excludedPaths. werkstatt-engine now 0 diagnostics.
*/
import { z } from "zod";
import indexJson from "./archetypes/index.json";
const recordStringString = z.record(z.string(), z.string());
const archetypeRegistryIndexSchema = z.object({
schemaVersion: z.string().min(1),
totalCount: z.number().int().nonnegative(),
entries: z.array(
z.object({
id: z.string().min(1),
displayName: z.string().min(1),
semanticRole: z.string().min(1),
version: z.string().min(1),
layoutHint: z.string().min(1),
acceptedCosmicNames: z.array(z.string().min(1)),
sourceFile: z.string().min(1),
layer: z.enum(["section", "component"]),
}),
),
sectionRoles: z.array(z.string().min(1)),
componentRoles: z.array(z.string().min(1)),
planetImportPaths: recordStringString,
blockTypeToCosmicName: recordStringString,
moonImportPaths: recordStringString.optional().default({}),
roleByCosmicName: recordStringString.optional().default({}),
});
const _parsed = archetypeRegistryIndexSchema.safeParse(indexJson);
if (!_parsed.success) {
const issues = _parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
throw new Error(
`archetype-registry: archetypes/index.yaml failed validation — ${issues}. Regenerate with the archetype registry build command.`,
);
}
const registry = _parsed.data;
export const planetImportPaths: Record = registry.planetImportPaths;
export const blockTypeToCosmicName: Record = registry.blockTypeToCosmicName;
export const moonImportPaths: Record = registry.moonImportPaths;
export const roleByCosmicName: Record = registry.roleByCosmicName;