Portable targets: document session + edit API (S1, full-reparse fallback)#61
Merged
Conversation
Introduce document session + edit API for ts/go/rust portable targets with text splice and full re-tokenize/parse, plus edit-session runner protocol and gate coverage for calc and javascript. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First slice of #57: all three portable targets (TS/Go/Rust) gain a document session +
editAPI. The API shape is now fixed; later slices swap the internals for true incremental reuse without touching the interface.createDoc(src)→{ text(), root(), edit(edits) }withEdit = { start, end, text }Docstruct +NewDoc / Text / Root / EditDocholds the ownedString;editsplices text,parse()borrows on demand (sidesteps theParser<'a>self-reference)(start, end, text)replaces[start, end); edits apply sequentially; offsets in each target's native CST offset unitstokenize/parse(full re-parse — no incremental reuse in this slice, by design); existing lexer/parser function bodies are append-only unchangededit-sessionmode ({init, batches}JSON on stdin, same CST JSON output), so the gate can adjudicate sessionsValidation
test/portable-targets.ts: 8 scripted edit scenarios (insert/delete/replace/multi-batch, including same-batch offset chaining) × 3 targets — alledit-session ≡ fresh parse of final textbyte-identical + oracle parity; all existing accept/reject counts unchangednode test/check.ts emit-parity— 5/5npx tsc --noEmit— cleanPart of #57 (S1 of the slicing plan; S2+ — windowed relex, arena persistence, adoption — tracked separately).