merge

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package merge handles CLAUDE.md section parsing and merging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(layers []Layer, opts MergeOptions) string

Merge combines layers into a single document. Order: team (base) -> personal -> project Returns the merged markdown content.

func MergeSimple

func MergeSimple(contents ...string) string

MergeSimple merges multiple markdown contents without layer metadata. Useful for simple cases where source tracking isn't needed.

func MergeWithLanguages

func MergeWithLanguages(layers []Layer, opts MergeOptions) string

MergeWithLanguages performs the full merge including language configs. First merges base layers, then appends a language-specific section.

Types

type Document

type Document struct {
	Preamble string    // Content before the first H2
	Sections []Section // H2-delimited sections
}

Document represents a parsed markdown document.

func Parse

func Parse(content string) *Document

Parse splits markdown into sections by H2 headers.

func (*Document) FindSection

func (d *Document) FindSection(header string) *Section

FindSection finds a section by header name (case-insensitive).

func (*Document) HasSection

func (d *Document) HasSection(header string) bool

HasSection checks if a section exists (case-insensitive).

func (*Document) SectionHeaders

func (d *Document) SectionHeaders() []string

SectionHeaders returns all section header names.

type Layer

type Layer struct {
	Content string
	Source  string // "team" | "personal" | "project"
}

Layer represents a config layer with its source.

type MergeOptions

type MergeOptions struct {
	AnnotateSources bool                                // Add source comments
	TeamRepo        string                              // For header annotation (e.g., "acme/standards")
	Languages       []string                            // Active languages to include
	LanguageFiles   map[string][]*language.LanguageFile // Language files by language ID
}

MergeOptions controls merge behavior.

type Section

type Section struct {
	Header  string // The H2 header text (without ##)
	Content string // Everything until the next H2
}

Section represents an H2-delimited section of markdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL