@codemirror/merge

A diff and merge view extension for the CodeMirror 6 code editor

Library
npm
v6.12.2
105 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
35 /100 Needs Attention
Development Activity 8
Maintenance 0
Community 60
Maturity 52
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 85
Code Quality 82
Innovation 74
Learning Curve 65

@codemirror/merge is the official CodeMirror 6 extension for rendering diffs and merge interfaces inside the editor. It ships two view modes: a split MergeView that shows two documents side-by-side with connecting diff decorations, and a unifiedMergeView that inlines changes into a single editor pane in the style of a unified diff. Both build on CodeMirror’s @codemirror/state and @codemirror/view extension system, so diff decorations, gutters, and change-navigation commands compose with the rest of a CodeMirror configuration rather than requiring a separate widget.

The package is maintained by Marijn Haverbeke as part of the core CodeMirror 6 project family. Its canonical source lives on the project’s self-hosted Fossil server (code.haverbeke.berlin), with this GitHub repository serving as a read-only mirror — the standard arrangement for CodeMirror 6 packages, whose actual development, issues, and CI happen off-GitHub even though npm and this mirror stay in sync with each release.

What You Get

  • MergeView: a split two-pane diff view showing document A and document B side-by-side with connecting change decorations
  • unifiedMergeView: an inline single-pane view that renders changes in unified-diff style within one editor
  • A diffing engine (diff.ts) that computes the underlying change set feeding both view modes
  • Gutter markers and decorations (deco.ts, theme.ts) for highlighting inserted/deleted/changed regions consistent with CodeMirror’s theming system
  • Commands for navigating between changes and accepting/rejecting individual diff chunks, composable with standard CodeMirror keybindings

Common Use Cases

  • Building an in-browser code review or PR-diff viewer that needs syntax-highlighted, scrollable diffs rather than a static HTML diff
  • Adding a ‘compare versions’ feature to a documentation or note-taking app built on CodeMirror
  • Implementing an AI-assisted code editor that shows proposed changes as an inline unified diff before the user accepts them
  • Building a collaborative editor’s conflict-resolution UI, letting users see and merge divergent edits side-by-side

Under The Hood

Architecture - The package is organized around two composable view classes built on CodeMirror 6’s extension model: mergeview.ts implements the split MergeView (two linked EditorView instances scroll and highlight in sync), while unified.ts implements unifiedMergeView as a set of extensions layered onto a single EditorView. Both consume a shared diffing core in diff.ts, with chunk.ts modeling the resulting change ranges as CodeMirror-compatible range sets, and deco.ts/theme.ts rendering those chunks as decorations and gutter markers. This mirrors CodeMirror 6’s broader design philosophy: functionality is expressed as composable state fields and view plugins rather than a monolithic widget class. Tech Stack - Pure TypeScript (~1,840 lines across src/), depending on the core CodeMirror 6 packages (@codemirror/state, @codemirror/view, @codemirror/language) and @lezer/highlight for syntax-aware diff rendering, plus style-mod for scoped CSS. Build and test tooling (cm-buildhelper, cm-runtests) is shared tooling used across the whole CodeMirror 6 package family, invoked via the prepare/test npm scripts. Code Quality - A test/ directory exercises the diffing and view logic; because this package is part of the tightly coordinated CodeMirror 6 monorepo family, it follows the same coding conventions, versioning cadence, and API-design review process as the rest of the @codemirror/* scope, even though day-to-day development happens on the project’s own Fossil server rather than GitHub. API Design - Both MergeView and unifiedMergeView accept the same shape of configuration as other CodeMirror 6 view constructors (a document plus an extensions array), so a team already using CodeMirror 6 can add diff/merge rendering with minimal new API surface to learn — the main cost is understanding CodeMirror 6’s extension composition model itself, which this package assumes rather than re-teaches.

Used by 9 apps in this directory

TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 1 weeks ago
Python
62%
Apache 2.0

marimo

Data Engineering · Developer Tools

22,918

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
89
Repo Health
91
Technical
65
Dependency
Built with
Python 62%
TypeScript 37%
Updated 1 weeks ago
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

28,378

"A coding agent that never compacts" — a terminal-based AI coding agent built on the Mastra framework, with Observational Memory instead of context compaction, multi-model support, and OAuth login for Claude Max or ChatGPT Plus.

View details
90
Repo Health
73
Technical
65
Dependency
Built with
TypeScript 99%
Updated 1 weeks ago
Clojure
56%
Other

Metabase

Analytics

49,438

The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.

View details
95
Repo Health
84
Technical
64
Dependency
Built with
Clojure 56%
TypeScript 38%
Updated 1 weeks ago
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,914

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
64
Dependency
Built with
Go 39%
TypeScript 38%
Svelte 21%
Updated 2 weeks ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,195

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 1 weeks ago
TypeScript
98%
Apache 2.0

rowboat

AI Assistants · AI Development

17,983

Build, test, and deploy multi-agent AI workflows with a visual editor, RAG data sources, MCP tool integration, and a production-ready REST API.

View details
85
Repo Health
72
Technical
65
Dependency
Built with
TypeScript 98%
Updated 2 weeks ago
Python
78%
AGPL 3.0

Skyvern

AI Agents · Automation

23,088

Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Python 78%
TypeScript 20%
Updated 1 weeks ago
TypeScript
97%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

3,952

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
85
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 97%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers