Skip to content

structuredmerge/structuredmerge-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

525 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StructuredMerge Go

StructuredMerge Go provides Go packages for building merge-aware tools that need portable structured-merge contracts without leaving the Go runtime.

The module includes the core AST/review contracts, parser substrate support, format-specific merge libraries, binary/ZIP planning helpers, provider adapters, and a Go packaging recipe library.

Project links:

Package Family

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

Package README files in other implementations link to their root package-family guide. The Go implementation uses this root inventory because its packages live inside one module.

The family is intentionally layered:

  • treehaver provides parser portability, backend discovery, byte ranges, and runtime capability reporting.
  • astmerge provides the cross-format merge substrate: shared contracts, diagnostics, review state, and execution reports.
  • Family packages such as markdownmerge, yamlmerge, and tomlmerge own parser-neutral behavior for one format family.
  • Provider packages such as goldmarkmerge, goccygoyamlmerge, and pigeontomlmerge bind those families to concrete Go parser libraries.
Package Layer What it provides
treehaver Parser substrate Parser backend registry, byte ranges, node wrappers, source locations, and binary tree contracts.
astmerge Merge substrate AST merge contracts, diagnostics, planning, review, replay, and nested merge vocabulary.
asttemplate Template substrate Template/session transport contracts.
astcrispr Structured edits AST edit recipes for generated blocks and template-owned regions.
astmergegit Git integration Merge-driver, diff-driver, conflict inspection, and language registry plumbing for smorg-go.
plainmerge Text Plain-text fallback contracts.
jsonmerge JSON and JSONC Object/array-aware JSON merge behavior using tree-sitter-language-pack where selected.
yamlmerge YAML YAML-family merge contracts.
tomlmerge TOML TOML-family merge contracts.
markdownmerge Markdown Markdown-family merge contracts.
rubymerge Ruby source Ruby source merge contracts.
gomerge Go source Go source merge contracts.
rustmerge Rust source Rust source merge contracts.
typescriptmerge TypeScript source TypeScript source merge contracts.
binarymerge Binary Binary tree planning contracts.
zipmerge Archives ZIP archive planning helpers.
goccygoyamlmerge YAML provider Uses goccy/go-yaml as the YAML parser/emitter provider path.
pigeontomlmerge TOML provider Uses Pigeon generated parser code as the TOML provider path.
goldmarkmerge Markdown provider Uses Goldmark as the Markdown parser provider path.
goparsermerge Go provider Uses the Go standard library go/parser provider path.
godstmerge Go provider Uses go-dst for decorator-preserving Go source edit projection.
kettlegomodder Recipe tooling Go module maintenance and package recipe helpers.

Install

go get github.com/structuredmerge/structuredmerge-go

Import only the packages your tool needs:

import (
	"github.com/structuredmerge/structuredmerge-go/astmerge"
	"github.com/structuredmerge/structuredmerge-go/jsonmerge"
)

Command

The Go implementation ships the implementation-specific smorg-go 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-go)" ~/.local/bin/smorg
git config merge.smorg-go.driver 'smorg-go merge-driver %O %A %B %P'
git config diff.smorg-go.command 'smorg-go diff-driver'
smorg-go conflicts diff path/to/file-with-conflicts.go
smorg-go 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 and for the first Go source-language slice. Other language and format paths are git-compatible command surfaces without semantic driver coverage.

Packages

Core:

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

Format libraries:

Provider and recipe libraries:

Portability

The Go packages 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 package tests and in the shared spec/fixture tooling rather than in a static status document.

Development

Common checks:

  • mise run check
  • go test ./...

The tree-sitter backend path uses the sibling tree-sitter-language-pack checkout through a local replace in go.mod. Repo tasks build its ts-pack-core-ffi crate first and compile with the tspack_dev build tag.

About

Go implementation of the StructuredMerge contract

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages