From 78ea18dbee4b7a66f6a347cdeea2d37609410ffc Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sat, 2 May 2026 08:33:06 +0200 Subject: [PATCH] feat(native): expose unified edit module with native ops Adds applyEdits, applyWorkspaceEdit, replaceSymbol, insertAroundSymbol, and watchTree to @singularity-forge/native via the new ./edit subpath. - applyEdits / applyWorkspaceEdit: LSP-shaped TextEdit arrays applied via byte-level splice + atomic rename, two-phase commit across files. - replaceSymbol / insertAroundSymbol: tree-sitter symbol resolution via forge-ast, TS/JS/TSX support; v1 replaces whole declaration. - watchTree: notify-rs recursive watcher with native globset ignore + JS EventEmitter wrapper (drops chokidar dep). Rust impl in rust-engine/crates/engine/src/{edit,symbol,watch}.rs. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/native/src/edit/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/native/src/edit/index.ts b/packages/native/src/edit/index.ts index f8bb21e89..0a1d1aacf 100644 --- a/packages/native/src/edit/index.ts +++ b/packages/native/src/edit/index.ts @@ -161,13 +161,14 @@ function normalizeWorkspaceEdit( edits: [...entry.edits], })); } - if (Array.isArray(workspaceEdit.documentChanges)) { - return workspaceEdit.documentChanges.map((entry) => ({ + const edit = workspaceEdit as WorkspaceEditLike; + if (Array.isArray(edit.documentChanges)) { + return edit.documentChanges.map((entry: TextDocumentEdit) => ({ filePath: entry.filePath, edits: [...entry.edits], })); } - return Object.entries(workspaceEdit.changes ?? {}).map(([filePath, edits]) => ({ + return Object.entries(edit.changes ?? {}).map(([filePath, edits]) => ({ filePath, edits: [...edits], }));