@ogygia/cli
Keys and stubs
The two federation commands. `ogygia keys` makes the Ed25519 key pair an app signs its calls with, and `ogygia fragments` turns a peer's widget catalog into TypeScript and fails CI when the catalog drifts.
On this page
Apps that share fragments with @ogygia/federation need two things from outside the build. Each app needs a key pair to sign its calls, and an app that places another team’s widgets wants their names and props as types, so a renamed widget fails its build instead of its pages. ogygia keys and ogygia fragments make both.
npx ogygia keys shell >> keys.env
npx ogygia fragments https://dash.internal --out src/lib/dash-widgets.tsKey pairs
npx ogygia keys <name> makes one Ed25519 key pair and prints it as two export lines, in the formats federate() reads:
<NAME>_SIGNING_KEYis the private key, base64 PKCS#8 DER. It stays with this app, asfederate({ key }), in your secret store.<NAME>_PUBLIC_KEYis the public key, base64 SPKI DER. Every app that hears from this one lists it aspeers.<name>.key.
The two lines go to standard output and the guidance to standard error, so npx ogygia keys shell >> keys.env captures only the keys. The command never writes a file. Any Ed25519 pair in those two formats works as well, such as one your secret manager makes. Keys and signing covers what a signature covers, and rotating a key.
Naming
The variable names come from name. It’s upper-cased, each run of characters other than A–Z and 0–9 becomes one _, and a _ at either end is dropped. With no name, or a name that leaves nothing, the prefix is OGYGIA.
| Name | Variables |
|---|---|
shell | SHELL_SIGNING_KEY, SHELL_PUBLIC_KEY |
shell-2026 q4 | SHELL_2026_Q4_SIGNING_KEY, SHELL_2026_Q4_PUBLIC_KEY |
__cms__ | CMS_SIGNING_KEY, CMS_PUBLIC_KEY |
(none), --- | OGYGIA_SIGNING_KEY, OGYGIA_PUBLIC_KEY |
An argument that starts with - isn’t a name, so npx ogygia keys --help makes an OGYGIA pair too.
npx ogygia keys shell
# export SHELL_SIGNING_KEY=MC4CAQAwBQYDK2Vw…
# export SHELL_PUBLIC_KEY=MCowBQYDK2VwAyEA…Widget stubs
npx ogygia fragments <origin> reads a peer’s widget catalog at <origin>/og/fragment/__catalog. The catalog is unsigned, so the command needs no key. It turns the catalog into a TypeScript stub, printed to standard output, or written to a file with --out:
WidgetName is the union of the widget names, never for an empty catalog. WIDGET_NAMES is the same list as a value. WidgetProps maps each name to its props: each prop the widget declares is an optional string, and a widget that declares none takes Record<string, string>. Typed stubs shows a helper that checks every call against them.
The command gives up after 10 seconds without an answer. It exits with 1, saying why, when the catalog answers an error status, or JSON without a names array of strings, or no JSON at all.
Drift checks
--check <file> makes the stub from the live catalog and compares it with the one you committed, byte for byte. It exits with 0 when they match and with 1 when they differ, printing the live names and the command that regenerates the file. A file that doesn’t exist is an error too. Run it in the CI of the app that uses the widgets, so a widget renamed or removed on the other team fails your build:
The first line of the stub names the origin, and it’s part of the comparison. Write the origin exactly as you did when you made the stub: https://dash.internal/, with a trailing slash, reports drift against a stub made from https://dash.internal (#2311, item 7).
npx ogygia fragments https://dash.internal --out src/lib/dash-widgets.ts// generated by `npx ogygia fragments https://dash.internal` — do not edit
export type WidgetName = 'clock' | 'kpis';
export const WIDGET_NAMES = ['clock', 'kpis'] as const;
export interface WidgetProps {
clock: Record<string, string>;
kpis: { org?: string };
}npx ogygia fragments https://dash.internal --check src/lib/dash-widgets.tsPeer checks
The MCP server’s ogygia_fragment tool checks a peer from an agent: it sends an unsigned request to the peer’s page endpoint, /og/fragment/page, where a 401 means it checks signatures and a 200 means it’s open to anyone, and it lists the catalog’s widgets with their props.