Definition authoring agent
The definition builder's agent writes and edits one definition: its events, the emits with their labels, what it draws, and every file of a multi-file package. Its edits apply straight to the draft, and the chart beside the chat reloads with each one.
Ask it to mark a setup in history. Measuring what happened after the setup is a study.
How an edit lands
The agent sends a set of file patches with apply_flow_edits: create, replace, delete, or an exact edit of part of a file. Every patch set saves to the draft, even one that does not link or derive; the result names the file and line that failed, and the agent fixes it with another edit. A Files updated message in the chat confirms each one.
The only thing it asks you first is using an indicator from the library, with an Indicator proposal card.
Its loop on every change
Read the definition with
get_flow_stateand its files withget_flow_files.Save the patch set with
apply_flow_edits.Lint with
lint_flowand typecheck withtypecheck_flow. Both read the saved draft. Typecheck is what catches actx.emitof an event id that was never declared, a misspelledctx.params.<id>, or an output id that does not exist.Dry-run with
dry_run_flow: the same pipeline a run over history uses, over a preset market, keeping events in memory.Check the builder's chart with
wait_for_previewandinspect_preview, and readctx.logoutput withget_flow_logs.
It stops after three failed lint attempts on the same problem instead of resubmitting the same edit.
Tools
Tool | Runs in | Does |
|---|---|---|
| Server | The saved definition row |
| Browser | The live draft: every file, its role and which is the entry |
| Browser | Saves a patch set; returns |
| Browser | Links the draft's imports, derives the manifest and lints: |
| Browser | Typechecks against the DSL's real declarations; reads those declarations |
| Server | Runs the saved draft over a preset market. Returns |
| Server | Runs a layer's |
| Browser | Reads what the builder's chart calculated and logged |
| Server, browser | Finds a dependency, its exact accessor keys and version, and asks you to add it |
| Server | Names the definition on your first message, and renames it when its purpose changes |
What it checks before it calls a change done
The entry file has
meta(...)andexport function onBar(ctx); no other file has either. Helpers use relative imports with the extension, such as./lib/levels.js.imports.use({ flowId, alias })is only for another definition's events.meta({ kind: "flow" }), since events are refused onkind: "indicator".Every
ctx.emitnames a declared event and passes a non-emptylabel. Every payload field has atypeand a plain-Englishdescription, because study agents read them.Events are visible unless you asked otherwise: no
paint: "none".Dedupe uses
oncePer: { keys }on the event, never a set kept inctx.accum.Every drawing call has an
outputs.declareof the matching kind. Everyhlineandrangeoutput setsmodeexplicitly;invalidateOnCustomFunctionhas aninvalidateWhen;invalidateOnEventnames declared event ids.Zones or levels an indicator already computes are read from it, through
lifecycle({ outputId, at: ctx.time })for ranges, not rebuilt in the definition.Sessions come from
ctx.session({ period, open, close, tz }), never bar counts or fixed UTC offsets.Nothing emits or draws inside a timeframe handler; one-shot emits gate on
handle.closedThisBar.Every dependency pins the version the search or approval returned.
Asking well
"Emit
or_breakwith the labelOR break ↑when the close crosses the opening-range high, once per session.""Move the classification helpers into
./classify.js; keepmetaandonBarin the entry file.""Add a subtitle with the range in percent and the sample size, two values at most."
Requests it cannot do: publish a study table (use the study builder), skip labels (they are required), or import npm packages (only relative imports work).
