Where Are the Source Files Located in the Automattic/Harper Repository?

The Automattic/harper source files are organized in a monorepo structure with top-level directories for Rust crates and npm workspace packages under packages/.

The Harper spell- and grammar-checking ecosystem is developed as a single Git repository that bundles multiple components—ranging from a Rust core engine to browser extensions and a desktop application. Understanding where the source files live in the Automattic/harper repository helps contributors navigate the codebase, import the right modules, and build specific components.

Rust Components: Top-Level Crate Directories

Harper's foundational logic resides in several Rust crates located at the repository root. Each crate is a standard Cargo project with its own Cargo.toml and src/ directory.

harper-core: The Grammar-Checking Engine

The harper-core directory contains the core linting engine written in Rust. This is the heart of Harper—implementing tokenization, rule evaluation, and diagnostic generation.

  • Primary source: harper-core/src/
  • Library entry point: harper-core/src/lib.rs
  • Key exports: Linter struct and lint() method for programmatic use

Downstream Rust crates reference harper-core via path dependency:

[dependencies]
harper-core = { path = "../harper-core" }
use harper_core::Linter;

fn main() {
    let mut linter = Linter::new_default();
    let text = "This is a smaple sentence.";
    let result = linter.lint(text);
    println!("{:?}", result);
}

harper-ls: Language Server Protocol Implementation

Editor integrations rely on harper-ls, the LSP implementation. Located at harper-ls/, this crate exposes Harper's diagnostics through the Language Server Protocol used by VS Code, Neovim, and other editors.

harper-wasm: WebAssembly Bindings

The harper-wasm crate at harper-wasm/ compiles the core engine to WebAssembly. This enables browser and Node.js usage via the harper.js package.

harper-comments and harper-tex: Specialized Parsers

Two additional Rust crates provide domain-specific functionality:

  • harper-comments (harper-comments/): Extracts and lints comments from source code files
  • harper-tex (harper-tex/): LaTeX-specific processing utilities

Both follow the standard src/lib.rs pattern for library crates.

harper-desktop: Tauri-Based Desktop Application

The harper-desktop directory contains a hybrid Rust/SvelteKit application:

Layer Location Entry Point
Rust backend harper-desktop/src-tauri/ harper-desktop/src-tauri/src/main.rs
SvelteKit frontend harper-desktop/src/ harper-desktop/src/routes/+page.svelte

Run the development server from the repository root:

just dev-desktop

JavaScript/TypeScript Components: The packages/ Directory

All npm-managed source files in Automattic/harper live under the packages/ directory, configured as a pnpm workspace via pnpm-workspace.yaml at the repository root.

harper.js: The Public JavaScript API

packages/harper.js/ bundles the WASM module and provides a TypeScript-friendly interface:

npm i file:./packages/harper.js
import { LocalLinter } from 'harper.js';

(async () => {
  const linter = await LocalLinter.create();
  const diagnostics = await linter.lint('This is a smaple sentence.');
  console.log(diagnostics);
})();

Lint Framework and Editor Components

Two shared packages support multiple Harper UIs:

Web Site and Documentation

The packages/web/ directory contains a SvelteKit site powering writewithharper.com:

  • Documentation content: packages/web/src/routes/docs/about/+page.md

Browser and Editor Extensions

Multiple plugin implementations share the packages/ parent:

Extension Location Activation File
Chrome packages/chrome-plugin/ src/background.ts
Firefox packages/firefox-plugin/ src/background.ts
VS Code packages/vscode-plugin/ src/extension.ts
Obsidian packages/obsidian-plugin/ src/main.ts
WordPress packages/wordpress-plugin/ src/plugin.php

Build Orchestration Files

The Automattic/harper repository uses two workspace systems to coordinate its multi-language structure:

  • Rust: Root Cargo.toml with workspace members pointing to each top-level crate directory
  • JavaScript: pnpm-workspace.yaml declaring packages/* as workspace packages

Summary

  • Rust source files live in top-level directories: harper-core/, harper-ls/, harper-wasm/, harper-comments/, harper-tex/, and harper-desktop/
  • JavaScript/TypeScript source files are grouped under packages/, including harper.js, browser extensions, and Svelte components
  • Key entry points include harper-core/src/lib.rs for the engine and packages/harper.js/src/index.ts for the JS API
  • Documentation source is located in packages/web/src/routes/docs/

Frequently Asked Questions

What is the main entry point for using Harper as a Rust library?

The main entry point is harper-core/src/lib.rs. This file exports the Linter struct and related types that power all Harper linting functionality. Import harper_core in your Cargo.toml to use it.

How do I find the source for the VS Code extension?

The VS Code extension source is located at packages/vscode-plugin/. The extension activates through packages/vscode-plugin/src/extension.ts, which launches the harper-ls language server as a separate process.

Where is the WebAssembly compilation step defined?

The Rust-to-WASM compilation lives in harper-wasm/src/lib.rs. This crate uses wasm-bindgen to generate JavaScript bindings. The resulting WASM binary is packaged by packages/harper.js/ for npm distribution.

Can I build just one component without the entire monorepo?

Yes. Each Rust crate is a standard Cargo project that builds independently with cargo build. JavaScript packages in packages/ can be built individually with pnpm --filter <package-name> build, though some depend on the WASM output from harper-wasm.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →