Skip to main content

Module edit

Module edit 

Source
Expand description

weave edit: how an agent changes code, addressed by entity.

An edit names a function, class or method and says what becomes of it: replace it, change one piece of text inside it, delete it, or add a new entity before or after it. Text edits without an entity cover everything else (imports, module-level statements, files weave has no grammar for), and an edit to a file that does not exist creates it.

Every edit is resolved against the file as it is on disk now, so nothing has to be read first and nothing another agent changed elsewhere in the file is overwritten. A text edit’s old must match exactly once (or set all), which is what keeps a stale edit from landing somewhere else.

A batch is all or nothing: every edit is planned in memory, in order, and files are written only when all of them resolved.

Structs§

Edit
EditError
Why a batch was refused. Nothing was written.
FileReport
What a batch did to one file, entity by entity.
Report
Then
What the then command did.

Enums§

EntityRef

Constants§

THEN_OUTPUT_CAP
How much of a then command’s output comes back.

Functions§

review_external
Review an edit another tool made (an agent’s own edit or patch tool): for each (file, content before the edit) (None before: the file is new or its content at HEAD stands in), what the edit broke in the parse and which callers a signature change or deletion left behind. Then start the agent’s last test command on the new tree, as after a weave edit.
run
Apply edits under root. With dry_run, plan and report only.
speculate
Start the agent’s last test command on the tree just written, in the background. Agents follow an edit by rerunning the same command after thinking for some seconds; by then this run is done or under way, and sem check --run joins it instead of starting over.
then
Run cmd once the edits are written, so an edit and its check take one call: through sem check --run when sem is installed (it joins the speculative run if there is one), else with sh -c in the repo root. Bounded by [THEN_DEADLINE]; output is kept to its last THEN_OUTPUT_CAP bytes.
version
sem’s entity version: v: + FNV-1a (32 bits) of the source without trailing newlines.