Appearance
Modules
A module is a pure algorithm you import and call. Unlike snaptrude.*, which is an asynchronous conversation with the running editor, a module is imported, synchronous, deterministic and never touches the scene: it takes plain data and returns plain data, and the caller does every read and every write around it.
Three doors
| Door | How you reach it |
|---|---|
| A plugin worker | import { … } from "@snaptrude/plugin-toolkit/<export>" |
The design agent's run_worker sandbox | modules.<group>.<name>.<fn>(…), already in scope |
| Node, a test, a script | the same npm package, no host needed |
The unit rule
Every module input carries unit: "mm" | "cm" | "m" | "ft" | "in". Every length in that call is read and written in it — 30 stays 30 — and the output echoes the unit. Angles are degrees; areas are the unit squared. The modules' own defaults and tolerances are defined in millimetres and scaled to the unit, so they mean the same thing everywhere. Pass the project's unit and never convert a value yourself.
In scope in a worker body
The design agent's run_worker body sees three objects, all documented here:
| Object | What it is |
|---|---|
modules.<group>.<name> | the pure modules below, synchronous |
inputs.last(module) / inputs.at(id) | the input of an earlier traced module call, byte-identical — run.inputs |
kept.<name> | values an earlier body returned under keep: {…} — run.inputs |
Build a module input once per chat; every later body is { ...inputs.last(m), field: value }.
Modules
| Module | Import | What it does |
|---|---|---|
pack.bubbleLayout | @snaptrude/plugin-toolkit/pack-bubble-layout | Arrange sized bubbles so that wished-for neighbours end up near each other and nothing overlaps. |
pack.corridorBand | @snaptrude/plugin-toolkit/pack-corridor-band | Reserve a strip along a centreline and carve it out of the regions you are about to pack. |
pack.corridorRuns | @snaptrude/plugin-toolkit/pack-corridor-runs | Lay typed cells along corridor paths. |
pack.footprintPlacement | @snaptrude/plugin-toolkit/pack-footprint-placement | Seat footprints inside a boundary. |
pack.linearArray | @snaptrude/plugin-toolkit/pack-linear-array | Fit items of known width along aligned segments. |
pack.rooms | @snaptrude/plugin-toolkit/pack-rooms | Subdivide a boundary into one cell per room, areas proportional to targets, and return N ranked candidates. |
geom.circlePacking | @snaptrude/plugin-toolkit/geom-circle-packing | Circle packing primitives: keep a set of plan circles from overlapping, and keep them inside a ring. |
geom.polygonBoolean | @snaptrude/plugin-toolkit/geom-polygon-boolean | Plan-polygon booleans and offsetting: set operations on regions with holes, stroking a centreline into a band, and the per-edge mitre inset a setback is. |
geom.polygon | @snaptrude/plugin-toolkit/geom-polygon | The plan-polygon primitives every pack module shares: area and winding, centroid, bounding boxes, containment, distance, segment and ring intersection, ring simplicity, convex hull, minimum-width strip (OBB), shared-edge length, transforms, convex-window clipping, SAT separation and hole bridging. |
geom.polylineFrame | @snaptrude/plugin-toolkit/geom-polyline-frame | Arc-length frame along a plan polyline. |
run.inputs | @snaptrude/plugin-toolkit/run-inputs | What a worker body can carry over from earlier bodies. |