@codemirror/merge

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

Library
npm
v6.12.2
105stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity12
Maintenance0
Community60
Maturity52
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture85
Code Quality82
Innovation74
Learning Curve65

@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,055

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
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

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
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today
TypeScript
99%
Apache 2.0

Mastra Code

AI Code Assistants

27,294

"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
88
Repo Health
73
Technical
66
Dependency
Built with
TypeScript99%
Updated today
Clojure
54%
Other

Metabase

Analytics

48,828

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
65
Dependency
Built with
Clojure54%
TypeScript40%
Updated today
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,817

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
88
Repo Health
88
Technical
68
Dependency
Built with
Go39%
TypeScript37%
Svelte22%
Updated today
Rust
67%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,065

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
66
Dependency
Built with
Rust67%
TypeScript29%
Updated today
TypeScript
98%
Apache 2.0

rowboat

AI Assistants · AI Development

17,323

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
TypeScript98%
Updated today
Python
76%
AGPL 3.0

Skyvern

AI Agents · Automation

22,785

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
71
Dependency
Built with
Python76%
TypeScript22%
Updated today
TypeScript
98%
Other

Sourcebot

Search · Developer Tools · AI Code Assistants

3,892

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
86
Repo Health
83
Technical
67
Dependency
Built with
TypeScript98%
Updated today

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

Search