Plugins
DownDraft has a runtime plugin system for user-authored extensions and mods, distinct from the compile-time module system. Plugins are discovered under <app>/plugins/*/, described by a plugin.json or mod.json manifest, and loaded by a per-thread PluginHost (core/src/plugin).
Formats
Section titled “Formats”|| Format | Description |
|---|---|
|| worker-js | JavaScript plugin running in a dedicated Web Worker |
|| wasm | WASM module — always runs in its own worker for crash isolation |
|| quickjs | Script evaluated in a QuickJS VM (legacy plugin.json compat, instruction-budgeted) |
|| asset | Declarative content pack — no code; assets/maps/physics/shader extensions only |
Isolation and security model
Section titled “Isolation and security model”Only install plugins you trust — the isolation tiers differ substantially:
wasmandquickjsrun inside their respective VM/interpreter with no ambient host capabilities beyond the granted permissions — these are hard isolation boundaries.worker-jsis not a security sandbox. The plugin runs as a worker thread in the host JS runtime (Bun/Node/Deno). The engine strips or traps dangerous globals on a best-effort basis and gates engine APIs behind the manifest permissions, but plugin code can stillimportruntime builtins (node:fs, FFI, network) unless the host runtime itself is launched with restrictions (e.g. Deno--deny-*flags). Treatworker-jsplugins like any other dependency: they run with the privileges of the app process.- Remote workshop packs fetched via
BlobStoreare content pulled over the network — pin trusted stores and treat untrusted remote packs as a supply-chain risk, especially when they carryworker-jslogic.
Capability tiers and threads
Section titled “Capability tiers and threads”Each manifest declares a capability tier (data / script / native) and a target thread (sim / renderer / own-worker). The tier bounds which permissions a plugin may request — ecs, gpu, physics, assets, and similar — and the host intersects the request against the tier’s allowlist and the app’s allowlist before loading. WASM plugins are always forced to own-worker.
- sim — inside the app’s sim worker (ECS system/component registration)
- renderer — in-process on the main thread (render passes, UI)
- own-worker — a dedicated Web Worker spawned per plugin
mod.json (scaffolded via draft mod) is the pack-style manifest: a logic extension plus declarative extensions (assets, maps, physics, shaders). plugin.json is the legacy single-format shape; both are normalized to the same internal model.
Manifest
Section titled “Manifest”// <app>/plugins/my-plugin/plugin.json{ "name": "My Plugin", "version": "1.0.0", "format": "worker-js", "tier": "script", "thread": "sim", "entry": "index.js", "permissions": ["ecs"], "requires": ["app:weather/state"], "dependencies": ["other-plugin@^1.0"]}The PluginHost validates the manifest, resolves permissions, computes a topological load order from dependencies, then invokes the format-specific loader with a tiered PluginContext facade.
draft plugin list # discovered plugins/mods in apps/*/plugins/draft plugin new my-plugin --app=my-app # scaffold plugin.json (default: worker-js)draft plugin new my-plugin --app=my-app --format=wasmdraft mod new my-mod --app=my-app # scaffold mod.json (default: asset)See the CLI reference for the full flag list.