githubnext/chopinPublic

Let's compose rich plans together

Report what an agent edit wrote, moved and took out

The edit engine already knew all of this and threw it away. A batch is
reconciled by object identity, so a block the agent wrote is simply one
the reconciler did not carry through — which makes what was written free
to report and impossible for the agent to misstate.

What moved or went cannot be had the same way. A node missing from the
result may have been deleted or replaced, and a node at a new index may
have moved or merely been pushed down by an insert above it. Both come
from the operations instead, which say exactly; a batch aborts on the
first one that fails, so by the time this runs every one of them applied.

Indices become anchors in the service rather than here, because only the
live document knows where a block sits in the collaborative history, and
only an anchor survives somebody else typing between the frame being sent
and the browser painting it.

A block that has gone cannot be anchored at all, so the space it left is
named by a block still beside it and the side the content was on. That
the plan can never be emptied is what guarantees one exists.
KCKrzysztof Cieslak authored committed by Krzysztof Cieślak
e140486Patch
Parent1124949
7 files changed+522-2
StackedSplit
apps/server/src/agent/tools.ts+8 −0
apps/server/src/chat/service.ts+1 −0
apps/server/src/plan/anchors.test.ts+78 −0
apps/server/src/plan/edit.test.ts+147 −0
apps/server/src/plan/edit.ts+173 −2
apps/server/src/plan/service.ts+68 −0
packages/protocol/plan.d.ts+47 −0