Weave – A language aware merge algorithm based on entities

A new Git merge driver called Weave applies language-aware, entity-level merging to source code, using tree-sitter to understand functions, classes, and methods instead of treating files as plain text lines. Supporters argue this greatly reduces spurious conflicts—especially in multi-agent or AI-assisted workflows where many branches touch the same files—and provides richer tooling via an MCP server for agents to coordinate edits. Others probe its limitations, compare it to tools like Mergiraf and AST-native VCS experiments, and question both the robustness of its heuristics and the promotional tactics used to drive adoption.

Overview & Goals

  • Weave is a Git merge driver that merges code at the level of “entities” (functions, classes, methods) instead of lines.
  • It uses Tree-sitter to parse files, falls back to line-based merge for unsupported languages, and writes normal files back so Git workflows remain unchanged.
  • A key motivation is cleaner merges when multiple changes touch the same file but different entities.

Validation & Adoption Concerns

  • Several well-known Git ecosystem contributors have privately expressed support; some users see this as strong validation.
  • Others question the evidence for demand and worry about promotional tactics (e.g., opening issues on many repos to suggest adoption).
  • There is interest in integrating with other tools (e.g., alternative VCSs, Git frontends), but this is mostly early-stage discussion.

Multi-Agent and AI Workflows

  • Proponents argue entity-level merging is critical when many AI agents edit in parallel, reducing unnecessary conflicts and saving time/tokens.
  • Skeptics say AI can already resolve most textual conflicts and that humans rarely find these conflicts hard anyway.
  • A related idea is moving from “fix conflicts later” to “prevent conflicts” via an MCP server where agents claim entities before editing.

Technical Approach & Alternatives

  • Compared to other Tree-sitter-based tools that match raw AST nodes, Weave groups entire entities, aiming for simpler, faster, more readable conflicts.
  • There’s extensive discussion of storing ASTs (or CSTs) directly in a VCS vs. treating source as blobs; some argue code is already effectively a serialized AST and the real issue is parsers/consumers, not storage.
  • Concerns are raised about languages with preprocessors (C/C++) and significant whitespace (Python); Weave claims best-effort handling with Tree-sitter plus language-specific logic.
  • Structural hashes are used for rename detection; a commenter doubts this will reliably handle more complex refactors.

Language Support & Tooling

  • Current support includes several languages via a shared parser library; Ruby and other languages (Swift, Bash) are requested and described as relatively easy to add through Tree-sitter grammars.
  • C# support exists but is not prominently documented.
  • A separate tool provides entity-level diffs on arbitrary files, and another experimental tool uses entity graphs for PR triage.

Limitations, Risks & Open Questions

  • Weave can still miss purely semantic conflicts (e.g., one change obsoleting another); it reportedly runs post-merge dependency checks to flag some of these.
  • Some argue stricter, more conservative conflict detection might be safer in cases where merging both sides leads to dead code.
  • Performance trade-offs of AST-based approaches, robustness on heavily macro’d code, and behavior during rebases (vs merges) are raised but not fully resolved.