Log inGet started
·
agentskill · drop-in viewer
asset⌬ agentskillagentSkillprimary: skill.yaml·originates fromworld 07158574-5…

debugging.agentSkill

Finding out **when** something went wrong in a running world.

by◐lumi·posted 1mo ago
What it does

debugging

Finding out when something went wrong in a running world.

The job this skill covers is not "what is the current value" — the current value is downstream of the moment that matters. It is: attach an instrument to running code, keep working, and be told the instant the thing happens.

It exists because the reflex it replaces does not work. Running something, waiting, and taking a capture aims at a moment you cannot see: seconds pass between the call and the frame, and adding a wait only moves the guess. Polling is the same guess with more steps.

Covers: probing a function call, a source line, or a value; using a condition to name the moment rather than every step toward it; reading the state a value was taken in before trusting the value; and cancelling what you armed.

The trap it spends the most words on is the expensive one — a right value read in the wrong world, where the match already ended or the scene already swapped, nothing announced it, and every number afterwards means something else.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

This asset doesn't declare a schema or structured payload.

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

Showing up to 3 levels deep. Open a part to see what it holds further down.

97+items
·
assettype · born here
❒asset
# agentSkill A skill packages what an agent needs to do one job well: the instructions, the assets and toolboxes the job runs through, and — for jobs with distinct branches — subskills that go deeper. Skills advertise themselves. Every registered skill's name and one-line description rides the agent's tool responses, so an agent discovers what this world knows how to do without being told to look. Invoking one returns the instructions plus the exact identities and tool names the job needs. ## Shape ``` <name>.agentSkill/ skill.yaml # the manifest: description, when, checks, dependencies, order instructions.md # the prose an agent receives on invoke README.md # what this skill is, for a human reading the tree .metadata # tags <sub>.agentSkill/ # optional subskills, reachable as <name>/<sub> ``` ## The manifest ```yaml $schema: zero/agent-skill/v1 description: Making a character a person can actually play. when: > Reach for this when the player should look like something else, or when you are about to build a camera and a body and wire them together by hand. checks: - check: Holding a movement key in play moves the body across the ground. observe: Read its position before and after holding the key; the numbers differ. - check: The body animates while it moves. observe: A time-sampled collage from a camera outside the player, while the key is held. dependencies: - "@builtin::tools.scene" - "@builtin::tools.scene.player" - "@builtin::components.PlayerPrototype" - "@builtin::docs.core.multiplayer" order: [spawn-points, camera-rig] ``` `description` is the line the roster carries, and the whole basis on which a skill is chosen. Name the job the skill makes a reader competent at, in the outcome they are after — "getting a scene's player and view right", "making content the engine will load". A reader scanning the roster is matching it against the job in front of them, so the closer it reads to their own sentence about that job, the sooner they open it. `when` is the longer trigger — the situations that should send a reader here, in the words they would use for their own task. `checks` is what the reader is answerable for at the end, and it leads the rendered skill, ahead of the procedure. Each entry pairs a **condition that must hold** with **where it is seen**, and both halves are required — a condition alone is satisfied by any glance, and the wrong vantage is how a job passes while every one of its faults sits outside the frame. Write them as observations someone else could repeat and disagree with: a number that changed, a thing visible in a named shot, a count that came back as one. A skill publishes only once it carries at least one. `stages` models a skill whose passes run in order, when the order is load-bearing. Each stage is `{ name, detail?, checks? }`, and a check that sits in a stage is answered after that pass has run — which is the difference between a criterion that means something and one that misleads. A skill with no meaningful order leaves `stages` out and lists its checks flat; a skill that has one may do both, and the flat checks then read as the final gate. `verdicts` names the fixed set of outcomes a reader reports — at the end of each stage when the skill has stages, and once at the end when it does not. Each is `{ verdict, means }`: the word, and what reporting it asserts. Both halves are required for the reason both halves of a check are. A verdict is a check one level up, deciding a whole pass rather than one condition, and a bare `refine` is a label each reader fills in privately — so two runs report the same word about different states and nothing downstream can tell them apart. Saying what it means settles the boundary in the skill instead of in whoever happens to be reading it. A check marked `perRun: true` is one whose content is written for the job at hand: the manifest can say *keep a list of every feature this object must have and answer against it*, but not what is on that list, because that is per run. It renders with that instruction attached. ```yaml verdicts: - verdict: continue means: Every check in the stage held, and the next stage can build on it. - verdict: refine means: A check failed on something this stage can still fix. Run it again. - verdict: stop means: A check failed on something an earlier stage decided. Go back to it. stages: - name: blockout detail: Mass and proportion only. checks: - check: Every part on the identity list has a stand-in at roughly the right size. observe: A capture beside the reference, at the same angle. perRun: true - name: material checks: - check: Metal reads as metal and cloth as cloth. observe: The metallic and roughness passes, after the lighting stage has run. ``` `dependencies` is one flat list of asset **identities**: a toolbox, a single tool, a guide, a component, a module, another skill. Each entry is resolved when the skill is opened and reported with what it turned out to be, so a skill never declares "this one is a toolbox" — the asset says so, and the reader groups by that. Identities are what make a skill portable. They pin like any other reference, so installing a skill into another world brings the toolboxes and guides it runs through along with it. A bare name (`scene`) or a guide path (`core/multiplayer`) resolves to nothing and is refused before publish. A toolbox entry lists the tools it carries, and a tool entry carries its own signature, so the instructions never restate a call contract that can drift. An identity this world lacks is reported as missing rather than dropped. Write instructions that name the toolboxes and tools a job runs through, and leave the call form to the reader — an agent may be holding the MCP tool surface, the shell, or Luau, and the signatures are listed for it either way. ## Subskills A `<sub>.agentSkill/` folder nested inside a skill is a subskill. It has the same shape as its parent and is invoked as `parent/sub`. Subskills are reachable only through their parent: they are absent from the roster and from `skills.list`, and appear in the parent's invoke result. A skill can therefore carry a dozen narrow procedures while costing the roster one line. `order` in the manifest names the subskills that lead. Any subskill it omits still appears, sorted by name, after the ordered ones — so adding a subskill folder is the only step needed to publish it. ## Publishing one Make a skill and it is live: it joins the roster agents read and it opens by name from the moment it exists. Edit its description and that is the line agents see next. A skill lives anywhere under `/zero/source/`. `asset.create` hands you a valid one to fill in: ```luau asset.create("agentSkill", "waveSpawning", { folder = "skills" }) ``` A skill's scope — `builtin`, `library`, or `world` — comes from where it lives rather than from anything it declares, so a world's own skill always reads as the world's. ## Opening one ``` agent_skill {} -- the roster agent_skill { name = "scenes" } -- one skill's instructions + deps agent_skill { name = "scenes/player-setup" } -- a subskill ``` The same three through the toolbox — `skills.list`, `skills.invoke` — and from Luau via `tools.use("skills", "invoke", "scenes")`. `asset.inspect` on a skill ref returns the structured record all of them render. Skills authored in a world are the world's own, and are labelled as world content wherever they surface beside built-in ones. ## In the Inspector Skill: what the skill is for and when it applies, how many checks and verdicts it declares, its stages, a link to each asset it depends on (and a problem for each that does not resolve), its subskills, and **Open** for instructions.md.
▲ 0↑ born
·
guide · born here
❒asset
# troubleshooting guide Reference docs surfaced through `guides { path: "..." }` and `man core/troubleshooting`. The content lives in `guide.md`; this README is just the asset summary.
▲ 0↑ born
·
toolbox · born here
❒asset
# capture Render a screenshot of the scene from anywhere — an explicit position, a named camera station around an entity, a specific camera, or a mirror of the active viewport — and a grid of them in one image; or read back the frame the engine actually presented, exactly as the player saw it. The picture of the machine's own camera (a webcam, a phone camera) is `cameraInput`, covered by the `topics/camera-input` guide; this toolbox photographs the scene. Every source but `presented` and `window` (see [The presented frame](#the-presented-frame)) spawns an ephemeral offscreen camera, triggers one render, and returns the picture as an image value — returned from a tool, a probe or `execute`, it reaches you as a picture, with what the capture has to say about it (its size, the frame it is of, the cells of a grid) beside it. A PNG is written as well when you pass a `path`. The convenience wrappers render from a world-space position (with optional look-at), frame a target entity, mirror the active viewport camera including its layers, or render a specific camera by name from its exact authored pose and settings (`fromCamera`, with optional per-capture overrides that never touch the camera); they run as a background task that waits for the GPU readback and cleans up — which only works in play mode, since the task scheduler ticks there. The low-level oneshot spawns the camera, triggers one render, and returns the handles synchronously — the only path that works from edit mode, and the one the `capture` MCP tool is built on. A cleanup tool clears the capture output directory. ## Where a shot lands A capture given a `path` writes the PNG there and says where those bytes stand, beside the path it wrote: `durable` is true when the PNG is on the path it names and the next session reads it back, and false when the play shadow took it (live in this session and discarded on a guarded play-exit unless kept, with `survivesRestart` saying whether a restart keeps it and `playShadow` naming the routes that keep it) or when the path is in `/source/tmp/` scratch (gone when the engine stops or restarts, with a `warning` opening `SCRATCH`). Every capture carries it on the picture it returns as `durability`. Shooting gameplay means shooting in play, which is exactly when a `/source` destination is the shadow's, so this is the field that says whether a shot survives leaving play — `vfs.promotePlayShadow(path)` keeps it with play still running. ## The presented frame `source = "presented"` reads back the frame the engine presented to the player instead of rendering one. Nothing is drawn for it: it is the frame the viewport drew, copied out as it was finished, after the post chain, the upscale, the display transform, the content UI and every post-scene pass, at the size it was composed at. So it is the one capture whose temporal antialiasing, motion blur, camera motion, auto exposure and render scale are the real ones, and the source to verify any of them with. `source = "window"` is the whole presented surface (the window, the browser canvas or the headless framebuffer) with everything painted on the window: the editor's chrome and every window-level UI pass. Where no Scene panel shows the viewport, the two are the same image: the scene fills the window and the editor's chrome is painted over it, and each such frame says so in its `note` (a cell of a `presented` capture, a frame `renderer.presentedFrames` returns) for as long as that chrome is on the window. Show the Scene panel (the editor toolbox's `layout` tool) to read the game view alone. `frames = n` (1-32) takes n presented frames, one every `interval` frames (default 1: consecutive), at real gameplay speed, and lays them out as a grid in the order they were presented. Each cell states what its frame was drawn with: `frame` (the renderer's count, so consecutive frames carry consecutive numbers), `rasterWidth` / `rasterHeight` (the size the scene rasterized at), `compositeWidth` / `compositeHeight`, `renderScale` and `scaleMode`, `jitter` (the projection's sub-pixel offset in raster pixels), `exposure` (what the display transform multiplied the scene by) and `historyReset` (the viewport camera's first frame, a cut, or a hand-over to another camera). A single frame comes back at the size it was presented at; `width` / `height` resample it, or size the sheet a grid is laid into. A presented frame is drawn through the camera, layers, lens and chain that drew the screen, so the options that aim, light or shape a rendered frame (`camera`, `entity`, `position`, `viewpoint`, `fov`, `pass`, `renderLayers`, `postProcessing`, `environment`, `mode = "collage"` and the collage axes) are refused for it; aim the camera holding the viewport instead, or take an offscreen capture. A source that renders refuses `frames` and `interval` the same way, since they count presented frames. `deterministic` and `clearAir` hold the clock and the air for the whole engine, so they reach the presented frame too. A diagnostic buffer of the viewport itself, under its real camera motion and history, is read the same way: put the camera holding the viewport on that pass (the camera toolbox's `set` with `debugPass = "motion_vectors"`) and take `source = "presented"`. The viewport's velocity buffer is the frame's travel against the frame before it, so a turning camera reads in it, where an offscreen `pass = "motion_vectors"` holds the objects' own motion alone. The `motion_vectors` picture is a visualization: each channel is the square root of 100 times the stored displacement's size on its axis (R horizontal, G vertical, B the length), the sign is dropped, and R reads 255 from `width / 200` px of horizontal travel, G from `height / 200` px of vertical travel (raster pixels). The rendering guide's "What the `motion_vectors` picture encodes" states it in full. The same frames, with their pixels as `TextureCpuHandle`s, come from `renderer.presentedFrames({ scope = "viewport" | "window", frames, interval })`, and `velocity = true` adds the viewport's velocity buffer from each frame as numbers (`frame.velocity`, a `VelocityField`): each pixel's travel in pixels per frame, x right and y down, signed and unclamped, read with `field:at(x, y)`, `field:row(y)` and `field:region(rect)`. ## The feed Every capture publishes the frame it made to `@builtin::tools.capture.feed`, so a viewer can show the newest one without taking a shot of its own. `Feed.latest()` is that frame: a `src` an image widget draws (the render target's guid while the engine still holds it, the written path when the capture produced a file), with the size, the source and the pass beside it. `Feed.watch(fn)` calls `fn` as each new frame arrives. The editor's Capture panel is built on it, and the `watch` layout puts that panel under the scene. A viewer calls `Feed.shown()` to say it is drawing frames from the feed. From then on the feed holds the newest capture's render target so the picture stays up after the capture that made it is finished with it, and lets it go when a later frame replaces it; `Feed.shown(false)` stops. With nobody drawing, a capture's target is released the moment its capture is done, and nothing is held. ## Viewpoints A **viewpoint** names where the camera stands and which way is up in the image: `front`, `back`, `left`, `right`, `top`, `bottom`, `iso`. It replaces reverse-engineering a `{yaw, pitch}` pair, and names the seven stations that answer "is this built correctly". `basis` says which axes the name is measured against, and it is **required** alongside a viewpoint when a subject is being framed: - **`"local"`** — the subject's own axes. `front` is the side it faces however it is turned, and the frame is fitted to its own extents rather than to the world-axis box around them. - **`"world"`** — the world axes. `front` is whatever faces world +Z. For a crate turned 40 degrees those are different pictures, so the call says which one it wants. Framing a world position rather than an entity, both values mean the world axes and either is accepted. ## Passes `pass` names **what** the frame holds, by name. `"final"` is the lit picture; a built-in diagnostic pass (`albedo`, `normal`, `depth`, `motion_vectors`, …) replaces the shaded image with the buffer behind it; and any capture **view** a render feature has published (`renderer.captureView.list()` enumerates them) is selectable by its own name. A name that is neither is refused against the list of what is registered. The name carries two decisions: which channel the camera renders, and which render layers that channel is legible under. A diagnostic buffer is read flat, so the sky behind it and the post-process chain over it come off; a view that draws its own geometry declares the layers it needs and is rendered under them. Stating `renderLayers` answers that second question yourself, for the one call. `passes` spreads the same vocabulary across the cells of a collage, and each cell reports the layers it was read under. ## Projection `projection = "orthographic"` covers a fixed world-space height at every distance. Parallel edges stay parallel and two equal-size objects at different depths cover equal pixels, which is what makes it the projection to check a shape or compare sizes under — a perspective frame's convergence hides both. `orthoHeight` sets that height; omit it and it is fitted to what is being framed. Any camera can be orthographic, not only a capture: it is a field on the `Camera` component. A capture through a camera the scene holds (`fromCamera`, `viewport`, and `source = "camera"`, `"screen"` or the scene camera) takes that camera's `projection` and `orthoHeight` with the rest of its lens, and its lighting `environment` with an `isolated` camera's background and ambient; a `projection` or `orthoHeight` stated for the call stands over the camera's. ## Which entity a capture framed A capture names an entity, or a camera to render from, by its id or by its name. A name exactly one entity carries means that entity. A name several entities carry means none of them on its own, so the capture is refused, and the refusal says how many entities carry it and names each by name and id; pass the id of the one you mean. A player is drawn as its body, so a capture of a player identity (an entity carrying `UserIdentity`, named `user`) frames the body its `avatar` names. A player prototype is absent from the live scene while it plays, so its name reaches no entity there: a capture of that name is refused, and the refusal names each player spawned from the prototype, by its identity and its body, with their ids. Every cell of a capture aimed at an entity reports what it framed under `subjects`: one `{ id, name }` per subject, carrying `playerIdentity = { id, name }` when the picture is the body of the identity the capture named. ## Isolate Framing a subject fits the **frame** to it; it does not decide what is drawn in that frame. Everything else standing there is still rendered — and a scene's default player spawn sits at the world **origin**, which is exactly where a prop usually gets built, so a tight shot of a new prop at the origin can come back showing the player instead. `isolate = true` draws the subject without the other geometry. It changes exactly that — lighting, sky and post-process are untouched, so a final frame stays a final frame, and a flat read of the geometry is a `pass`. Excluded geometry still casts shadows onto the subject and still bounces light into it, the same as any render-layer exclusion. In a `setups` collage each cell shows the entity its own set-up frames alone, and a set-up can state `isolate` for its own cell; a set-up aimed from a position or a camera frames no entity and is refused when it is to be isolated. ## The tone the frame carries Every capture reports `luma` on its cell record: the tone of the pixels it just encoded, in code values on the 0-255 scale the image is delivered at. ``` luma = { pixels, min, max, mean, p1, p5, p50, p95, p99, span, spread, crushed, clipped } ``` `span` is `max - min` — the whole range, a single stray pixel included. `spread` is `p95 - p5` — the range the body of the picture occupies, which is the reading that answers whether a shot is legible. `crushed` and `clipped` are the shares of the picture sitting at code 0 and at code 255. A frame's mean cannot answer that question: half a picture at 40 and half at 200 carries the same mean as a flat field at 120, and only one of them has anything in it. A subject can be modelled, shaded, lit and drawn and still arrive inside a handful of code values, in which case the image looks like a wash and every other field here reports success. `spread` is the number that says so. The same reading is available anywhere pixels are: `cpu:tone()` on a `TextureCpuHandle` — from `renderer.texture.readback(rtHandle)` on a capture handle, from a render-to-texture camera's target, from a CPU canvas — and `cpu:histogram()` under it, the per-code-value counts for luminance and for each of the three channels, which every reading above is a sum over. `cpu:histogram(x, y, w, h)` counts one rectangle of the picture alone, so a reading per region of the frame — how much of each cell is dark, lit or a given colour — is one call per region. `cpu:flip(reference)` holds the picture against another of its size by NVIDIA FLIP, the comparison a golden is judged by; `@builtin::modules.postMetrics` carries it with the golden runner, the pixel metrics (banding, temporal variance, halo overshoot, ring energy, hue drift) and the scopes, each reading a presented frame or a capture result as it comes. ## The grade an offscreen frame carries A capture spawns its own camera and renders offscreen, and the post-process chain runs over that frame the way it runs over the viewport's — for a station, for an orbit around an entity, for a named camera, for a render-to-texture camera alike. Inside an effect, `engine.view_proj` / `engine.prev_view_proj` / `engine.inv_view_proj` are the camera THAT render was drawn from and `engine.resolution` is that target's own size, so a grade that reconstructs world space from scene depth reconstructs against the station and lens the capture asked for. That makes an offscreen capture an oracle for an authored look: it photographs a chosen station and lens without taking the on-screen camera away from whoever else is driving the scene, and moving that camera somewhere else does not move the frame this one returns. An offscreen render keeps no view history of its own, so `engine.prev_view_proj` there holds that same matrix rather than the frame before it, and a pass taking camera motion from the two reads none. On the viewport the pair is a frame apart, so a camera's motion (and the blur and temporal reconstruction built on it) is read from the presented frame: `source = "presented"`. A render feature's passes reach an offscreen render the same way, against the same camera — the `renderFeature` assetType README carries that half, including `@frame.camera`, its own per-target camera input. `render(ctx)` itself runs once a frame for the main viewport, so `ctx.viewport` is the window's size rather than the captured target's; a feature sizes its scratch with `screen = true` and lets the engine track the drawn target. `postProcessing = false` takes the chain off the frame a capture returns, and with it the film a render feature draws — the flare and grain, a short focus's bokeh, the shutter's smear. It is a `Camera` property rather than a render layer, so `renderLayers` does not reach it. A capture naming a diagnostic `pass` drops the chain by default, so the buffer comes back as the value it encodes. ## Collage `collage` renders a grid of frames into one image. What varies across its cells is what you pass — `setups` for a cell per whole camera set-up, `viewpoints` for a cell per view of one subject (or `"sides"` for all six), `passes` for a cell per render pass, `duration` for a cell per sample over time. A collage with no axis is refused rather than quietly sampling time. `setups` is the shot list: each entry is written the way a single capture is aimed (`source`, `camera`, `entity`/`entities`, `position`, `lookAt`, `rotation`, `distance`, `angle`, `margin`, `viewpoint`, `basis`, `projection`, `orthoHeight`, `fov`, `near`, `far`), plus `label` to name the shot on the result, and a field an entry leaves out comes from the collage's own options. `setups` and `viewpoints` are one axis — both say where the camera stands — so a request names one of them; either crosses with `passes` into a 2D grid, a row per station and a column per pass. The shot most of this exists for is one call: six sides of one object, each an orthographic elevation, nothing else in frame. Authoring the cameras themselves — creating, listing, aiming, framing, and setting their parameters — is the `camera` toolbox.
▲ 0↑ born
·
toolbox · born here
❒asset
# debug Surface recent problems, inspect entity component state, and control the ambient debug-visualization overlay. - **problems** — return the errors and warnings the engine has logged since your last call (contract violations, `awake`/`update` throws, auto-disabled components, unresolved requires, bridged renderer/asset errors). Advances a read-cursor, so repeated calls report only what is new. **When something you built does not behave, call this first.** - **inspect** — component state for every entity matching a target (id, name, glob, proxy, or an array): script components as serialized public data, native ECS components as field values, or both — selected by `include`, filterable by `types`. In the editor the overlay draws gizmos for the whole scene — mesh bounds, camera frustums, skeleton bones, physics colliders, icons for meshless entities (audio sources, cameras, lights), and mesh wireframes. It is ambient (no per-entity setup) and agent-driven: - **set** — show or hide a category (`bounds`, `frustum`, `bones`, `colliders`, `icons`, `wireframe`), or `all`. - **scope** — focus the overlay on specific entities (by name or id); call with nothing to clear the focus and draw for everything. - **playSession** — show the overlay in play mode for a temporary, never-saved session, so bones/colliders/bounds stay visible on a running, animating scene. - **state** — report which categories draw, the current scope, the play session, and the engine mode.
▲ 0↑ born
·
guide · born here
❒asset
# core/observing How to be told when something happens in a running world, instead of running something, waiting, and hoping the timing was right. Covers the `probe` toolbox: attaching an instrument to code that is already running, the three things you can watch (a function call, a line, a value), what a probe reports and why the text is required, and the case that costs the most time — the world reaching a state you did not put it in, where every value you read means something other than you assume. Read it when the question is "when did this happen" or "what was true at that instant". For "why does this look wrong" the guide is `core/troubleshooting`.
▲ 0↑ born
·
toolbox · born here
❒asset
# wld Manage the live world while you work — flip between edit and play, and compose additive scene layers. Flip into play mode — which snapshots the edit state, then starts scripts and physics — and back to edit, which restores that snapshot and stops scripts; query the current mode any time. Load a scene as an additive layer alongside the current one, unload it, or show and hide layers without losing their entities. List the worlds saved on disk, and read the current world state: name, mode, active layer, and available scenes. To list the loaded scene layers or the scenes available to load, use `scene.loadedLayers` and `scene.list`. Saving and loading scene snapshots is the `scene` toolbox (`scene.save` / `scene.load` / `scene.list`).
▲ 0↑ born
·
toolbox · born here
❒asset
# logs A toolbox. Its tools read what the engine logged. Everything the engine records lands in one in-memory ring — Rust log lines, bridged renderer and asset errors from third-party crates, Rust panics, and every `print` and `log.*` a script made. These tools read it back from inside the engine, on every platform — a browser has no host filesystem to reach for and no console to scroll. ## The tools - **search** — the one to reach for. Filters by severity, subsystem, substring or regex, the script or entity that logged a line, and a time window. Can return the lines around each match, or collapse a repeating message into a single row. - **tail** — the most recent lines of any level, oldest first. What is happening right now. - **errors** — recent errors and warnings, newest first. - **summary** — how many lines, of what severity, from which subsystems and entities, and which messages repeat. The shape of the noise before you go looking inside it. - **clear** — drops what is buffered. Lifetime counts survive. ## The ring as files The same ring is mounted read-only on the VFS — the engine's own filesystem, which is why these need no host disk behind them — and `cat` and `grep` work on them like any other file: | Path | What it holds | |------|---------------| | `/zero/runtime/logs/engine` | every level, most recent 500 lines | | `/zero/runtime/logs/errors` | the ERROR-and-above subset of the same | | `/zero/runtime/logs/script` | what scripts logged | | `/zero/runtime/logs/previous` | the previous session of this world: how it ended, then the last lines it wrote | The ring starts empty at every boot, so it cannot say why the engine before this one stopped. `previous` can: its first line names how the previous session of the world this engine booted on ended (a clean shutdown and its reason, an exit with no reason recorded, or no exit record at all because the process was killed or faulted), with the panic and the crash record that explain an ending that was not clean, and the lines that session wrote follow. Those lines are as the engine wrote them to its log file, each opening with its `[seconds.millis]` stamp, where the live `engine` and `errors` files open each line with its number in this session's ring. A boot whose previous session ended without a clean shutdown also says so in a notice and a WARN line. Each engine on the machine keeps its own record of each world, so an engine that comes back reads the session it ran last, whatever other engines on the same world did meanwhile. Neither surface is the right one — they answer different questions. A message you can already name is quicker to grep than to query. A question with a shape to it — this entity's lines, this severity in this window, what surrounded the failure, which message repeats and how often — is what the tools are for, and a file cannot answer it. The files also stop at 500 lines and include the record of your own tool calls, so grepping for a marker string can return the call that went looking for it; a query reaches the whole ring and leaves those out unless `include_mcp` asks for them. ## Finding out why something misbehaved The `problems` tool in the `debug` toolbox is the first call when something you built does not behave: it drains the errors and warnings you have not read yet, oldest first, so the root-cause failure reads ahead of the cascade it set off. This toolbox is the general view over the same ring — every level, searchable, countable, and filterable by origin and by caller. Reach for it when you need more than the unread problems: a specific message, a specific entity, a specific minute, one agent's failures on an engine several of them share, or the lines that led up to a failure. ## What a line carries | field | meaning | |---|---| | `seq` | monotonic, unique for the process lifetime | | `level` | `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR` | | `type` | subsystem — `RENDERER`, `SCRIPT`, `PHYSICS`, `UI`, … | | `message` | the line itself | | `timestamp` | epoch seconds | | `origin` | `local`, or `remote` for a line raised by content another session on this world authored | | `caller` | which caller's work raised it, as the key the caller answers by on the engine that raised it (`agent:<name>` while the caller holds a name, else `client:<session>` / `actor:<sub>`), on the lines a caller's work raised | | `script` | the script that logged it, when a script did | | `entity` | the entity that script was running on, when there was one | | `context` | present only on a line returned as context around another line's match | `script` and `entity` are why asking for one entity's output is a filter rather than a guess at what its messages look like. `caller` is the same move one axis over: one engine answers several agents at once and runs all of their content, so its log holds all of their failures. Pass `caller = "mine"` for your own lines, `"unowned"` for the engine's own, or a caller key spelled out for somebody else's. ## Reading incrementally **summary** reports a `cursor` — the highest sequence number the ring has assigned. Read it before an action and hand it back to **search** as `since` afterwards, and you see only what that action logged. `engine_cursor` is the same figure with your own tool traffic left out, so it stands still on an engine whose loop has stopped however many times you poll it. ## Your own tool traffic Each tool call is itself recorded, with `type` of `MCP`. A search leaves those out, because the call carrying the search is one of them and an unqualified search for a marker would otherwise return the search. `include_mcp` sees them alongside everything else; a `type` of `MCP` sees only them.
▲ 0↑ born
·
toolbox · born here
❒asset
# probe Get told when something happens in the running world, without editing anything. A probe attaches to code that is already running. You say what to watch, what condition matters, and what to compute at that instant; you get a notice on a later tool call saying it happened and carrying the value. You never wait, you never guess a delay, and there is nothing to remember to undo — no source file is touched, nothing reloads, and cancelling removes every trace. This is what to reach for instead of adding a log line to a component and reloading it, and instead of running a script, waiting, and capturing in the hope the timing was right. ## The three things you can watch | Tool | Fires when | |---|---| | `onCall` | A named function runs. Sees its arguments and what it returned. | | `onLine` | Execution reaches a file and a line. Sees that frame's locals. | | `onChange` | A value becomes different from what it was. | And three to manage them: `list` (what is armed and what it has seen), `hits` (the detail behind the notices), `cancel` (take one off, or all). ## What a probe tells you Three parts, every time: 1. **Where it came from** — which probe, and what it is attached to. Written by the probe, so several armed at once never blur together. 2. **What it is about** — your `notice` text. Required. A value with no idea what it is about is not a report. 3. **What your body returned** — a string becomes the line, a table becomes the values beside it. ```lua probe.onCall("modules.combat.applyDamage", { notice = "a hit killed something", when = "ret.killed", run = "return ret.target .. ' at ' .. tostring(ret.hp) .. 'hp'", }) ``` That reads back as its source, then "a hit killed something", then `goblin at -40hp`. Repeat hits collapse into one line with a count and the values that differed, which is why the text stays fixed and the value varies. ## Seeing the moment Pass `capture` to have a hit bring back a picture as well: Luau, read against the hit's context the way `run` is, that aims a capture tool at what the hit is about and returns the picture. ```lua probe.onCall("modules.combat.applyDamage", { notice = "a hit killed something", when = "ret.killed", capture = "return tools.use('capture', 'fromEntity', { entity = args[1], angle = { 30, 20 } })", freeze = true, }) ``` A capture waits for the renderer, so it runs as the hit is recorded rather than inside the code the probe is attached to; the hit's notice goes out once the picture is back and carries it under `shot`, delivered to you as a picture beside the line, and the picture says which frame it is of. `probe.hits` holds the same picture on the hit's row. On `onCall`, `freeze` also stops the world at the hit. A capture that fails still reports the hit, with `captureError` saying why. ## Picking a target - A function on a required module — `onCall`, by `module.field`. - A local inside a module, or a helper a component keeps to itself — `onLine`, by chunk and line. This is the one that reaches code no name can address. - A value: a component field, a light's intensity, a position — `onChange`. Pair any of them with `when` to name the moment rather than every step toward it. `when = "value >= 5"` fires the first time it reaches five. A line probe's `when` is evaluated inside the frame it stopped in, so it reads that frame's variables by their own names and with their own types — `doubled >= 6`. The other two read the context: `ret.killed`, `value >= 5`. ## What it costs - `onCall` costs one extra call on the wrapped function, and nothing anywhere else. - `onLine` costs nothing on an unarmed line, but a breakpoint drops the enclosing function out of native code until that script reloads. On a function that runs every frame that is real, so cancel it when done. - `onChange` reads its expression once per frame while armed, which is also its limit: something that changes and changes back within a frame is not a change it can see. Probe the code that sets it with `onLine` instead. Every probe carries a hit limit and a cooldown, both defaulted low. A probe that reaches its limit disarms and says so; hits the cooldown held back are counted and shown by `list`, so a busy probe never leaves you believing it fired only as often as it spoke. ## Where it stops Nothing about a probe is written to disk and nothing survives the engine stopping. A body runs inside a protected call and must not yield; three errors in a row disarm the probe and report why. Globals are sealed read-only, so `onCall` cannot wrap one. A component's own method is not a field on a module either — reach it with `onLine`.
▲ 0↑ born
·
assettype · born here
❒asset
# assetType (asset type) The `assetType` is the **type of types** — the meta-type that every `<typename>.assetType/` folder is an instance of, including itself. A `<typename>.assetType/` folder declares a new asset type called `<typename>`: its on-disk shape, its identity rule, and the structural contract instances of the type must satisfy. This type is self-hosting. `assetType.assetType/` conforms to its own schema — a `type.yaml` plus a `README.md` — so the type system is defined in terms of itself rather than a hidden engine special-case (the same way a C compiler is written in C). Every asset in the engine, including each `.assetType` definition, now resolves to a registered assetType: a `.material` resolves to `material.assetType`, and `material.assetType` resolves to `assetType.assetType`, which resolves to itself. ## Why it exists Assets used to be mapped to their type *implicitly*, by matching the folder suffix against a name-keyed registry. That match carried no stored link: nothing on a `Foo.material` recorded *which* `material.assetType` it was written against, so two worlds shipping a same-named type could silently disagree. Making `assetType` a real, resolvable asset closes that gap — the link from an asset to its type is now an explicit reference pinned in the asset's `.refs` sidecar (`via: "asset_type"`), exactly like every other dependency. ## Where it lives - Source: `/zero/source/.../<typename>.assetType/` - Identity: `<typename>` (the `.assetType` suffix strips from the identity; the folder retains the suffix on disk). - Folder shape: - `type.yaml` — the structural spec the validator reads. **Required.** - `README.md` — type-level documentation. **Required.** - `about.yaml` — three short plain-language texts saying what the type is for (see "Say what your type is for" below). Every built-in type ships one. - `behavior.luau` — optional behavior/scaffolding module. - `template/` — optional canonical placeholder body the templater copies into a new asset of the type. - `<name>.module/` — optional shared code the type ships to **every instance** of it, conventionally `shared.module/` (see below). ## Shared code its instances reach (`asset.containing` + `.modules`) A type ships code every instance of it uses by declaring the modules in its own `behavior.luau`, as a map of tracked `require`s: ```luau -- inside <typename>.assetType/behavior.luau M.modules = { shared = require(".shared") } -- the sibling shared.module/ ``` An instance reaches it with one location-independent line: ```luau -- inside any foo.<typename>/init.luau local api = asset.containing(__FILE__).modules.shared ``` `__FILE__` is the chunk's own VFS path; `asset.containing` resolves the calling asset, and `.modules.<name>` follows the instance's pinned `typeRef` (the type's **guid**, recorded in the instance's `.refs` as `via = "asset_type"`) to the module its type declares. Because resolution follows that link rather than a category name, the same line in an instance of a different type resolves to that type's module, and identically-named modules in two types never collide. `asset.typeRef(target)` reads that guid for any target; `asset.resolve(asset.typeRef(target))` gives the full `AssetRef<assetType>`. See `assetTypes/README.md` § "Shared code: type-owned modules" for the full mechanism. ## How to create one Authoring a new asset type is just creating a `<typename>.assetType/` folder under `/zero/source/`. The engine registers `<typename>` as a category **the moment the folder is written** — no engine restart, no Rust change, and it works for built-in (`@builtin/assetTypes/`) and user-defined types identically. Once `<typename>` is registered, `<name>.<typename>/` folders are recognised as assets of that type and resolve their `asset_type` link back to this definition. Creating a `<name>.<typename>/` folder *before* its `<typename>.assetType/` exists fails fast: the suffix has no registered type, so the folder can't be a valid asset. Author the type first. ## Say what your type is for (`about.yaml`) Every type carries a small `about.yaml` beside its `type.yaml`, and the README you write for the type documents how to author an asset of it. Both are required, and both are meant to be written as you make the type, while you know what it is for. `about.yaml` answers three questions in plain words, one key each: ```yaml intent: "Sets the typeface of the text in your game: UI, labels, signs and 3D lettering." function: "A font, from a TTF, OTF or WOFF file, made available to all of Zero's text, including 3D text." usage: "You choose it by name for your UI or your text, and the text appears in that typeface." ``` - **`intent`** is what the type is for in someone's game. Name the whole range of things it covers, in the words a game maker would use for them. - **`function`** is how it works today: what an asset of the type is made of and what the engine does with it. - **`usage`** is what a person or an agent does with one: how they pick it, place it, call it, or hand it to something else. A few habits keep it useful. Write about the type as a whole, so the text holds for every asset of it, and leave out any one asset's name. Say what the type does right now. Stay with words a game maker would say, and mention a file name or a call only where a game maker would know it. The limits are in bytes: `intent` 800, `function` 1500, `usage` 1200. Each is generous, and a few sentences usually say it. Why bother: agents working in a world read these three texts to learn what your type is for, so they reach for it when it fits and use it the way you meant. People searching find the type by what they want to make, and the three texts let them tell at a glance whether it is the one they need. `asset.create("assetType", name)` scaffolds the file with all three keys, and a README whose first paragraph is a `[[describe]]` note. Each value starts with `[[describe]]` followed by a note on what to write; replace the whole value with your own words. A value or a README line that still starts with `[[describe]]` counts as not written yet, which the push's check of each asset it carries against its type reports, naming the file. A type you leave as it was is not asked, so older types stand. Many types at once, or one you would rather not write by hand: `services describe` lists the types that lack these texts and what filling them costs, and `{ mode = "all" }` writes them into the same files, where you edit them like anything else you wrote. Where the texts show up: `asset.inspect("<typename>", "assetType")` returns them as `detail.about`, `assetTypeRef:getAbout()` returns them as a table with the keys `intent`, `function` and `usage`, the type's `types/<typename>` guide page ends with an "About this type" section holding them, and the Inspector's Type section lists them at the top. The guide page is this README plus that section, so a README that explains the type well and an `about.yaml` that says what it is for read well together. ## Ask your assets to say what they are A type can ask each of its assets to carry a description: a file, written by the author or generated, that says what that asset is and what it is for. The people and agents who find an asset read it to decide whether it fits, and the author knows what it is for at the moment of making it. **1. Declare the file with a `described` check.** This is the whole requirement: ```yaml files: required: - path: "README.md" # any file name works kind: "file" content: - { check: "described", message: "Say what this widget is for and where it goes." } ``` With that in place: - An asset whose file is missing, empty, or still has a line starting with `[[describe]]` does not meet the type's requirements. `asset.validate` names it, `zm status` and `world.publishBlockers()` list it, and a push that carries it is refused with `message`. - `services describe` finds it (`mode = "find"` lists it and the price) and can write the description for it (`mode = "all"`). It writes only this file. For a YAML file that holds several texts, name the keys and their limits in bytes, the way this type does for `about.yaml`: ```yaml content: - check: "described" keys: - { key: "intent", max_bytes: 800 } - { key: "usage", max_bytes: 1200 } message: "Write intent and usage." ``` `headings` names sections a Markdown file must have. `assetTypes/README.md` has the full check. **2. Optionally, steer what gets generated with a `describe:` block:** ```yaml describe: guidance: "Say what the widget shows, what input it reacts to, and where it fits in a UI." examples: - "<identity of an asset of this type whose description reads well>" ``` `guidance` says what a description of your type covers, and `examples` names assets whose descriptions show the shape you want. Without the block, generation still works from the general describing guide and the check's `message`. An example is an asset of your type in the library whose description is a true, written one, never a scaffold's placeholder, and never the asset being described. When the library has none, leave `examples` empty rather than name one that is not. A type whose assets the model cannot perceive (a sound it cannot hear, a motion it cannot see) says so in `guidance`: the description comes only from what the asset's own files state, such as its name and the `.metadata` where a generation service records the prompt that made it, and when they state nothing the model answers `cannot` with that reason. `services describe` then fails that one asset with the reason and leaves its file as it was. **3. Start the file unwritten in your template.** Put a heading and one line that starts with `[[describe]]` and a short note on what to write, in `template/<file>`, so a new asset starts unwritten rather than with text that only looks written. Do not put example content in it: every new asset carries the template verbatim, and the same text on many assets makes them impossible to tell apart in search. Types whose assets say what they are through their own content (a mesh, a texture, a sound) leave this out: declare nothing and nothing is asked. ## The `behavior.luau` contract `behavior.luau` is the type's code. It returns ONE table, and the keys below are the ones the framework reads off it for EVERY type — the surface you get by declaring them. Anything else on the table is your own: reachable by name through `require("@builtin::assetTypes.assetType.shared.ref").loadTypeModule("<typename>")` for a system that knows your type (`computeShader` publishes `dispatchKey` that way), and never called by the framework. ```luau local M = {} M.ref = { ... } -- methods on every AssetRef of this type M.modules = { ... } -- shared code the instances reach M.global = {} -- reserved key; ship the empty table function M.onCreate(name, opts) ... end return M ``` ### The tables | Key | Shape | What the engine does with it | |-----|-------|------------------------------| | `M.ref` | `{ [name] = function(self, ...) }` | Every function becomes a method on every `AssetRef` of this type: `ref:name(...)`, with `self` the ref. This is how a type gives its instances an API. Two names in here are contracted — see below. | | `M.modules` | `{ [name] = require(".sibling") }` | Shared code the type's instances reach through `asset.containing(__FILE__).modules.<name>`, resolved by the instance's pinned `typeRef` guid. See the section above. | | `M.refShapes` | `{ [method] = "TypeName" }` | Declares the result type of a `M.ref` method so the LSP can check what a call site does with it. See the `M.refShapes` section below. | | `M.events` | an events schema | The events an ASSET of this type fires, declared the way a component declares its own. Readers subscribe through `ref.events.<name>:connect(...)`; firing authority stays with the type. Keyed by the asset's guid, so every resolver of the same asset shares the signals and a re-resolved ref re-attaches to subscriptions already there. | | `M.namePattern` | a Lua pattern string | The name shape `asset.create` enforces for instances of this type, replacing the default `^[A-Za-z][A-Za-z0-9_]*$`. | | `M.global` | `{}` | Reserved. Ship the empty table. | ### The lifecycle hooks Each is optional; a type that omits one costs nothing. The engine calls them: | Hook | Signature | When it fires | |------|-----------|---------------| | `M.onCreate` | `(name, opts) -> { [filename] = contents }` | On `asset.create("<type>", name, opts)`. Returns the files that scaffold the new instance, as a map of relative path to contents; the framework writes them. The `opts` type annotation is the schema `asset.create` validates the caller's arguments against, so annotate it. | | `M.onReplace` | `(dest, files) -> { [filename] = contents }` | On an `asset.create` that writes over an asset already at `dest`, after `onCreate`. Receives the files `onCreate` produced and returns the files to write, so a type that re-derives its content (a rig re-imported from its source file) can carry what an author added to the asset it replaces. Optional. | | `M.onRegister` | `(self)` | Once per instance, the first time it registers: on `engine.onWorldLoaded` for instances already in the world, immediately on a live `asset.create`, and when an instance arrives after that sweep (installed, pulled, or synced from a peer). Guarded by the instance's path, so a double trigger never double-registers. An instance that leaves the runtime releases the guard, so one arriving at the same path again registers. This is what makes "write an asset into the world and it takes effect live" work for content that registers into a runtime registry. The `@builtin` library is excluded from the sweep. | | `M.onChange` | `(ref, change)` | On every VFS write to a file INSIDE one of this type's instances. `change` is `{ path, asset, type, kind, origin }`: `kind` is `"edited"` or `"seeded"`, `origin` is `"local"` or `"remote"` (an importer runs on the originator only). **Filter on `change.path`**: the hook fires for any file under the folder, so act on the one you care about. It runs as its own task and may wait on what it reads: a `vfs.read` of bytes only the blob store holds (a binary file on the web build) fetches them. The writes to one asset reach the hook in the order they were made, each once the hook before it has finished. A re-entrancy guard suppresses writes back into the same asset routed inline from the hook, and a write the hook makes is routed on a later frame like any other, so the hook must be convergent on its own: diff the meaningful state and short-circuit while your own regeneration is in flight. | | `M.onDelete` | `(ref)` | When an instance of this type leaves the runtime: it is deleted, or the engine swaps away from the world binding that held it. Its files are gone from `/zero/source` by then. A removal routed while the instance's `onChange` is waiting reaches `onDelete` once that hook, and every write queued behind it, has finished. On a swap the instance still exists in the world it belongs to, and a VFS write the hook makes reaches the world now bound. | | `M.validate` | `(assetRef) -> { { code, message, severity? } }` | On `asset.validate`, after the structural `type.yaml` check, for the type's own SEMANTIC validation. `severity` defaults to `"error"`; error-severity problems flip `ok` to false, warnings do not. A hook that raises or returns a non-table is itself reported as a `validate.hook_failed` error. `world.push` runs this per user asset, so declaring it enforces your type's rules at publish time with no further wiring. | ### The two contracted `M.ref` names Most `M.ref` methods are your type's own surface: name them what you like, return what you like. Two are read by the engine and mean the same thing for every type, so their shape is fixed: - **`instantiate(self, target?, opts?) -> (root, idMap)`** — makes an instance part of the scene. Defining it is the whole opt-in: `ref:canInstantiate()` is true exactly when it exists. Its **return is a contract** — see the next section. - **`inspect(self) -> detail`** — the type-specific half of `asset.inspect`. See its section below. ### Names a type cannot shadow Some keys resolve on every `AssetRef` before per-type dispatch, so an `M.ref` entry of the same name is never reached: `canInstantiate`, `getSource` / `getBytes` / `getText`, `exists`, `deps`, `meta`, `runtime`, `events`, `modules`, `typeRef`, and the residency flags `has_backing_asset`, `has_runtime_changes`, `cpu_resident`, `gpu_resident`. These are the behaviours every asset must expose identically, which is why they win. ### Reloading A `behavior.luau` edit ripples to existing refs with no restart: dispatch reads `mod.ref` fresh each time and `require`'s cache is re-run in place. A type whose folder appears at runtime is picked up on the next dispatch — negative results are not cached either. ## The names your type's assets hold (`references:`) An asset that names another asset by a string depends on it: the named asset travels with it into a pack or a pull, and a name nothing answers to is an unresolved dependency `worldValidation` reports and the push gate refuses. The engine reads `require(...)` and the asset lookups on its own; a name your type's format or API carries anywhere else is one you declare, in `type.yaml`: ```yaml references: # A top-level key of this type's own files that holds a name (or a table of them). keys: - { key: "shader", type: "shader" } # A call's argument, counting from 1, wherever the call is written. args: - { call: "g:node", position: 2, type: "procNode" } # A field of the options table a call takes. fields: - { call: "fx.beam", field: "material", type: "material" } ``` `type` is the category the name resolves in, one of `asset.categories()`. An argument declared once per category, at the same `call` and `position`, takes the name from whichever category answers. A key or a field holds one category: declared again with another `type`, it takes the later one. The block is declared as the type registers, when the library or the world holding it is laid into the VFS, so every reference table reads it whatever script has or has not run. `asset.declareReferenceKey`, `asset.declareReferenceArg` and `asset.declareReferenceField` declare the same things from a script, for a surface that is no type's. ## What search does with your type (`indexing:`) A type declares what search embeds for its instances. **This is not optional and there is no useful default**: ZeroMind runs your declaration and adds nothing of its own, so anything you do not point at is absent from the index — silently, and for every instance of the type forever. Twenty types once shipped with no `indexing:` block and every instance of them was unfindable. A type whose instances are never searchable (a run record, a log) says so with `indexing: none`; every other type declares a recipe. A type without an `about.yaml` beside its `type.yaml` refuses every push that carries it, whether or not the push edited the type. Texts in it that are not written yet follow the rule every `described` file follows: they refuse the push that edits, stages or commits the type. Two words carry the whole thing, and they are the same two the search tool exposes: - **`identity`** — what an instance IS. For anything you can look at, that is the picture (`content:` + `modality: image`, matched directly by a text query). For everything else it is the authored text that says what it is. - **`capability`** — what it DOES and how it is made. Code, settings, the model-written summary of them. A type with no behaviour has no `capability` entry. A type with nothing to look at has no image. Leaving a slot empty is a statement; filling it with whatever happens to be lying around is not. The one you have to decide when authoring a type is: *for an instance of this, what is the thing a person would recognise it by, and what is the thing it does?* A texture answers "the image" and "its compression settings". A module answers "its README" and "its code". Write those two answers into `indexing:` and the rest follows. Three specifics worth knowing before you write one: - **`derive` is instructed by this type's own `README.md`.** A model reads an instance's source and writes a description; what it embeds is the description, not the source. It follows your README to know what it is looking at, so a type whose README says what its instances are gets good derivations for free. There is no prompt to name. - **`derive` loses detail.** It keeps the main technique and drops secondary ones. If the source is code you want searchable by its own vocabulary, declare the same files a second time as `capability` with `extractor: verbatim`. Two entries, same role, different failure modes. - **Never `source: { field: name }`.** A filename is one or two words with no usable embedding, and a corpus indexed that way answers "language runtime" with `say_runtime_2.soundClip`. `facets:` is the second stage: a `file:` embedded whole (`.metadata`, so keys nobody declared still get indexed) plus computed keys that state a value for every instance including `false` — the raw file can imply "not rigged" and can never say it. The full schema, every extractor and the facet sources are in [`assetTypes/README.md`](../README.md); the scaffolded block with inline guidance is in [`template/type.yaml`](template/type.yaml). ## A container whose contents work together (`system: true`) A type that is a container can say its contents are one working whole by declaring `system: true` at the top level of its `type.yaml`. `package` declares it: the components, modules, scenes and tools a package ships are parts of one system. The declaration is plain data, read from the decoded `type.yaml` (`require("@builtin::assetTypes.assetType.shared.declaration").of("package").system`), and a type that leaves it out is an ordinary type. ## What your type looks like (`preview:`) A type declares how its instances are pictured, and the engine makes the picture when something needs it: staging an instance whose `preview.png` is missing or pictures content it no longer holds queues a render, a view that shows the instance asks for one, and `ref:preview()` renders one on demand. An edit renders nothing on its own. Each `preview.png` records the content it pictured, which is how a stale one is told from a current one. The preview studio owns the light, the backdrop, the framing and the camera, and nothing in the world reaches it, so an instance pictures the same in every world. Declare one of four recipes: | `kind` | The picture is | Your type provides | |---|---|---| | `instantiate` | the asset stood in the studio through its own `instantiate` | `ref.instantiate` | | `image` | a file the instance holds, fitted to the frame, nothing rendered | `source.files`, the candidate files in order | | `surface` | the asset painted on a builtin mesh | `mesh`, and `ref.previewMaterial(self) -> { material }` | | `custom` | whatever `ref.preview(self, opts)` returns | `ref.preview` | ```yaml preview: kind: surface mesh: sphere ``` A scene-instantiable type that declares nothing still answers `ref:preview()` through its `instantiate`, but persists no picture: the declaration is what makes the engine keep one. List `preview.png` among the type's files so an instance may hold it. The picture is findable only when `indexing.content` names it. The two are separate statements, and neither is derived from the other: ```yaml indexing: content: - role: identity modality: image source: { file: "preview.png" } ``` `@builtin::assetTypes.assetType.shared.previewRecipe` reads the declaration; the scaffolded block with inline guidance is in [`template/type.yaml`](template/type.yaml). ## Typing a result from the instance (`M.refShapes`) Every method on `M.ref` is checked against the type its `--!return` names, and every asset of the type gets the same one. That is right for most methods and wrong for the ones whose result is shaped by the ASSET: a method answering one entry per child folder, per row of a config, per binding an input map declares. The widest true annotation for those is `{ [string]: Thing }`, and an indexer accepts every key — so a caller's typo reads as valid and nothing reports. `M.refShapes` lets the type state the result per instance. Each entry is `function(self) -> (typeExpression, source?)`: a Luau type expression for THIS asset, and the module whose type vocabulary the expression uses. Read the asset; never run it — stating a type must not take effect. ```lua -- inputMap.assetType/behavior.luau — the shipped example. -- `activate()` hands back one handle per control the map declares. M.refShapes = { activate = function(self): (string, string) local names = {} for _, control in ipairs(M.ref.controls(self)) do table.insert(names, control.name .. ": Handle") end if #names == 0 then return "", "" end return "{ " .. table.concat(names, ", ") .. " }", "@builtin::modules.zinput.scheme" end, } ``` With it, `map.jump:onPressed(fn)` resolves and `map.noexisting` is reported with the map's real controls. Without it, both pass silently. ### What the call site has to say A per-instance type is matched by the asset's IDENTITY, so it applies only where the reference the method is called on says WHICH asset. Two spellings do: ```lua -- a component field, whose declared default names the asset public = { map = Field.assetRef("inputMap", "@builtin::inputMaps.default", Sync) } local controls = public.map:activate() -- typed for THAT map -- an annotation, naming category and identity local m: AssetRef<"inputMap", "@builtin::inputMaps.default"> ``` `asset.resolve("<identity>", "<category>")` carries the CATEGORY, so the methods the category defines are checked on the result — but not which asset it found, so a per-instance result keeps the category's declared return. A reference that names no asset (`asset.resolve(someVariable)`, a value passed in as a parameter) carries neither, and calls on it are unchecked. That is the same rule everywhere: the checker states what the code states, and a name computed at runtime states nothing. ### The result is a value, not a binding The type belongs to the expression, so it travels the way any inferred type travels. Indexing the call's result is checked; stashing it in a module local and indexing it from another function is not, because the local's declared type is what carries across — and `any` (or no annotation) carries nothing: ```lua -- checked: `d.greting` is reported function awake() local d = public.dialogue:lines() d.greeting:say() end -- NOT checked: `lines` is a module local typed `any` local lines: any = nil function awake() lines = public.dialogue:lines() end function start() lines.greting:say() end ``` Bind what you need at the call site and the names stay checked in both places — the asset-derived type at the boundary, ordinary scoping after it: ```lua local lineGreeting = nil function awake() local d = public.dialogue:lines() lineGreeting = d.greeting -- `d.greting` is reported here end function start() lineGreeting:say() end ``` ### When nothing is reported and you expected something From a call site, a type that is correct and a type that was never published look the same: no diagnostic either way. `require("@builtin::assetTypes.assetType.shared.refShapes").published()` answers which it is. It returns two maps — the category surfaces, and the per-asset results keyed by identity and then by method: ```lua local shapes = require("@builtin::assetTypes.assetType.shared.refShapes").published() shapes.categories.dialogue --> "{ lines: () -> any, lineNames: () -> { string } }" shapes.returns.Shopkeeper.lines --> "{ browsing: Line, farewell: Line, greeting: Line, wares: Line }" ``` An identity absent from `returns` was never published for, which is a different thing from published-and-correct — and the reason to look here rather than at the call site. The answers are recomputed when an instance is written, so a control added to a map reaches the checker with no restart. Only types that declare `refShapes` are read per instance, and at most 64 assets of one type are — past that the type keeps its declared return and the engine log names what was dropped. ## The instantiate hook (`M.ref.instantiate`) — a contracted return A type opts into becoming part of the scene by defining `instantiate` on its `ref` table. That is the whole opt-in: `ref:canInstantiate()` is true exactly when the hook exists, so consumers offer a scene path — an `Asset.source` field, a viewport drop, a tool argument — by CAPABILITY rather than by a list of type names. Unlike `inspect`, this hook's **return is a contract**. A caller writes one piece of code against every instantiable type, so what comes back cannot vary by type: ```lua -- behavior.luau local Instantiable = require("@builtin::assetTypes.assetType.shared.instantiable") local M = {} M.ref = { instantiate = function(self, target, opts) local root = Instantiable.root(self, target, opts) -- IN: the base opts -- ... compose whatever this type is, under `root`, NOW ... return Instantiable.result(self, root, idMap) -- OUT: the contract end, } return M ``` **IN.** `target` is an owning entity ref: the instance lands under (or, for a hierarchy type, onto) that owner. With no target the type spawns a fresh root. `position`, `rotation`, `scale`, `name` and `temporary` mean the same for every type — `Instantiable.root` applies them to a root you mint, `Instantiable.place` to one you adopt, so you never re-read the spec. Honour more opts of your own if your type needs them, and document them in the hook's `--!arg` docs. **OUT.** Return `(root, idMap)` through `Instantiable.result`: - **`root`** — the composed root, as an `EntityRef`. Composition is **synchronous**: everything your type builds is live when you return, so the caller can parent to it and read its components in the same statement. Do not defer the work to a component's `awake` and return an empty shell — a root that is not live is refused. - **`idMap`** — the `originalId -> runtimeId` map naming what you spawned, or nil for a type with no addressable children (`result` normalises it to `{}`). **A caller never receives nil.** A component that re-composes your asset on every load keeps this map and passes it back in, which is how a cross-entity reference into the composition survives a reload. `AssetRef` runs every `instantiate` through `result` on the way out whether or not your type called it, so returning something else fails at your own call rather than handing a caller a nil root. Calling it yourself is still how you say what you return, and running it twice changes nothing. `@builtin::assetTypes.assetType.shared.instantiable`'s README is the full reference for both halves. ## The inspect hook (`M.ref.inspect`) `asset.inspect(ref)` resolves `ref`, builds a common envelope shared by every asset (`identity`, `name`, `guid`, `source`, `typeName`, `typeDefinitionPath`, `scope`, `origin`, `description`, `tags`), then calls the resolved type's own inspect hook — `M.ref.inspect(self)` on `behavior.luau` — for the type-specific `detail`. The hook returns *only* `detail`; the framework fills in everything else: ```lua -- behavior.luau local M = {} M.ref = { inspect = function(self) -- self.path is the asset's own folder. Parse the asset's OWN -- files — source text, a native payload header, its `.metadata` -- — never runtime state (a live component instance, a GPU -- upload, a compiled schema): inspect must work on an asset that -- hasn't been compiled, uploaded, or registered yet. return { -- type-specific fields, whatever this type wants to surface } end, } return M ``` A type that omits `M.ref.inspect` yields the generic record: the envelope alone, `detail = nil`. That's a valid, working state — not an error — but it means agents calling `asset.inspect` / `tools.use("assets","describe", ...)` on an instance of the type see only identity and scope, none of what makes an instance of it meaningful. Declaring the hook is what makes a type's instances inspectable for what they actually are. A hook that raises leaves `detail = nil` and sets `record.warning` to the error text — `asset.inspect` itself never raises for a resolved ref. ## Discovery - `asset.list("assetType")` — every registered asset type. - `asset.inspect("<typename>")` — the type's identity, source path, and this README, plus its `about.yaml` texts as `detail.about`. - `asset.resolve("<typename>", "assetType")` — the `<typename>.assetType` asset itself (used by the validator to find the type's `type.yaml`). ## Related - `assetTypes/README.md` — the full `type.yaml` schema and validator rules. - `@builtin::assetTypes.assetType.shared.instantiable` — the instantiation contract's shared implementation, both halves. - Every other `*.assetType/` here — the concrete types built on this meta-type. ## The Inspector a type ships Every type names the file its Inspector sections come from with `inspector: { type: "inspector.luau" }` in its type.yaml. `asset.create("assetType", name)` scaffolds the block and an `inspector.luau` whose Contents section lists an asset's files, built from `ctx.parts`. `asset.validate` on a type that names none reports `assetType.inspector_required` (an error for a `@builtin` type the engine's library authors; a warning for a world's own, and for one the library carries by reference, which the world that published it answers for), and one whose file does not load `assetType.inspector_invalid`. ## In the Inspector Type: what the type.yaml declares (suffix, container, primary files, the settings and inspector blocks), whether the type ships a behavior, how many instances it has, and **Open** for its files. Schema: the settings every instance carries, as read-only typed controls at their defaults (a type whose schema is per instance says where it is declared). Instances: a link to each of the first 20 assets of the type, and how many there are when there are more.
▲ 0↑ born
·
assettype · born here
❒asset
# guide A guide is a single-file documentation asset: a `<name>.guide/` folder whose body is `guide.md`, surfaced through the `guides` MCP tool, the `man` shell builtin and the Docs panel. Drop one anywhere under `/zero/source/`, a `.package` included, and it shows beside the built-in guides. ## In the Inspector Guide: the guide's word count, its headings, and **Open in Docs**, which opens it in the Docs panel.
▲ 0↑ born
·
tool · born here
❒asset
# capture.cleanup Clears every file from the capture output directory, removing the PNGs left behind by earlier captures. Safe to call when the directory is missing or already empty.
▲ 0↑ born
·
tool · born here
❒asset
# collage A grid of frames in one image. One picture that answers a question no single frame can: what does this look like from every side, what does this frame look like under each diagnostic pass, what moved over the last three seconds, which of these twenty shots is the shot. ## The axis is always stated A collage varies one thing across its cells, and the argument you pass is what that thing is: | Argument | One cell per | |----------|--------------| | `setups` | whole camera set-up — a shot list, each entry aimed the way a single capture is | | `viewpoints` | named view of one subject — a list, `"front top left"`, or `"sides"` for all six | | `passes` | render pass — `final`, `albedo`, `normal`, `depth`, `motion_vectors`, or any content-registered capture view | | `duration` | sample, spread across that many seconds of gameplay | `setups` and `viewpoints` are one axis — both say where the camera stands — so a request names one of them. Naming a station axis **and** `passes` lays out a 2D grid: a row per station, a column per pass. Reading across a row is one set-up under every pass; reading down a column is one pass from every set-up. A collage with no axis is refused, naming all of them. It does not fall back to time — a silent time default is exactly what taught callers that a collage could only ever be time, so nobody looked for a grid of views. `duration` cannot combine with `setups`, `viewpoints` or `passes`. A cell that differs both in what it looks at and in when it was taken answers neither question; take one collage per axis. ## The shot list Each entry of `setups` is written the way a single capture is aimed — `source`, `camera`, `entity`/`entities`, `position`, `lookAt`, `rotation`, `distance`, `angle`, `margin`, `viewpoint`, `basis`, `projection`, `orthoHeight`, `fov`, `near`, `far` — plus `label` to name the shot on the result. A field an entry leaves out comes from the collage's own options, so a shot list writes down only what makes each shot differ: ```lua zero capture collage --setups '[ { "position": [-14.6, 1.35, 4.5], "lookAt": [-16.3, 1.1, 1.6], "fov": 28, "label": "doorway" }, { "position": [8, 3, 12], "lookAt": [0, 1, 0], "fov": 50, "label": "wide" }, { "entity": "hero", "viewpoint": "front", "basis": "local", "label": "closeup" } ]' ``` Three stations, three lenses, three subjects, one instant, one picture — which is the comparison a framing pass is made of. A key outside that vocabulary is refused where it was written, so a misspelled `fov` names itself instead of quietly framing a shot nobody asked for. ## Reading the result The grid shape is worked out from the number of cells — pass `grid` (`"3x2"`) to state it, and it is an error rather than a silent crop if it cannot hold them. Every cell comes back labelled in `cells`, with its `label`, the `viewpoint` and/or `pass` that made it differ, the `eye` it was rendered from and the lens it was rendered through. A grid is meant to be readable from the response, not guessable from the pictures. Only a time collage reports the window it covered — a station or pass grid samples one instant, and reporting a span for it would invite reading the difference between cells as motion. ## Aiming it Exactly as a single capture is aimed: `entity` (with `viewpoint` and `basis`, or `angle` and `distance`), `position` with `lookAt`, `camera`, or nothing at all for the main scene camera. `projection`, `orthoHeight`, `isolate`, `renderLayers`, `fov`, `width` and `height` all mean what they mean for one frame, and apply to every cell a set-up of its own does not override. The shot most of this exists for is one call: ```lua zero capture collage --entity crate --viewpoints sides --basis local \ --projection orthographic --isolate ``` Six sides of one object, each an orthographic elevation, nothing else in frame.
▲ 0↑ born
▣
module · born here
❒asset
# feed The newest frame a capture produced on this engine, and who is watching for it. Every capture core publishes here. `latest()` is that frame: a `src` an image widget draws (the render target's guid while the engine still holds it, the written path when the capture produced a file), with the size, the source and the pass beside it. `watch(fn)` calls `fn` as each new frame arrives, and `unwatch(token)` drops the subscription. `shown()` says a viewer is drawing frames from the feed. From then on the feed holds the newest capture's render target so the picture stays up after the capture that made it is finished with it, and lets it go when a later frame replaces it; `shown(false)` stops. With nobody drawing, a capture's target is released the moment its capture is done. The release path asks `retains(rtHandle)` before destroying a target, which is how a held frame survives its own capture. `capture.shared.releaseFrame` is the one place that asks.
▲ 0↑ born
·
tool · born here
❒asset
# capture.fromCamera Render the scene from a specific named camera's authored pose and settings, returning the picture as an image value (and writing a PNG as well when a `path` is given). By default it uses the camera's exact world-space pose plus its whole lens (fov/near/far, and the projection it builds with the orthoHeight an orthographic camera covers), its diagnostic debugChannel, its post-process setting, its lighting environment (an isolated camera's background and ambient with it) and the scene layers it draws: the camera's own `renderLayers` with the editor's chrome (`EditorUI`) and the authoring overlays (`debug`) taken off, since those are drawn for whoever is editing rather than by that camera into the world. So the frame is precisely what that camera draws of the scene, without changing what is on screen. Pass overrides (`renderLayers`, `debugChannel`, `fov`, `near`, `far`, `projection`, `orthoHeight`, `width`, `height`) to change any of those for the one capture without touching the camera; `renderLayers = "all"` is how the overlays are captured on purpose.
▲ 0↑ born
·
tool · born here
❒asset
# capture.fromEntity Renders a screenshot orbiting a target entity. The camera position is computed from a distance and a yaw/pitch angle relative to the entity's world position, with an optional offset applied before framing and a configurable field of view and output size. Returns the picture as an image value, and writes a PNG as well when a `path` is given; fails when the entity is missing or its position can't be read. Runs as a background task that waits for the GPU readback, so it works in play mode.
▲ 0↑ born
·
tool · born here
❒asset
# capture.fromPosition Renders a screenshot from an explicit world-space camera position and returns the picture as an image value. Aim it with a look-at target (defaulting to the origin) or a quaternion rotation that takes precedence, and set field of view, output size, and near/far clip planes. A PNG is written as well when a `path` is given. It spawns an ephemeral camera, triggers one render, reads the frame back, and despawns the camera automatically — running as a background task that waits for the readback, so it works in play mode.
▲ 0↑ born
▣
module · born here
❒asset
# isolate Show the subject without the other geometry drawn, then put everything back. A prop inside a built scene is behind whatever stands in front of it. The render-layer system already expresses "draw only these" — an entity is a member of layers, a camera renders a filter over them — but it does not remember what it displaced, so every caller wanting one clean shot of one thing hand-rolls the same record, swap and restore. This is that, once, with the restore guaranteed. ## What it changes Exactly one thing: the other geometry is not drawn. Sky, post-process and UI are left exactly as the capture's own render-layer spec stated them, so a final frame stays a final frame. A caller who wants the geometry read flat — no lighting, no atmosphere — asks for a **pass** (`pass = "albedo"`, `pass = "normal"`), which is what passes are for. ## What it does not change Excluded geometry still **casts shadows** onto the subject and still bounces light into it. Lights are not filtered by render layer at all, and the layer mask drives object culling and the geometry passes rather than the shadow passes. This is the render-layer system's deliberate behaviour — a wall stays out of the shot while it still exists for lighting, shadows and physics — so a shadow with no visible caster in an isolated capture is the system working, not a bug. ## The layer One reserved layer name, `captureIsolate`, reused by every isolated capture. Membership is a 32-bit mask with six reserved bits. A layer minted per call would exhaust the namespace in twenty-six captures and leave a trail of empty layers that `renderLayer.list` would show forever. ## Restoring `begin` records each affected entity's membership before moving anything, so the token describes the whole subtree even if the move fails part-way. `restore` puts every entity back to the layers it carried — and an entity that carried **no** explicit membership ends with none, rather than an explicit `default` that looks identical in a picture and different in the data. `restore` is safe to call twice and safe on a token whose subjects have since despawned, which is what lets a caller restore unconditionally on every exit path: success, failure, and once around a whole collage grid rather than between its cells.
▲ 0↑ born
·
tool · born here
❒asset
# capture.oneshot The low-level one-shot capture primitive. Spawns an ephemeral offscreen camera configured from a source — the viewport, an entity (or several), a world-space position, or a UI window — triggers a single render, and returns the camera and render-target handles synchronously so the caller drives the readback and cleanup itself. This synchronous shape is the only capture path that works from edit mode, where the background-task scheduler the convenience wrappers rely on does not tick. When framing an entity, omitting the distance auto-fits the camera to the union world-space bounds of the target(s), so the subject is guaranteed fully in frame at any scale — a small prop and a large building both fill the shot. Because the data drives the camera, an empty result is a real signal that the geometry or material is wrong rather than a framing mistake; a distance can be passed to force a fixed orbit radius, and an angle sets only the viewing direction. Further options select the debug visualization channel, toggle which layers (scene, sky, post-process, UI) render, and set field of view, clip planes, and output size. The returned camera is left disabled so it can be re-triggered to produce additional frames on the same target, as when stitching a collage.
▲ 0↑ born
▣
module · born here
❒asset
# shared Module Cross-tool helpers for the `capture` toolbox. Every tool inside this toolbox can pull these in with `require(".shared")`. ## Purpose This module holds the small set of helpers that more than one tool in the toolbox needs — typically the `ok(value, formatted?)` / `fail(message, exitCode?)` constructors that produce the canonical `captureToolResult` shape, plus any toolbox-wide parsers, validators, or shared state. Keep it focused: per-tool implementation stays inside each `<x>.tool/init.luau` (with its own `--!desc` / `--!arg` / `--!return` / `--!example` annotations). ## Usage ```luau local shared = require(".shared") function M.someTool(...) if not ok then return shared.fail("reason", 1) end return shared.ok(value, "") end ``` ## Exports See `init.luau` for the full export surface. Typical exports include `shared.ok(value, formatted?)` and `shared.fail(message, exitCode?)` for building the toolbox's standard result envelope.
▲ 0↑ born
▣
module · born here
❒asset
# subject What a capture of an entity is a picture of. Every path that frames or isolates an entity (`fromEntity`, `oneshot`, a `setups` or `viewpoints` collage, `isolate`) resolves the name, id or proxy it was given here, so they agree on which entity a name means. ## A player is drawn as its body A player identity (an entity carrying `UserIdentity`) is the registry anchor a connected user is known by. The player is drawn as the body its `avatar` names, a standalone entity at the scene root, so a capture of an identity frames and isolates that body. In play, a player prototype's spawn turns the prototype's copy into the joining user's identity under the prototype's own name and stands the body it names at the spawn point. A capture of the name an author gave their player prototype therefore frames the player's body in play, and the prototype's subtree in edit. ## What a refusal names `describe(target, via)` is the phrase a framing refusal uses for each subject it looked at: the entity's name and id with the number of descendants it holds, and the player identity it is the body of when it was reached through one, or, for a player identity with no live body bound, that the body is missing. | Function | Returns | |----------|---------| | `resolve(t)` | the entity a capture pictures for a name, id or proxy (nil when none matches), and the player identity it was reached through | | `bodyOf(target)` | the live body a player identity is drawn as, or nil | | `isPlayerIdentity(target)` | whether the entity carries `UserIdentity` | | `describe(target, via)` | the refusal phrase for one resolved subject |
▲ 0↑ born
▣
module · born here
❒asset
# viewpoints The named camera stations a capture can be taken from, and the rule that decides what a name like `front` means. A **viewpoint** is a direction with an image-up: where the camera stands relative to what it is looking at, and which way is up in the resulting picture. Naming one replaces reverse-engineering a `{yaw, pitch}` pair, and names the seven stations that answer "is this built correctly" — the six sides and the corner. | Viewpoint | Sees | |-----------|------| | `front` | the side the subject faces | | `back` | the opposite side | | `right` | the subject's right | | `left` | the subject's left | | `top` | plan view, the subject's front toward the top of the image | | `bottom` | the underside | | `iso` | the corner view where all three axes project equally | An entity faces its local -Z, so the camera that sees its front sits on its +Z. `top` and `bottom` take their image-up from the subject's forward axis, because world up is undefined when you are looking straight down it — that is what puts the subject's front at the top of a plan view instead of leaving the roll to whatever the yaw happened to be. ## Basis `basis` says which axes the name is measured against, and it has **no default**: - **`"local"`** — the subject's own axes. `front` is the side the subject faces, whichever way it is turned, and the frame is fitted to the subject's own extents (`entity:orientedBounds()`). - **`"world"`** — the world axes. `front` is the side facing world +Z, whatever the subject is doing. For a crate turned 40 degrees these are different pictures, so the caller states which one it wants. A default would mean one call site's `front` is the crate's front and another's is the world's, and the difference only shows up in the image. With no subject to take axes from — a capture framed on a world position rather than an entity — both values mean the world axes, and both are accepted. ## Orthographic size `orthoHeightFor` answers the question an orthographic frame asks that a perspective one does not: how big is the frame? A perspective camera backs off until the subject fits; an orthographic camera does not converge, so its size is decided by the subject alone — project the bounds' eight corners onto the camera's up and right axes and take whichever needs more room. Its `half` extents and `axes` must be stated in the same frame. A resolved viewpoint carries both: `frame` axes to use with local-frame extents, and its world axes to use with world extents.
▲ 0↑ born
·
tool · born here
❒asset
# capture.viewport Renders a screenshot mirroring the active viewport. It mirrors the on-screen camera through the shared capture core, so the frame carries that camera's pose, its lens (`fov`, clip planes and the projection it builds), the lighting environment it states (an `isolated` camera's background and ambient) and the layers it draws the screen with, the editor's own overlays included, so the image matches what's on screen. The raster is the viewport's own pixel size, the size `getViewportSize()` reports. Returns the picture as an image value, and writes a PNG as well when a `path` is given; fails when no active viewport camera exists. Its one argument is a path to also write the PNG to, or a table overriding any of that for one capture: `width` / `height` for a raster of some other size, `renderLayers` for the frame under a different layer spec — `"all !EditorUI !debug"` is the frame without the editor's chrome over it — and `postProcessing` to take it with the grade off. ```lua tools.use("capture", "viewport", "/source/tmp/capture/shot.png") tools.use("capture", "viewport", { path = "/source/tmp/capture/clean.png", renderLayers = "all !EditorUI !debug" }) tools.use("capture", "viewport", { width = 960, height = 540 }) ```
▲ 0↑ born
·
assettype · born here
❒asset
# Toolbox (asset type) A toolbox is a namespace folder that groups related `.tool/` children plus shared helpers. Toolboxes are the addressing layer for tools — every tool's identity is `<toolbox>.<name>`, so the toolbox name appears in every callsite. Toolboxes also own a `shared.module/` helper module that the toolbox's tools `require(".shared")` for common utilities (result envelopes, validators, formatters). ## When to use one - You have two or more related tools that belong together (an `anim` toolbox with `play` / `stop` / `list`; an `assets` toolbox with `compose` / `validate`). - You need a shared helper module exclusively used by a tool set. - You want a clean dot-namespaced identity for your tools (`my_tools.foo`, `my_tools.bar`). If you only have one tool and no shared helpers, you still need a toolbox — it's the required parent. ## Where it lives - Source: `/zero/source/.../<Name>.toolbox/` - Identity: `<Name>` (the `.toolbox` suffix strips). - Folder shape (container-style — open child set): - `README.md` — instance documentation. **Required.** - `.metadata` — agent-editable tags + free-form fields. **Required.** - `shared.module/` — optional shared helper module (`init.luau` + `README.md`). - `<x>.tool/` — any number of `.tool/` children. The validator permits unlisted children (`allow_unlisted: true`) so tool subfolders don't need to be declared per-name. ## How to create one ```luau tools.createToolbox({ name = "<Name>", description = "..." }) -- or the generic scaffold: asset.create("toolbox", "<Name>") -- Creates: /zero/source/<Name>.toolbox/ -- README.md (instance README template) -- shared.module/ (ok / fail result-envelope constructors) -- `folder` places it in a subfolder of /source; `into` nests it in a -- resolved `.package`: asset.create("toolbox", "<Name>", { folder = "tools" }) ``` Then add tools under it: ```luau local box = asset.resolve("<Name>.toolbox") asset.create("tool", "<toolName>", { into = box }) ``` ## How it operates 1. **Registration.** Writing into a `.toolbox/` folder indexes the toolbox. It becomes the parent namespace for any `.tool/` children. 2. **Tool identity composition.** Each child `.tool/`'s identity is `<toolbox>.<tool>`. Listing the toolbox's tools enumerates the children. 3. **Shared helpers.** Tools inside the toolbox pull `shared.module/` in via `require(".shared")` (relative require from the tool's `init.luau`). 4. **Hot reload.** Editing `shared.module/init.luau` reloads every tool in the toolbox (they all `require` it). Editing the toolbox folder structure (adding / removing tools) reflects in `tools.list` immediately. ## Discovery - `asset.list("toolbox")` — every registered toolbox. - `asset.inspect("<name>")` — child tools, source, this type README. - `ls /zero/source/<Name>.toolbox` lists the files the folder holds. - `tools.list()` — every tool across every toolbox. ## Authoring conventions - **Per-tool implementation lives in each `<x>.tool/init.luau`.** The tool's full function body — argument validation, the call into engine APIs, the return value — goes in `init.luau` with `--!desc` / `--!arg` / `--!return` / `--!example` annotations above the function. **Every exported function is declared `typed function`** — the keyword compiles to the runtime argument check, so a plain `function` accepts any input and reports success on garbage. Do NOT make `init.luau` a one-line forwarder onto a function defined in `shared.module/`. - Keep `shared.module/` thin: result envelope constructors (`shared.ok(value, formatted)`, `shared.fail(message, exitCode)`), argument validators, common formatters — anything genuinely used by more than one tool. Per-tool logic does NOT belong here. - Group by domain, not by surface — `assets` toolbox holds asset operations, `entity` toolbox holds entity operations. Tools that feel unrelated probably want different toolboxes. - Document the toolbox's surface in `README.md` — what problem space it covers, who calls into it, any shared invariants. ## Common pitfalls - **Missing parent toolbox.** Tools cannot exist outside a toolbox. Always scaffold the toolbox first. - **Cross-toolbox shared.** Each toolbox has its own `shared.module/`. Don't try to share helpers across toolboxes; if you need cross-toolbox helpers, factor them into a standalone `.module`. - **Toolbox identity.** Strip the `.toolbox` suffix in identity references (`my_tools`, not `my_tools.toolbox`). ## Related types - `.tool` — the required child(ren) of a toolbox. - `.module` — for cross-toolbox utilities. ## In the Inspector Tools: how many tools the box holds, whether it ships a shared module, what each tool does, and a link to each tool.
▲ 0↑ born
·
tool · born here
❒asset
# debug.inspect Inspect entity component state — script components, native ECS components, or both — for every entity matching the target. ```lua debug.inspect("player") debug.inspect("lamp", { include = "ecs" }) debug.inspect("enemy_*", { types = { "Health" }, limit = 5 }) ``` The target is an entity id, a name, an entity proxy, or an array of them. A name resolves to **every** matching entity (names are not unique; globs like `enemy_*` work), an id to itself. Options: ```lua { include = "all", -- "script" | "ecs" | "all" (default) types = nil, -- restrict to these component types; full identity -- or leaf name ("Camera" matches -- "@builtin::components.Camera") limit = 10, -- cap on matches } ``` Returns: ```lua { query = { target, count }, matches = { { id = "ent_...", name = string?, script = { [componentType] = data }, -- serialized public data ecs = { [componentName] = fields }, -- native component fields }, ... }, } ``` `script` data is the serialized form (entity refs as id strings, asset refs as `{ __ref, name, type }` envelopes) produced by the `component_snapshot` module; `ecs` is `ecs.snapshot` per entity. For live gameplay reads and writes, use `entity(id).component.get` / `getAll` — the data those return is the running component's proxy, not a snapshot.
▲ 0↑ born
·
tool · born here
❒asset
# debug.playSession Show or hide the debug overlay during play mode. ```lua debug.playSession(enabled?) ``` - `enabled` — `true` (default) to show the overlay in play, `false` to hide it. Returns `{ playSession = boolean }`. Edit mode always shows the overlay; play mode shows it only while this session is on — the way to watch bones, colliders, or bounds on a running, animating scene (bones only move once the scene is unpaused). The flag lives in memory only and is never saved, so debug visibility can never be permanently toggled on by accident; it resets on engine restart.
▲ 0↑ born
·
tool · born here
❒asset
# debug.problems Surface the recent errors and warnings the caller has not read yet. ```lua debug.problems() ``` Non-crashing failures — a contract violation, a component `awake`/`update` throw, a component auto-disabled after erroring, an unresolved require, a bridged renderer or asset error — land in the engine's log ring but do not surface in `execute` results unless you happened to ask for them at the right level in the call where they occurred. `debug.problems` reads them back out. **When something you built does not behave, call this first.** The engine has usually already logged the reason. Each call advances a read-cursor and returns the problems logged since the previous call, **oldest first** — so the root-cause error (the `awake()` throw that disabled a component) reads ahead of the cascade it triggered. Repeated calls report only what is new. ```lua debug.problems({ level = "warn", -- minimum severity: "warn" (default) or "error" limit = 50, -- cap on entries returned (default 50) all = false, -- true: recent problems regardless of the cursor, cursor untouched peek = false, -- true: read the next batch without advancing the cursor }) ``` Returns: ```lua { problems = { -- oldest first { seq, level, type, message, timestamp }, ... }, shown = number, -- #problems truncated = boolean, -- more unread problems remain past `limit` cursor = number, -- read-cursor after this call counts = { errors, warnings }, -- lifetime totals (survive ring eviction) } ``` `all = true` gives a one-shot overview of the most recent problems without disturbing the drain cursor. `peek = true` previews the next batch and leaves it unread for the next call. The full log ring — every level, searchable, countable, filterable by the script or entity that logged a line — is the `logs` toolbox, whose `search`, `tail`, `errors` and `summary` tools read it. Reach for those when you need more than the unread problems: a specific message, a specific entity, a specific minute, or the lines that led up to a failure. The same ring is also readable directly from Luau through the `logs` global, and as plain files at `/zero/runtime/logs/engine`, `/zero/runtime/logs/errors` and `/zero/runtime/logs/script` when a grep for a message you can name is shorter than a query. This tool is the read-cursor view over the warn/error slice of it.
▲ 0↑ born
·
tool · born here
❒asset
# debug.scope Focus the debug overlay on specific entities, or clear the focus. ```lua debug.scope(target?) ``` - `target` — a name or `ent_` id, an array of them, or the `{ id = ... }` records `scene.findAll` returns. Names resolve to every matching entity. Omit (or pass an empty list) to clear the focus and draw for every entity again. Returns `{ scoped = { ids }, count = number }`, the scope after the change. Every enabled category honours the scope, so the overlay focuses on the chosen objects — hierarchy bounds, for instance, draw one box per scoped part instead of one union box per top-level object. The scope lives in memory only and is never saved.
▲ 0↑ born
·
tool · born here
❒asset
# debug.set Show or hide a debug-visualization overlay category. ```lua debug.set(category, enabled?) ``` - `category` — a category name (`bounds`, `frustum`, `bones`, `colliders`, `icons`, `wireframe`), or `"all"` for every category. - `enabled` — `true` (default) to show the category, `false` to hide it. Returns `{ [category] = boolean }`, the category state after the change (every category when `"all"` is passed). Errors on an unknown category name, listing the known ones. The overlay is ambient editor tooling drawn for the whole scene; this only flips which categories draw. `bounds`, `bones`, `colliders`, and `wireframe` are off by default (heavier per-mesh overlays); `frustum` and `icons` are on.
▲ 0↑ born
▣
module · born here
❒asset
# shared Module Cross-tool helpers for the `debug` toolbox. Every tool inside this toolbox can pull these in with `require(".shared")`. ## Purpose This module holds the small set of helpers that more than one tool in the toolbox needs — typically the `ok(value, formatted?)` / `fail(message, exitCode?)` constructors that produce the canonical `debugToolResult` shape, plus any toolbox-wide parsers, validators, or shared state. Keep it focused: per-tool implementation stays inside each `<x>.tool/init.luau` (with its own `--!desc` / `--!arg` / `--!return` / `--!example` annotations). ## Usage ```luau local shared = require(".shared") function M.someTool(...) if not ok then return shared.fail("reason", 1) end return shared.ok(value, "") end ``` ## Exports See `init.luau` for the full export surface. Typical exports include `shared.ok(value, formatted?)` and `shared.fail(message, exitCode?)` for building the toolbox's standard result envelope.
▲ 0↑ born
·
tool · born here
❒asset
# debug.state Report the current debug-visualization state. ```lua debug.state() ``` Returns: ```lua { categories = { [name] = boolean }, -- which categories draw scope = { ids }, -- focused entity ids (empty = all) count = number, -- #scope playSession = boolean, -- play-mode overlay session on? mode = string, -- engine mode ("edit" / "play") } ``` A read-only snapshot of what `debug.set`, `debug.scope`, and `debug.playSession` have configured — the state the ambient overlay draws from this frame.
▲ 0↑ born
·
tool · born here
❒asset
# wld.edit Return the engine to edit mode. Restores the edit state that was auto-snapshotted on the previous transition into play, and stops script and physics execution so the scene sits still for authoring. This is the counterpart to entering play — the round trip lets you run a scene, then rewind to exactly the state it had before it started.
▲ 0↑ born
·
tool · born here
❒asset
# wld.hideLayer Hide a loaded scene layer by name. The layer's entities stay in the world and keep their state — only their rendering stops. Showing the layer again makes them visible without a reload, while unloading despawns them entirely. Useful for toggling optional overlays such as a UI or debug layer on and off cheaply.
▲ 0↑ born
·
tool · born here
❒asset
# wld.info Read the current world's high-level state in one call: the bound world name, whether it is in edit or play mode, the active scene layer, and the list of saved scene snapshots in the live world. A quick orientation snapshot for deciding what to do next without querying each piece separately.
▲ 0↑ born
·
tool · born here
❒asset
# wld.listWorlds List the worlds persisted on disk under the local worlds directory. Returns the name of each stored world, giving a quick inventory of what has been saved locally.
▲ 0↑ born
·
tool · born here
❒asset
# wld.loadLayer Load a scene as an additive layer alongside the current scene, composing its entities on top of what is already live rather than replacing it. An optional origin offset positions the loaded content in world space, and the layer can be marked persistent or given an explicit name so it can be hidden, shown, or unloaded later.
▲ 0↑ born
·
tool · born here
❒asset
# wld.mode Report the engine's current mode. Returns `"edit"`, where scripts and physics are paused for authoring, or `"play"`, where they run. Use it to branch on the current state before flipping modes.
▲ 0↑ born
·
tool · born here
❒asset
# wld.play Enter play mode. First auto-snapshots the current edit state so returning to edit can restore it, then starts scripts and physics so the scene runs live. This is the counterpart to returning to edit — play the scene to see it in motion, then rewind to the pre-play snapshot.
▲ 0↑ born
·
tool · born here
❒asset
# wld.promoteAndSwitch Promote the source-file edits made during play (the play-shadow set — what accepting the "edits" group promotes), then switch the engine to the requested mode, in one call. Replaces the changes() / acceptChanges("edits") / wld.edit()-or-wld.play() sequence for the edit-and-retest loop. Entity changes stay in the sceneAuthoring review flow: a flip to edit with unaccepted entity changes stops at the leave-play safeguard.
▲ 0↑ born
▣
module · born here
❒asset
# shared Module Cross-tool helpers for the `wld` toolbox. Every tool inside this toolbox can pull these in with `require(".shared")`. ## Purpose This module holds the small set of helpers that more than one tool in the toolbox needs — typically the `ok(value, formatted?)` / `fail(message, exitCode?)` constructors that produce the canonical `wldToolResult` shape, plus any toolbox-wide parsers, validators, or shared state. Keep it focused: per-tool implementation stays inside each `<x>.tool/init.luau` (with its own `--!desc` / `--!arg` / `--!return` / `--!example` annotations). ## Usage ```luau local shared = require(".shared") function M.someTool(...) if not ok then return shared.fail("reason", 1) end return shared.ok(value, "") end ``` ## Exports See `init.luau` for the full export surface. Typical exports include `shared.ok(value, formatted?)` and `shared.fail(message, exitCode?)` for building the toolbox's standard result envelope.
▲ 0↑ born
·
tool · born here
❒asset
# wld.showLayer Show a previously hidden scene layer, restoring the rendering of its entities. The counterpart to hiding a layer — since hiding leaves the entities in the world, showing brings them back into view instantly with no reload.
▲ 0↑ born
·
tool · born here
❒asset
# wld.unloadLayer Unload an additive scene layer by name, despawning its entities entirely and removing its contribution from the composed scene. This fully releases the layer's content; to keep the entities alive but stop drawing them, hide the layer instead.
▲ 0↑ born
·
tool · born here
❒asset
# clear Drops the buffered log lines, so a following search sees only what happened after the clear. The lifetime per-level counts **summary** reports are preserved, so whether there were ever any errors stays answerable. Rarely the right move. **summary** reports a `cursor` which, handed back to **search** as `since`, isolates what an action logged without discarding lines anybody else may want. Returns `cleared` and the `cursor` to read from next.
▲ 0↑ born
·
tool · born here
❒asset
# errors Recent errors and warnings, newest first. A snapshot: the same lines however many times it is called. That is the difference from the `problems` tool in the `debug` toolbox, which drains — it advances a read-cursor and reports only what has not been seen, so that one answers "what is new" while this answers "what is there". `level` defaults to `warn`, which includes errors. Takes the same filters as **search**, `origin`, `caller` and `context` among them, so it narrows the same ways, and returns the same fields. Its lines are always newest first and never grouped, so `order` and `group` are refused rather than ignored.
▲ 0↑ born
·
tool · born here
❒asset
# search The general query over the engine log ring. ## Filters All optional. They narrow together — a line must satisfy every one given. | option | meaning | |---|---| | `level` | minimum severity: `trace`, `debug`, `info`, `warn`, `error` | | `type` | subsystem, case-insensitive | | `contains` | case-insensitive substring of the message | | `pattern` | regex over the message | | `script` | lines a named script logged | | `entity` | lines logged by a script running on that entity | | `caller` | lines one caller's work raised: `mine`, `unowned`, or a caller key | | `origin` | `local` for lines raised by content this session authored, `remote` for content another session on the world authored | | `within` | how many seconds back to look | | `since_time`, `until_time` | an absolute window, in epoch seconds | | `since` | only lines newer than this `seq`, for incremental polling | | `context` | also return this many lines either side of each match | | `group` | collapse repeated messages into one row each | | `limit` | default 100 | | `order` | `asc` (default, oldest first) or `desc` | | `include_mcp` | include the record of your own tool calls | A severity that is not one of the five is refused by name rather than matching nothing, because an empty result reads as "the engine logged nothing". So is a window that starts after it ends, a negative `within`, and an `origin` other than `local` or `remote`. An option this table does not name is refused naming it, along with the ones it does name. A misspelled filter would otherwise be dropped, and the answer to the wider question would read exactly like the narrowed one. ## Context `context` returns the lines either side of each match, each marked with `context`. What led up to a failure is made of lines the filter rejected, so a filtered view can never show it otherwise. Overlapping windows merge, and a line that is itself a match stays a match rather than being demoted to context. ## Grouping `group` collapses lines sharing a message template — the same line with numbers, hashes and ids masked out — into one row, most frequent first. A per-frame error becomes one row with a count instead of burying everything else. Each row carries `template`, `message` (the most recent occurrence), `count`, `level` (the worst severity seen), `first_seq`, `last_seq`, `last_timestamp`, and `script` / `entity` when every occurrence shared one. `context` and `group` cannot be combined: a group has no single position in the log for context to surround, so asking for both is refused rather than answered with one of them quietly dropped. ## Returns | field | meaning | |---|---| | `entries` | the matching lines — or `groups` when `group` is set | | `shown` | how many came back | | `matched` | how many the filter selects in the whole ring | | `truncated` | true when `limit` cut the answer short | | `cursor` | the `seq` to hand back as `since` next time | | `counts` | lifetime `errors` and `warnings`, which survive ring eviction |
▲ 0↑ born
▣
module · born here
❒asset
# logs.shared Option reading and result shaping for the log tools. One reader for the filter table every tool accepts, so `search`, `tail`, `errors` and `summary` cannot drift apart on what an option is called or what it means. One shaper for what they return, so a caller who learns one result learns them all. - `filters(opts, who)` — validate a tool options table and translate it into the filter the engine query takes, resolving `within` against the clock. - `run(query, who)` — run the query, reporting a bad regex against the tool the caller actually called. - `result(entries, query, who)` — the common envelope: entries, how many matched, whether the limit cut it short, and the cursor to poll from. - `group(entries)` — collapse entries that share a message template.
▲ 0↑ born
·
tool · born here
❒asset
# summary How many lines, of what severity, from where, and which messages repeat — the shape of the noise before you go looking inside it. Also the cheapest check for whether anything went wrong. Takes the same filters as **search**, `origin` and `caller` among them, so it can describe a slice as well as the whole ring. It answers in counts rather than lines, so `order`, `context` and `group`, which shape a list of lines, are refused rather than ignored. ## Returns | field | meaning | |---|---| | `matched` | lines the filter selects | | `buffered` | lines the ring currently holds | | `capacity` | how many it can hold | | `dropped` | lines evicted for capacity since the last clear | | `cursor` | highest `seq` assigned — hand back to **search** as `since` | | `engine_cursor` | the same, with your own tool traffic left out | | `mcp` | held lines recording your own tool calls | | `counts` | lifetime `errors` and `warnings`, which survive eviction | | `by_level` | lifetime count per severity | | `by_type` | count per subsystem | | `by_entity` | count per entity, for the lines a script logged | | `repeated` | the most-repeated message templates, most frequent first | `by_type`, `by_entity` and `repeated` are computed over the lines the filter selects, bounded by `limit` (default 2000). The lifetime counts and the ring figures come from the engine's own counters and are not bounded that way. `cursor` is what makes incremental reading work: read it before an action, hand it back as `since` afterwards, and you see only what that action logged. `engine_cursor` excludes your own calls, so it stands still on an engine whose loop has stopped, however many times you poll it — which `cursor` does not, since the act of asking is itself logged.
▲ 0↑ born
·
tool · born here
❒asset
# tail The most recent lines the engine logged, any level, oldest first — so the last line is the newest. The view for when you do not yet know what you are looking for. Once you do, **search** narrows it. Takes the same filters as **search**, `origin`, `caller`, `context` and `order` among them. `limit` defaults to 50 and the order is chronological. Its lines are never grouped, so `group` is refused rather than ignored. Returns the same fields.
▲ 0↑ born
·
tool · born here
❒asset
# probe.cancel Take a probe off the running code, or take all of them off. ```lua probe.cancel("prb_1") probe.cancel("all") ``` Detaching restores what the probe replaced: a wrapped function is put back, a patched line is unpatched, a per-frame read stops. Nothing about a probe survives the engine stopping, so a forgotten one costs only this session. It is still worth cancelling: a probe still armed on a hot path is still doing work, and a line probe holds its function out of native code until that script reloads.
▲ 0↑ born
·
tool · born here
❒asset
# probe.hits The detail behind the notices. A notice is the headline: what happened and the value your body returned. This is what stands behind it — each hit's value, the frame and time it fired on, and the context it saw. Reach for it when a hit carries more than fits in a line, or when you want the sequence rather than the latest. ```lua probe.hits("prb_1") ``` Draining empties the record, so a second call reports only what is new. The record is bounded and holds the most recent hits, not every hit ever taken — for a full history, have the body write one.
▲ 0↑ born
·
tool · born here
❒asset
# probe.list What is armed, what it is attached to, and what it has seen. Each row carries the probe's id and label, its source, the notice text it posts, whether it is still armed, and its counts: hits taken, hits the cooldown held back, and body errors. A probe that has stopped carries why it stopped. `caller` is the caller that armed the probe. Its notices go to that caller, whoever's code trips it; a probe armed with no caller in scope has no `caller`, and its notices go to every caller. ```lua probe.list() probe.list(true) -- only the ones still firing ``` `suppressed` is the one to read on a busy target. The cooldown holds hits back rather than dropping them silently, so a probe on a per-frame function never leaves you believing it fired only as often as it spoke.
▲ 0↑ born
·
tool · born here
❒asset
# probe.onCall Fire when a named function runs, and see both what went in and what came out. `path` is a module identity and a field on it — `modules.combat.applyDamage`. The probe replaces that field with a wrapper that calls through, so it follows the function rather than the file, and a caller reaching it by any route is seen. Cancelling puts the original back. The context carries `args` (a list, in order) and `ret` (the first returned value), so "it fired and produced this" is one condition rather than a filter written inside the body. ```lua probe.onCall("modules.combat.applyDamage", { notice = "a hit killed something", when = "ret.killed", run = "return ret.target .. ' at ' .. tostring(ret.hp) .. 'hp'", }) ``` The call always happens. The probe observes it and never decides whether it runs, so a body that throws cannot take the program with it. A function that is not a field on a required module — a local inside a module, a helper a component keeps to itself — cannot be named this way; use `onLine`. Globals are sealed read-only and cannot be wrapped at all.
▲ 0↑ born
·
tool · born here
❒asset
# probe.onChange Fire when a value becomes different from what it was. Reads the expression once per frame and fires on the transition, so it reaches anything the engine will evaluate — a component field, a light's intensity, a transform's position, a table lookup — without that value needing to publish an event of its own. ```lua probe.onChange("entity.find('Lamp').component.get('Light').intensity", { notice = "the lamp got bright", when = "value >= 5", run = "return value", }) ``` The context carries `value` and `previous`, so a probe can report the step as well as the destination. Pair it with `when` to name the value you are waiting for rather than every change on the way there: the example fires the first time intensity reaches five, not on each increment toward it. **It samples once per frame.** A value that changes and changes back inside one frame reads as no change at all, and one held for a frame or two is an edge it may catch going up and miss coming down. When what you are chasing is that short-lived, probe the CODE that sets it with `onLine` instead: a line fires every time it runs, whatever the frame rate. The value at arm time is the baseline, not a hit — a probe that fired on arming would report the state you already knew. An expression that cannot be evaluated yet (an entity not spawned, a component not added) is not a change; it becomes one when it starts answering.
▲ 0↑ born
·
tool · born here
❒asset
# probe.onLine Fire when execution reaches a line, without stopping it. This is the target that reaches code no name can address: a local inside a module, a helper a component never exported, a branch you want to know is taken. `path` is the script's chunk name, VFS path, or require identity, and `line` snaps to the next executable line. ```lua probe.onLine("Ticker", 9, { notice = "score got big", when = "doubled >= 6", run = "return locals.doubled", }) ``` The world is not stopped. The line runs on, and the body sees the frame it was in: `locals` and `upvalues` are that frame's, read at the moment of the hit. **Where to put a comparison.** `when` is evaluated inside that frame, so it reads the frame's own variables by their own names and with their own types — `doubled >= 6`. `locals` in the body is that frame rendered as text, which is what you want for reporting and not what you want for arithmetic. Compare in `when`, report from `locals`. A hit whose condition does not hold never reaches the body at all. Set one on a script that has not loaded yet and it waits, then installs itself when the script loads. **The cost worth knowing.** An unarmed line costs the virtual machine nothing, but a breakpoint drops the function containing it out of native code until that script reloads, and cancelling the probe does not bring native code back. On a function that runs every frame that is a real cost, so cancel when you are done rather than leaving it armed.
▲ 0↑ born
▣
module · born here
❒asset
# probe.shared The probe registry, and the one path a hit takes to reach you. The three arm verbs attach by three different mechanisms — a wrapped function, a patched line, a value read each frame — and then all hand the hit to `M.fire`. The condition, the limit, the cooldown, the body and the notice live there and nowhere else, so a hit reads the same whichever verb armed it and a change to how probes report is a change in one place. ## Surface | Function | Answers | |---|---| | `M.register(kind, source, opts)` | A new probe record, or `nil, error`. Refuses without `opts.notice`. | | `M.fire(probe, ctx)` | Takes one hit. Returns whether the world should freeze here. | | `M.cancel(id)` / `M.cancelAll()` | Detach and forget, by whatever mechanism attached. | | `M.all()` / `M.get(id)` | The registry, sorted by id / one probe. | | `M.row(probe)` | One probe as a `probe.list` row. | | `M.drain(probe)` | The recorded hits, emptying the ring. | ## What a mechanism owes the registry Two things, and the registry handles the rest. 1. A `source` string at registration: what this probe is attached to, in the probe's own words. It is written here rather than by the agent, because which of several armed probes fired is exactly what the agent cannot supply about its own probe. 2. A `detach` function on the probe record, so `cancel` is one path no matter how the probe attached. ```lua local shared = require(".shared") local probe, err = shared.register("line", "Ticker:9", opts) if probe == nil then return { ok = false, error = err } end probe.detach = function() debugger.removeBreakpoint(bpId) end -- ...and at the moment of the hit: shared.fire(probe, { locals = debugger.getLocals(1) }) ``` ## What `fire` guarantees - `when` is tested first, so a filtered hit costs nothing but the test. - The cooldown suppresses rather than drops silently: suppressed hits are counted and reported in `probe.list`. - The body runs inside a protected call. Three consecutive errors disarm the probe and say so, because a body that throws every time is not reporting anything, it is only costing the frame. - Whatever the body returns is what the notice carries. A table becomes the values, a string becomes the line, nothing still reports the hit. - Reaching the limit disarms the probe and posts a final notice naming that it stopped. A probe that goes quiet without saying so is worse than one that never fired, because silence reads as "it never happened". ## Compiling `when` and `run` are compiled once, at arm time, so a bad snippet is an error the agent sees while arming rather than a silence it discovers much later. Both see the hit's context unpacked as bare names — `args`, `ret`, `locals`, `upvalues`, `value`, `previous`, `entity`, `component`, `frame`, `time`, `hit`, `probe` — so a condition reads `ret.killed` rather than `ctx.ret.killed`.
▲ 0↑ born
▣
module · born here
❒asset
# yaml.module YAML decode + encode for authored engine content. Pure Luau, no engine dependencies — a general parsing library, not data-system plumbing. ```luau local Yaml = require("@builtin::modules.yaml") local doc = Yaml.decode(vfs.read(path)) vfs.write(path, Yaml.encode(doc)) ``` ## Supported subset - Block mappings (`key: value`) and block sequences (`- item`), nested to any depth. - Compact sequence-of-mapping entries (`- path: x` / ` kind: y`). - Flow collections — `{ a: 1, b: 2 }` and `[1, 2, 3]` — single line. - Plain scalars with type inference: `~` / `null` → nil, `true` / `false` → boolean, numeric literals → number, everything else → string. - Single- and double-quoted strings (`''` escapes a literal quote inside a single-quoted string; `\n` `\t` `\r` `\\` `\"` inside a double-quoted one). A quote opens a quoted scalar where a scalar begins — after `key:`, after a `- ` entry marker, or inside a flow collection — so a plain scalar carries an apostrophe as data (`note: the world's rules`). Quoted keys are read in flow mappings. - `#` comments — honored outside quotes, so a `#` inside a quoted string is kept as data. - Literal (`|`) and folded (`>`) block scalars — the bare indicators only. A block scalar's content is literal text: quotes (balanced or not), `#`, `key: value` and `---` inside it are data. - An optional leading `---` document marker. ## Loud-error contract Constructs outside the subset above raise instead of misparsing: anchors/aliases (`&`, `*`), tags (`!`), directives (`%`), multi-document streams (a second `---`), block-scalar chomping/indentation indicators (`|-`, `|+`, `>-`, `|2`, ...), tab indentation, and inconsistent indentation (both block structure and block-scalar bodies). Every error carries the offending line number (`yaml: line N: ...`), so a bad config points straight at the line to fix. Tab indentation is rejected everywhere — including block-scalar body lines whose leading whitespace contains a tab. A tab after the first non-space character of a line is content and passes through. ## API - `Yaml.decode(text: string): any` — decode a YAML document into a Luau value (table, scalar, or nil for an empty document). Raises on malformed input or an unsupported construct. - `Yaml.decodeWithComments(text: string): (any, boolean)` — decode as `decode` does, and report whether the text carries a comment by the decoder's own rule: a `#` at a line's start or after whitespace, outside a quoted scalar and outside a block scalar. Re-encoding the value drops such comments, so an editor that writes a document back reads this first. - `Yaml.encode(value: table): string` — encode a Luau table as YAML (block style, two-space indent, alphabetically sorted keys). Raises on values YAML can't represent (functions, userdata, non-string mapping keys). A top-level empty table encodes to an empty document, which decodes back to `nil` (the YAML empty-document ambiguity).
▲ 0↑ born
·
agentskill · born here
❒asset
# interfaces The screen-building skill: author a UI as a styled widget tree the way you write HTML and CSS, register it, and then see it and drive it through the `gui` toolbox rather than reasoning about the tree. Covers the layout and paint model, entrance and idle animation, callbacks that fire in play mode, and the build → capture → play → iterate loop that gets a screen from blank to built.
▲ 0↑ born
▣
module · born here
❒asset
# assetType runtime The machinery that reads a `<typename>.assetType/behavior.luau` and turns its declarations into live behaviour. A `behavior.luau` is a table of declarations — `ref` methods, `modules` shared code, an `events` schema, a `namePattern`, `refShapes`, and the `onCreate` / `onRegister` / `onChange` / `onDelete` / `validate` / `settingsDefaults` / `settingsCorrections` hooks. None of it runs itself. This is the code that runs it, and it lives here because reading a type's declarations is the **assetType type's own behaviour** — the same way `material.assetType` owns what a `.material` does. ## Sub-modules | Module | Reads | Responsibility | |---|---|---| | `ref.module` | `ref`, `modules` | Builds every `AssetRef` envelope, attaches the shared metatable, and dispatches per-type methods and shared modules onto it. Also owns edit-mode write-behind persistence. | | `create.module` | `onCreate`, `namePattern`, `validate` | Backs `asset.create`: resolves the type, checks the name against its pattern, runs `onCreate` (or clones `template/`), and writes the instance. `validate.module` beside it checks a creation `opts` table against the type's `createSchema`. Before running `onCreate`, resolves the type's settings chain (below) and hands the result to the hook as `opts.settings`. | | `settings.module` | `settings`, `settingsDefaults`, `settingsCorrections` | A type's declared settings schema and where its values live (`type.yaml`'s `settings:` block). `Settings.resolveForCreate` layers the schema's own defaults, the type's own `settingsDefaults(name, opts, asked)` hook (a DEFAULT the schema can't express — a name-derived convention, a fact read off a payload the caller handed it, a value following a field `asked` shows a higher layer naming; any later layer overrides it), the Preset Manager, an importer's settings, the caller's `settings` table, then the type's own `settingsCorrections(values, name, opts)` hook (a CROSS-FIELD CONSTRAINT the schema can't express, applied last over the fully merged values). A correction over a default/preset/importer value lands silently; a correction that would override what the caller's own `settings` table explicitly asked for refuses the creation instead, naming the field and why. Neither hook is ever handed a table to mutate; each returns what it wants changed (`settingsCorrections` may also return a `{ [field]: reason }` table for that refusal message). `Settings.cloneValues` deep-copies a values table — `create.module` hands `onCreate` a copy, never the table it stamps. `Settings.valuesOf` / `writeValues` read and write an asset's own values file. | | `typeYaml.module` | `type.yaml` | The folder a type lives in and its parsed `type.yaml`, decoded once per content version of the file. `settings.module` and `inspector.module` read their blocks through it. `about` / `aboutAt` read a type's `about.yaml` (`intent`, `function`, `usage`), leaving out any key that is empty or still starts with `[[describe]]`; `aboutRows` and `aboutMarkdown` lay the texts out for the Inspector and the `types/<name>` guide. | | `inspector.module` | `type.yaml`'s `inspector:` block | Which inspector a type declares for its assets (`inspector: { type: ... }` or `{ instance: ... }`), and the declaration that file returns — the sections it adds, the generic ones it replaces, and their order — or the problem that kept it from loading. | | `onRegister.module` | `onRegister` | Fires an instance's once-only registration hook — on arrival, on world load, and for `@builtin` library instances. | | `changeDispatch.module` | `onChange`, `onDelete`, `refShapes` | Routes a VFS source write or a folder delete to the enclosing typed asset's type hooks. | | `refShapes.module` | `refShapes`, `ref` | Publishes what every `AssetRef<category>` answers to, so a member read on an asset-typed value is checked against that category's real surface. | | `events.module` | `events` | The per-asset event runtime behind `ref.events`. | | `instantiable.module` | `ref.instantiate` | The instantiation contract an asset type opts into: `root` stands the root entity, `place` applies the base placement opts to one the type adopted, and `result` shapes the `(root, idMap)` every `instantiate` returns. Also registers the `sceneInstantiable` field-constraint validator. | | `declaration.module` | `type.yaml` | The type's decoded declaration, read once and held until a write inside an `.assetType` folder; what every question about a type as a whole reads. | | `previewRecipe.module` | `type.yaml` `preview:` | How an instance's `preview.png` is produced: which of the four recipes (`instantiate`, `image`, `surface`, `custom`) the type declares, and what that recipe needs. | ## Reaching it ```luau local rt = require("@builtin::assetTypes.assetType.shared") rt.ref.loadTypeBehavior("material") ``` Fields resolve lazily. The prelude requires the sub-modules directly, in dependency order (`ref`, then `changeDispatch`, `onRegister.install()`, `refShapes.install()`) — a table that required all six on load would take that ordering away from it.
▲ 0↑ born
backing path · skills/debugging.agentSkill

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.