templates

package
v0.0.0-...-1783878 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupFile

func BackupFile(src, backupDir string) error

BackupFile copies a file to the backup directory preserving structure

func CacheDir

func CacheDir(repoURL string) string

CacheDir returns the template cache directory for a repo

func Clone

func Clone(repoURL, cacheDir string) error

Clone clones a template repository to a local cache directory

func CountInvalidFiles

func CountInvalidFiles(results []ValidationResult) int

CountInvalidFiles returns the count of invalid files from validation results

func EnsureCache

func EnsureCache(repoURL string) (string, error)

EnsureCache clones or pulls the template repository

func ExtractPlaceholders

func ExtractPlaceholders(content string) []string

ExtractPlaceholders finds all {{PLACEHOLDER}} patterns in content

func GetInvalidFiles

func GetInvalidFiles(results []ValidationResult) []string

GetInvalidFiles returns a list of file paths that failed validation

func GetVersion

func GetVersion(cacheDir string) (string, error)

GetVersion returns the current git commit hash of the cached repo

func HashContent

func HashContent(content string) string

HashContent returns the SHA256 hash of content

func HashFile

func HashFile(path string) (string, error)

HashFile returns the SHA256 hash of a file

func IsHeadlessCommand

func IsHeadlessCommand(filename string) bool

IsHeadlessCommand returns true if the file is a headless command

func Pull

func Pull(cacheDir string) error

Pull updates a cached template repository

func ReplacePlaceholders

func ReplacePlaceholders(content string, placeholders []Placeholder) string

ReplacePlaceholders replaces {{PLACEHOLDER}} patterns in content

func TemplateFiles

func TemplateFiles(cacheDir string, includeHeadless bool) ([]string, error)

TemplateFiles returns a list of template files from a cache directory

Types

type CategorizedComparisons

type CategorizedComparisons struct {
	Outdated []FileComparison
	Missing  []FileComparison
	Current  []FileComparison
	Custom   []FileComparison
}

CategorizedComparisons holds file comparisons grouped by status

func CategorizeComparisons

func CategorizeComparisons(comparisons []FileComparison) CategorizedComparisons

CategorizeComparisons groups file comparisons by their status

type CopyOptions

type CopyOptions struct {
	Placeholders    []Placeholder
	IncludeHeadless bool
	BackupDir       string // If set, backup existing files here before overwriting
	ProtectCustom   bool   // If true, don't overwrite files not in templates
}

CopyOptions configures the template copy operation

type CopyStats

type CopyStats struct {
	CommandsCopied         int
	HeadlessCommandsCopied int
	SkillsCopied           int
	AgentsCopied           int
	OtherFilesCopied       int
	PlaceholdersReplaced   int
	FileHashes             map[string]string // Template file hashes (before placeholder replacement)
}

CopyStats tracks what was copied

func CopyTemplates

func CopyTemplates(cacheDir, projectDir string, opts CopyOptions) (*CopyStats, error)

CopyTemplates copies templates from cache to project .claude/ directory

type FileComparison

type FileComparison struct {
	Path   string
	Status FileStatus
}

FileComparison represents the result of comparing a local file with a template

func Compare

func Compare(cacheDir, projectDir string, includeHeadless bool, storedHashes map[string]string) ([]FileComparison, error)

Compare compares local .claude/ files with templates storedHashes contains the template hashes from when files were last copied

type FileStatus

type FileStatus string

FileStatus represents the comparison status of a file

const (
	StatusCurrent  FileStatus = "CURRENT"  // File matches template
	StatusOutdated FileStatus = "OUTDATED" // File differs from template
	StatusMissing  FileStatus = "MISSING"  // File doesn't exist locally
	StatusCustom   FileStatus = "CUSTOM"   // File exists locally but not in templates
)

type Placeholder

type Placeholder struct {
	Key   string
	Value string
}

Placeholder represents a template placeholder and its value

type ValidationResult

type ValidationResult struct {
	Path   string
	Valid  bool
	Issues []string
}

ValidationResult holds the result of validating a single file

func ValidateClaudeDir

func ValidateClaudeDir(projectDir string) ([]ValidationResult, error)

ValidateClaudeDir validates all markdown files in .claude/ have proper frontmatter

Jump to

Keyboard shortcuts

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