Skip to content

structuredmerge/structuredmerge-rust

Repository files navigation

StructuredMerge Rust

StructuredMerge Rust provides Cargo crates for native tools that need portable structured-merge contracts, fixture-backed behavior, and embeddable merge components.

The workspace includes the core AST/review contracts, parser substrate support, format-specific merge crates, binary/ZIP planning helpers, provider adapters, and a Rust packaging recipe crate.

Project links:

Package Family

StructuredMerge Rust is a layered crate family. The lower layers provide parser, range, AST, merge, and template contracts; format crates apply those contracts to specific languages and data formats; provider crates bind a format family to a parser or serializer; workflow crates package Rust project maintenance and Git-driver behavior.

Each crate README keeps this section short and links here. This root guide is the implementation inventory for Rust users who need to choose crates, understand backend coverage, or wire a focused backend into a test suite.

The family is intentionally layered:

Crate Layer What it provides
tree-haver Parser substrate Parser backend registry, byte ranges, node wrappers, source locations, and binary tree contracts.
ast-merge Merge substrate AST merge contracts, diagnostics, planning, review, replay, and nested merge vocabulary.
ast-template Template substrate Template/session transport contracts.
ast-crispr Structured edits AST edit recipes for generated blocks and template-owned regions.
ast-merge-git Git integration Merge-driver, diff-driver, conflict inspection, and language registry plumbing for smorg-rs.
plain-merge Text Plain-text fallback contracts.
json-merge JSON and JSONC Object/array-aware JSON merge behavior using tree-sitter-language-pack where selected.
yaml-merge YAML YAML-family merge contracts.
toml-merge TOML TOML-family merge contracts.
markdown-merge Markdown Markdown-family merge contracts.
ruby-merge Ruby source Ruby source merge contracts.
go-merge Go source Go source merge contracts.
rust-merge Rust source Rust source merge contracts.
typescript-merge TypeScript source TypeScript source merge contracts.
binary-merge Binary Binary tree planning contracts.
zip-merge Archives ZIP archive planning helpers.
yaml-serde-merge YAML provider Uses serde_yaml as the YAML parser/emitter provider path.
pest-toml-merge TOML provider Uses Pest with pest_grammars as the TOML parser provider path.
pulldown-cmark-merge Markdown provider Uses pulldown-cmark as the Markdown parser provider path.
kettle-rusty Recipe tooling Cargo workspace maintenance and package recipe helpers.

Install

Add the crates your tool needs:

[dependencies]
ast-merge = "0.1"
tree-haver = "0.1"

Binary and ZIP use StructuredMerge-prefixed package names on crates.io:

structuredmerge-binary-merge = "0.1"
structuredmerge-zip-merge = "0.1"

Command

The Rust implementation ships the implementation-specific smorg-rs command. Use that name in git configuration unless a package manager or local install has provided a smorg symlink.

Package-manager formulas may expose the selected implementation as smorg. For a local user-created symlink:

ln -s "$(command -v smorg-rs)" ~/.local/bin/smorg
git config merge.smorg-rs.driver 'smorg-rs merge-driver %O %A %B %P'
git config diff.smorg-rs.command 'smorg-rs diff-driver'
smorg-rs conflicts diff path/to/file-with-conflicts.go
smorg-rs languages --gitattributes

merge-driver updates Git's %A file by default, or writes to --output when used outside git. diff-driver accepts both the two-argument local form and the seven- or nine-argument forms Git passes to external diff commands. conflicts diff reports conflict-marker regions in a file that already contains Git conflict markers.

Semantic merge-driver coverage is fixture-backed for JSON. Other language and format paths are git-compatible command surfaces without semantic driver coverage.

Crates

Core:

  • tree-haver - parser substrate, byte ranges, backend adapters, and binary tree contracts.
  • ast-merge - AST merge contracts, diagnostics, planning, review, replay, and nested-merge vocabulary.
  • ast-template - template/session transport contracts.

Format libraries:

Provider and recipe crates:

Portability

The Rust crates are developed against the shared StructuredMerge fixtures. Those fixtures define the cross-language behavior expected from the Go, TypeScript, Rust, and Ruby implementations. Conformance checks live in crate tests and in the shared spec/fixture tooling rather than in a static status document.

Development

Common checks:

  • mise run check
  • cargo test

About

Rust implementation of the StructuredMerge contract

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages