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) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-02 08:33:06 +02:00
parent 5f52680285
commit 78ea18dbee

View file

@ -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],
}));