# Debug commands of @ferret/ferretic, @ferret/inspector, @ferret/core

Call with `world.commands.execute(name, args)`; `world.commands.list()` on the running game is the authority. Read from the sources of these packages.

- `probe.color` — the mean colour (0..255), the contrast (0..1) of the frame and, with {reference: a data URL}, the mean absolute difference from it (0..1, when the sizes match): {reference?} -> {size, mean, contrast, difference?}
- `probe.count` — how many entities have a tag, the name (or name prefix) or a component class: {what} -> {what, count}
- `probe.errors` — what the page reported as an error since the probes were made (console.error, uncaught errors, rejected promises, game:error): {} -> {count, errors}
- `probe.ground` — how high the lowest point of a thing is over what lies under it: {name, tolerance? (0.05 m)} -> {onGround, height (m; negative when sunk into it; null when nothing is there), over (mesh name)}
- `probe.view` — is a thing in the camera's view: {name} -> {inView, inFrustum, share (of the frame, 0..1), visible (share of sample points seen past other things, 0..1), occludedBy (mesh name or null), distance}
- `test.check` — read a Ferretic program without running it: {source} -> {ok, error: {line, col, message}, routines, runs}
- `test.help` — the Ferretic language on one page
- `test.list` — every test of this game run so far: [{id, name, status, runs}]
- `test.rows` — rows of a test's table, page by page: {id?, table: samples | log | prints | failures, offset? (0), count? (the rest), run? (with RUNS: which run, 1..n; default the last)} -> {id, table, total, offset, rows, columns?}
- `test.run` — play the game by a Ferretic program (test.help: the language): {source, name?, runs?, timeout? (game seconds; none unless given), keepRunning?, wait? (true), seed?} -> the report: id, status, expectations, failures (their number and the first), log (the last value of each name), runs and summary with RUNS, and the size of each table (samples, log, prints, failures) to read with test.rows. Any number of tests may run at once. The game is paused at the end unless keepRunning. A project file: {file} through the editor.
- `test.shot` — a picture a test took with SHOT: {name?, id?} (default: its last picture) -> the image
- `test.state` — a test's report so far (status running while it runs): {id?} (default: the last started)
- `test.stop` — stop a running test: {id?} (default: the last started) -> its report (status stopped)
- `anim.graph` — the graph state of an entity: {entity} -> state, parameters, montages
- `anim.list` — animation groups of the scene, or of an entity's Animator: {entity?}
- `anim.montage` — play a one-shot clip on an entity: {entity, clip, mask?, blendIn?, blendOut?, loop?}
- `anim.play` — play a clip on a model or entity, outside any graph: {group, clip, loop?: true, speed?: 1}
- `anim.scrub` — show a clip at a time on a model, with the graph not driving it: {group: model/entity name, clip, time}
- `anim.set` — set graph parameters or fire a trigger: {entity, params?: {name: number|bool}, trigger?}
- `anim.stop` — stop a clip started with anim.play: {group}
- `asset.list` — models loaded with asset.load
- `asset.load` — load a glTF/GLB into the scene: {url, name?, position?, scale?} -> the model's nodes and clips
- `asset.remove` — remove a model loaded with asset.load: {name}
- `camera.get` — the active camera
- `camera.set` — move the camera: {position?, target?, fov?, radius?, alpha?, beta?}
- `camera.view` — named view of the scene or a node: {name: "front"|"back"|"left"|"right"|"top"|"iso"|"fit", node?, margin?}
- `input.actions` — the actions the game binds: [{name, kind, bindings: {keyboard|gamepad|touch: [...]}}]
- `input.hold` — press actions as a player would, hold them for `seconds` of game time, then let go: {actions: [{action, down?: true, x?, y?}], seconds?: 0.5 (max 30)} or one {action, down?, x?, y?, seconds?}. A button is down:true; an axis takes x (-1 left … 1 right) and y (-1 … 1, up/forward is usually +1 or -1: read the game). Several actions are held together (reverse and turn at once). Returns after the hold, with each action's value. Look at the result with screenshot and scene.node / scene.entities afterwards.
- `input.release` — let go of every action input.hold still holds: {}
- `physics.bodies` — the rigid bodies of the physics host: [{entity, node, kind, shape, mass, material, position, speed}], with the level's constraints and fractured bodies
- `record.pause` — pause the recording
- `record.resume` — resume a paused recording
- `record.start` — start recording the scene: {fps?, audio?, videoBitsPerSecond?} -> {mime, audio}; audio is false while the sound is still locked
- `record.state` — the recorder: {state: idle|recording|paused, elapsedMs, supported}
- `record.stop` — end the recording: {dataUrl?: false to leave the file out} -> {mime, bytes, durationMs, audio, dataUrl}
- `scene.bounds` — world bounds of the scene or of one node and its children: {node?}
- `scene.entities` — list entities: {tag?, name?} -> id, name, position, components
- `scene.exportStep` — the visible meshes (or one node and its children) as a STEP file for CAD (ISO 10303-21, AP214): an assembly, one faceted part per mesh, world coordinates, Z up: {node?, name?, units?: "mm"|"m", hidden?, maxTriangles?} -> {file, text, bytes, parts, solids, surfaces, triangles, skipped}
- `scene.node` — details of one node: {name} -> transform, bounds, material, skeleton
- `scene.nodes` — list scene nodes: {filter?, kind?: "mesh"|"transform"|"light"|"camera", limit?}
- `scene.stats` — counts and frame stats
- `scene.validate` — check the level: meshes without collision, without material, nodes with bad transforms, skeletons without animation
- `view.set` — debug views: {wireframe?, bounds?, skeletons?, colliders?, triggers?} -> current flags
- `commands.list` — every command of this world: -> [{name, description}]
- `game.values` — the values the game exposes to tests and tools (world.expose): {names?: [..]} -> {name: value}
- `host.show` — show a world by name ("main" or one a game created): {name}
- `host.worlds` — the worlds on the shared engine and which one is shown
- `perf.bound` — which side holds the frame: -> {by: cpu|gpu|?, frameMs, gpuMs}
- `perf.enable` — switch the frame profiler on or off: {on} -> enabled
- `perf.report` — where a frame goes, ms a frame by system, the most expensive first: {top?, prefix?} -> {frameMs, frameWorst, rows, own}; `own` is what the game's own code costs in the game's thread, by function, with what would take each off it
- `perf.reset` — clear the profiler
- `perf.trace` — the recorded frames, long tasks and marks: -> {frames, longTasks, marks, done} or null
- `perf.trace.start` — record every frame for a while (the start of a game): {seconds?, minMs?}
- `quality.auto` — switch the regulator on or off: {on} -> on
- `quality.preset` — every knob at a share of its range: {share 0 (richest) .. 1 (cheapest)}
- `quality.report` — the quality regulator: target, measured frame, which side holds it, the knobs and the last decisions
- `quality.set` — put a knob at a level and keep it there ({id, level}), or give it back to the regulator ({id, auto: true})
- `quality.target` — the flat-screen frame rate to hold: {hz}
- `scheduler.info` — the system scheduler: workers, declared kernels, registered kernels, counts: -> {threads, pooled, declared, registered, stats}
- `snapshot.audit` — reads of fields the snapshot spec does not declare (needs the replica made with audit on)
- `world.info` — time, tick count, entity and service counts
- `world.pause` — pause or resume the simulation: {paused}
- `world.step` — run n fixed steps (use while paused): {n}
- `world.timeScale` — set the time scale: {scale}
