trailers

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package trailers provides parsing and formatting for Entire commit message trailers. Trailers are key-value metadata appended to git commit messages following the git trailer convention (key: value format after a blank line).

Index

Constants

View Source
const (
	// MetadataTrailerKey points to the metadata directory within a commit tree.
	MetadataTrailerKey = "Entire-Metadata"

	// MetadataTaskTrailerKey points to the task metadata directory for subagent checkpoints.
	MetadataTaskTrailerKey = "Entire-Metadata-Task"

	// StrategyTrailerKey indicates which strategy created the commit.
	StrategyTrailerKey = "Entire-Strategy"

	// BaseCommitTrailerKey links shadow commits to their base code commit.
	BaseCommitTrailerKey = "Base-Commit"

	// SessionTrailerKey identifies which session created a commit.
	SessionTrailerKey = "Entire-Session"

	// CondensationTrailerKey identifies the condensation ID for a commit (legacy).
	CondensationTrailerKey = "Entire-Condensation"

	// SourceRefTrailerKey links code commits to their metadata on a shadow/metadata branch.
	// Format: "<branch>@<commit-hash>" e.g. "entire/metadata@abc123def456"
	SourceRefTrailerKey = "Entire-Source-Ref"

	// CheckpointTrailerKey links commits to their checkpoint metadata on entire/sessions.
	// Format: 12 hex characters e.g. "a3b2c4d5e6f7"
	// This trailer survives git amend and rebase operations.
	CheckpointTrailerKey = "Entire-Checkpoint"

	// EphemeralBranchTrailerKey identifies the shadow branch that a checkpoint originated from.
	// Used in manual-commit strategy checkpoint commits on entire/sessions branch.
	// Format: full branch name e.g. "entire/2b4c177"
	EphemeralBranchTrailerKey = "Ephemeral-branch"

	// AgentTrailerKey identifies the agent that created a checkpoint.
	// Format: human-readable agent name e.g. "Claude Code", "Cursor"
	AgentTrailerKey = "Entire-Agent"
)

Trailer key constants used in commit messages.

Variables

This section is empty.

Functions

func FormatCheckpoint

func FormatCheckpoint(message string, cpID checkpointID.CheckpointID) string

FormatCheckpoint creates a commit message with a checkpoint trailer. This links user commits to their checkpoint metadata on entire/sessions branch.

func FormatMetadata

func FormatMetadata(message, metadataDir string) string

FormatMetadata creates a commit message with metadata trailer.

func FormatMetadataWithStrategy

func FormatMetadataWithStrategy(message, metadataDir, strategy string) string

FormatMetadataWithStrategy creates a commit message with metadata and strategy trailers.

func FormatShadowCommit

func FormatShadowCommit(message, metadataDir, sessionID string) string

FormatShadowCommit creates a commit message for manual-commit strategy checkpoints. Includes Entire-Metadata, Entire-Session, and Entire-Strategy trailers.

func FormatShadowTaskCommit

func FormatShadowTaskCommit(message, taskMetadataDir, sessionID string) string

FormatShadowTaskCommit creates a commit message for manual-commit task checkpoints. Includes Entire-Metadata-Task, Entire-Session, and Entire-Strategy trailers.

func FormatSourceRef

func FormatSourceRef(branch, commitHash string) string

FormatSourceRef creates a formatted source ref string for the trailer. Format: "<branch>@<commit-hash-prefix>" (hash truncated to 12 chars)

func FormatStrategy

func FormatStrategy(message, strategy string) string

FormatStrategy creates a commit message with just the strategy trailer.

func FormatTaskMetadata

func FormatTaskMetadata(message, taskMetadataDir string) string

FormatTaskMetadata creates a commit message with task metadata trailer.

func FormatTaskMetadataWithStrategy

func FormatTaskMetadataWithStrategy(message, taskMetadataDir, strategy string) string

FormatTaskMetadataWithStrategy creates a commit message with task metadata and strategy trailers.

func ParseAllSessions

func ParseAllSessions(commitMessage string) []string

ParseAllSessions extracts all session IDs from a commit message. Returns a slice of session IDs (may be empty if none found). Duplicate session IDs are deduplicated while preserving order. This is useful for commits that may have multiple Entire-Session trailers.

func ParseBaseCommit

func ParseBaseCommit(commitMessage string) (string, bool)

ParseBaseCommit extracts the base commit SHA from a commit message. Returns the full SHA and true if found, empty string and false otherwise.

func ParseCheckpoint

func ParseCheckpoint(commitMessage string) (checkpointID.CheckpointID, bool)

ParseCheckpoint extracts the checkpoint ID from a commit message. Returns the CheckpointID and true if found, empty ID and false otherwise.

func ParseCondensation

func ParseCondensation(commitMessage string) (string, bool)

ParseCondensation extracts the condensation ID from a commit message. Returns the condensation ID and true if found, empty string and false otherwise.

func ParseMetadata

func ParseMetadata(commitMessage string) (string, bool)

ParseMetadata extracts metadata dir from commit message. Returns the metadata directory and true if found, empty string and false otherwise.

func ParseSession

func ParseSession(commitMessage string) (string, bool)

ParseSession extracts the session ID from a commit message. Returns the session ID and true if found, empty string and false otherwise. Note: If multiple Entire-Session trailers exist, this returns only the first one. Use ParseAllSessions to get all session IDs.

func ParseStrategy

func ParseStrategy(commitMessage string) (string, bool)

ParseStrategy extracts strategy from commit message. Returns the strategy name and true if found, empty string and false otherwise.

func ParseTaskMetadata

func ParseTaskMetadata(commitMessage string) (string, bool)

ParseTaskMetadata extracts task metadata dir from commit message. Returns the task metadata directory and true if found, empty string and false otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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