okonomi / opm

A product that builds itself

A .opm file is a parametric product: a manifest saying what it builds and what it needs to know, and a program that builds it. Hand it a width and it hands back meshes. No build service, no round trip, no token.

It is a zip with four members, and the program inside is Lua run in a sandbox with no clock, no random source and no way out. The same file and the same inputs produce the same bytes on every host that reads it — which is what lets a caller cache by content and a catalogue store a key.

Reading one

import { fetchOpm, toBuildResult } from '@okonomi-gmbh/opm-loader'

const opm = await fetchOpm('/programs/window.opm', { wasmUri })
const built = toBuildResult(opm.build('window_casement', { width: 900, height: 1400 }))

for (const part of built.parts) {
  part.name       // the movable node it belongs to
  part.material   // the slot to dress it in
  part.positions  // metres
}

The loader is on npm, MIT, and depends on nothing but a Lua VM. It is not the only way to read a file — the format is specified here precisely so that it need not be.

What this site is

Static. Everything on it is generated from the sources it describes and served with no computation at all, which is why it can outlive any particular service that speaks the format. The contracts are served at the same paths a generator serves them on, with the same bytes, so a consumer can point at either.