Automattic Harper Dependencies: Complete Guide to the Rust Workspace Architecture
Harper is organized as a Cargo workspace containing over 20 specialized crates that depend on high-performance Rust libraries including fst for finite-state transducers, pulldown-cmark for Markdown parsing, and tower-lsp-server for LSP functionality, with each crate's dependencies defined in its respective Cargo.toml manifest.
Understanding the Automattic Harper dependencies requires examining its distributed workspace structure rather than a single package manifest. This grammar-checking engine separates concerns across multiple crates—from core text processing to WebAssembly bindings—with each component declaring specific external libraries optimized for tasks like spell-checking, parsing, and asynchronous communication.
Workspace Structure and Dependency Organization
The root Cargo.toml establishes a shared versioning scheme and enables intra-workspace linking by declaring all member crates. This workspace definition ensures consistent dependency resolution across the entire project while allowing individual crates to specify only the libraries they require.
Workspace Members
The root manifest defines the following components as workspace members:
harper-cliharper-coreharper-lsharper-commentsharper-wasmharper-tree-sitterharper-htmlharper-literate-haskellharper-typstharper-statsharper-pos-utilsharper-brillharper-inkharper-pythonharper-jjdescriptionharper-thesaurusharper-asciidocfuzzharper-texharper-desktop/src-tauriharper-git-commit
Source: Root Cargo.toml
Core Engine Dependencies in harper-core
The harper-core/Cargo.toml file defines the heart of the language-checking engine. This crate pulls in specialized libraries for finite-state transducers, Unicode handling, and efficient data structures.
Text Processing and Parsing Libraries
pulldown-cmark(0.13.3) — Markdown parsing engineregex(1.12.3) — Regular expression engine for pattern matchingammonia(4.1.2) — HTML sanitization utilitieslevenshtein_automata(0.2.1 withfst_automatonfeature) — Approximate string matching for spell-checking suggestions
Data Structures and Performance
fst(0.4.7) — Finite-state transducers enabling fast spell-checking operationshashbrown(0.16.1 withserdefeature) — High-performance hash maps and setstrie-rs(0.4.2) — Trie data structures for efficient prefix matchingsmallvec(1.15.1 withserdefeature) — Stack-allocated vector optimization to reduce heap allocationslru(0.18.0) — LRU cache implementationcached(0.59.0) — Memoization utilities for expensive computationsfoldhash(0.2.0) — Fast hash implementation
Serialization and Error Handling
serde/serde_json(1.0.228 / 1.0.150 withderivefeature) — Data serialization and deserializationthiserror(2.0.18) — Derive macro for standard error implementationsbitflags(2.11.0 withserdefeature) — Type-safe bit-flag handlingstrum/strum_macros(0.28.0) — Enum utility macros
Unicode and Text Utilities
unicode-blocks,unicode-script,unicode-width— Unicode classification and width calculationordered-float(5.3.0 withserdefeature) — Ordered floating-point value wrappers
Internal Workspace Dependencies
harper-brill(path dependency, version 2.0.0) — Brill-tagger integration for part-of-speech taggingharper-thesaurus(optional, path dependency, version 2.0.0) — Synonym lookup when thethesaurusfeature is enabled
Source: harper-core/Cargo.toml
Language Server and CLI Dependencies
harper-ls (Language Server Protocol)
The harper-ls/Cargo.toml extends the core engine with LSP capabilities using async Rust:
tower-lsp-server(0.22.1) — LSP protocol implementationtokio(1.52.1) — Asynchronous runtime with selected featuresclap(4.6.0) — Command-line argument parsingdirs(6.0.0) — Platform-specific directory resolutionanyhow(1.0.102) — Flexible error handling and context propagationtracing/tracing-subscriber— Structured logging and telemetryresolve-path,open,futures,globset— Path resolution, file opening, async utilities, and glob pattern matching
This crate also maintains path dependencies to other workspace members including harper-stats, harper-comments, and harper-typst.
Source: harper-ls/Cargo.toml
harper-cli (Command Line Interface)
Located in harper-cli/Cargo.toml, the CLI frontend uses:
clap— Command-line interface generationanyhow— Error handlingserde_json— JSON output formattingharper-core— Core engine integration
Source: harper-cli/Cargo.toml
Platform-Specific Dependencies
WebAssembly Support (harper-wasm)
The harper-wasm/Cargo.toml configures the WebAssembly wrapper with:
wasm-bindgen— JavaScript bindings generationjs-sys— JavaScript global bindingswee-alloc— Lightweight WebAssembly allocator
Source: harper-wasm/Cargo.toml
Desktop Application (harper-desktop)
The Tauri backend defined in harper-desktop/src-tauri/Cargo.toml combines:
tauri— Desktop application frameworkserde— Configuration serializationanyhow— Error propagationharper-core— Text checking engine integration
Source: harper-desktop/src-tauri/Cargo.toml
Inspecting the Dependency Graph
You can analyze the Automattic Harper dependencies using Cargo's built-in tooling. Run these commands from the repository root to visualize the dependency tree:
# Display the complete dependency tree for the entire workspace
cargo tree --all-features
# Show dependencies for only the core engine
cargo tree -p harper-core --all-features
# Inspect LSP server dependencies with specific features enabled
cargo tree -p harper-ls --features concurrent,thesaurus
These commands reveal how external crates like fst and pulldown-cmark integrate with workspace members such as harper-brill and harper-thesaurus.
Summary
- Harper uses a Cargo workspace with over 20 member crates, each with targeted dependencies defined in individual
Cargo.tomlfiles. - The core engine (
harper-core) relies onfstfor finite-state transducers,pulldown-cmarkfor Markdown parsing, andlevenshtein_automatafor spell-checking suggestions. - Async dependencies including
tokioandtower-lsp-serverare isolated to theharper-lscrate for Language Server Protocol support. - Platform-specific crates like
harper-wasmandharper-desktopimport specialized libraries (wasm-bindgen,tauri) while maintaining a common core through path dependencies. - Utility macros such as
thiserror,strum, andbitflagsappear consistently across crates to reduce boilerplate code.
Frequently Asked Questions
What is the primary spell-checking dependency in Harper?
Harper uses the fst crate (version 0.4.7) to implement finite-state transducers for fast dictionary lookups, combined with levenshtein_automata (0.2.1) to generate spelling suggestions based on edit distance. These libraries enable high-performance approximate string matching without loading entire word lists into memory.
Does Harper require an asynchronous runtime?
Only the Language Server implementation requires async support. The harper-ls crate depends on tokio (1.52.1) as its asynchronous runtime and tower-lsp-server (0.22.1) for LSP protocol handling. The core engine and CLI tools operate synchronously without async overhead.
How does Harper manage dependencies across multiple crates?
Harper uses path dependencies to link workspace members together. For example, harper-core declares harper-brill as a path dependency (path = "../harper-brill"), ensuring version alignment across the workspace. External crates are pinned to specific versions in each Cargo.toml to guarantee reproducible builds.
What library handles Markdown parsing in Harper?
The pulldown-cmark crate (version 0.13.3) handles all Markdown parsing operations in harper-core. This pull-parser library processes Markdown text efficiently without building a complete DOM, making it suitable for real-time grammar checking in documents.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →