Using Pinakes as a library
The commands are also exported as functions, for editor plugins, sites, and build scripts. They return what the CLI would print instead of printing it, and they never exit the process.
import { openUniverse, lint, compile, context, proseCheck, renderContextMarkdown } from '@bbthorson/pinakes';
const universe = openUniverse('./my-universe'); // reads pinakes.yaml and the registry once
const { ok, diagnostics } = lint(universe); // ok === false exactly when `pinakes lint` exits 1const { records } = compile(universe); // in memory; nothing writtencompile(universe, { write: true }); // what `pinakes compile` does, pruning included
const { bundle, errors } = context(universe, 'Jasper', '2026-10-11');if (bundle) console.log(renderContextMarkdown(bundle));
const { tells } = proseCheck(universe, { report: 'tells' });Every function also takes a root path in place of an opened universe.
-
compiledoes not write by default. This is the one place the library differs from the CLI. Writing also prunes stale files frompaths.output, and a caller that only wanted records shouldn’t find its directory changed. -
Bad input throws, findings are returned. A missing or invalid
pinakes.yamlthrows, and so does aproseCheckwhosestoryfilter matches nothing. Continuity problems come back asdiagnostics, and a character or date thatcontextcannot use comes back inerrors. -
The affect helpers are exported for tools that read affect records.
buildAffectVocabulary(config.affect.labels)gives the resolved label vocabulary,resolveAffectLabellooks a label up in it (exactly, orundefined),parseAffectDeclarationreads anaffect:value, andclassifyAttractorBasin,getBehavioralDirectivesandformatAffectPromptInjectionare what the compiler andcontextuse.affectStateAt(universe, character, asOf)returns the statecontextprints, with its anchor, events and mode (declared,replayedorheld). See Affect.
The package is ESM-only and ships TypeScript types.