Skip to main content
The @ex-machina/facets package exports its core functions for programmatic use. Everything the CLI can do is available as a library.

Installation

bun add @ex-machina/facets

Import

import {
  // Registry
  loadManifest,
  FacetManifestSchema,
  FacetsYamlSchema,
  FacetsLockSchema,
  readFacetsYaml,
  writeFacetsYaml,
  readFacetsLock,
  writeFacetsLock,

  // Discovery
  listFacets,
  cacheFacet,
  updateFacet,
  updateAllFacets,
  clearCache,

  // Installation
  installFacet,
  uninstallFacet,
} from '@ex-machina/facets'

Subsystems

The library is organized into three subsystems:
SubsystemPurposeKey exports
RegistryLoad manifests, read/write config files, validate schemasloadManifest, FacetManifestSchema, readFacetsYaml
DiscoveryList, cache, update, and clear facetslistFacets, cacheFacet, updateFacet, clearCache
InstallationInstall and uninstall facet resourcesinstallFacet, uninstallFacet

Result pattern

Most functions return discriminated union result types instead of throwing exceptions:
const result = await installFacet('my-facet', projectRoot)
if (result.success) {
  console.log(`Installed ${result.facet}`, result.resources)
} else {
  console.error(`Failed: ${result.reason}`)
}
This makes error handling explicit and type-safe.