Compiling

Selected databaseMongoDB

Run the compiler to turn your models and prompts into runnable code. You must run it after adding or changing models or queries. When using Mask Databases, run mask-sync-fetch to get the latest, then node mask.compile.cjs when you have new prompts, and mask-sync-push to share your changes.

Compile

  • Run from your project root
  • Turns your models and prompts into runnable code
node mask.compile.cjs

Requirements

You need project-root mask.compile.cjs that calls runWithMaskConfig with overrideConfig including database, dbModulePath, and syncApiKey (from @local/mask/compiler). The compiler does not run without them. See Configuration.

When to run

  • After adding or changing any MaskModels.define(...) or MaskDatabase.prompt(...) in your source (or after changing registery inside overrideConfig in mask.compile.cjs).
  • After cloning the repo — run mask-sync-fetch to get the latest from Mask Databases, then node mask.compile.cjs if you have new or changed prompts.
  • When deploying — run mask-sync-fetch so production has the latest queries; run node mask.compile.cjs only if your build includes new prompts.

Sync and compile

When syncApiKey is set: run mask-sync-fetch to get the latest from the server, node mask.compile.cjs when you add or change prompts, and mask-sync-push to share your changes. See Sync for the full workflow.

If a prompt fails to compile

Fix or remove the prompt in your code then run node mask.compile.cjs again. If you want it gone everywhere: delete it from your project in the Mask Databases dashboard. If it hasn’t been pushed yet (no mask-sync-push for this prompt), you can remove it locally with mask-delete (see Deleting prompts), then re-run node mask.compile.cjs.