Skip to content

feat(core): port V1 fuzzy edit matching to V2 core edit tool - #32761

Closed
Robin1987China wants to merge 1 commit into
anomalyco:devfrom
Robin1987China:fuzzy-edit-v2
Closed

Robin1987China wants to merge 1 commit into
anomalyco:devfrom
Robin1987China:fuzzy-edit-v2

Conversation

@Robin1987China

@Robin1987China Robin1987China commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

N/A — feat PR (feature PRs skip issue requirement per contributing guidelines)

Type of change

  • New feature

What does this PR do?

Ports 9 fuzzy replacer strategies from V1 (packages/opencode/src/tool/edit.ts) to V2 core (packages/core/src/tool/edit.ts), plus Levenshtein distance, similarity thresholds, and the disproportionate-match safety guard.

The V2 core edit tool currently only supports exact string matching. This change adds fuzzy fallback strategies tried in order after exact match fails: line-trimmed, block-anchor (Levenshtein similarity), whitespace-normalized, indentation-flexible, escape-normalized, trimmed-boundary, context-aware, multi-occurrence.

How did you verify your code works?

  • bun turbo typecheck: all 29 packages pass
  • bun test test/tool-edit.test.ts: 19/19 tests pass (9 existing + 10 new)
  • New tests cover each fuzzy strategy plus edge cases

Screenshots / recordings

N/A (non-UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@Robin1987China

Copy link
Copy Markdown
Contributor Author

Note: This is a feat PR, which skips the issue-link requirement per the contributing guidelines. The originally linked issue #32760 was auto-closed by the compliance bot (it didn't use an issue template). I've removed the stale link to avoid confusion. Happy to open a feature-request issue if the team prefers one for tracking.

@Robin1987China

Copy link
Copy Markdown
Contributor Author

Closing — this was a large feat PR in a hot area that didn't follow issue-first. Will re-approach after upstream design discussion if there's interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant