domain

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BumpVersion

func BumpVersion(currentTag string, bump string) (string, error)

BumpVersion applies the given bump to currentTag and returns the new version string. currentTag must be in "vMAJOR.MINOR.PATCH" or "MAJOR.MINOR.PATCH" format. The returned tag preserves the "v" prefix if present.

func CalculateBump

func CalculateBump(messages []string) string

CalculateBump analyzes conventional commit messages and returns the required semver bump. Priority: major > minor > patch. Rules:

  • Any commit with "!" before ":" in the type → "major"
  • Any commit with "BREAKING CHANGE" in the body → "major"
  • Any commit with "feat:" or "feat(" prefix → "minor"
  • All other commits → "patch"

func IsValidTagName

func IsValidTagName(tag string) bool

IsValidTagName validates tag name is valid semver

Types

type Backup

type Backup struct {
	Ref       string // refs/git-courer/backup/{timestamp}_{op}
	HasStash  bool   // true if we stashed changes before the operation
	Operation string // "commit", "merge", "release", "branch_delete"
	CreatedAt time.Time
}

Backup holds the state saved before a destructive operation. It combines a git ref (HEAD snapshot) and an optional stash (working tree snapshot).

type ClientCapabilities

type ClientCapabilities struct {
	Sampling    bool `json:"sampling"`
	Elicitation bool `json:"elicitation"`
}

ClientCapabilities represents what the client supports

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ClientInfo represents the MCP client information from initialize handshake

type CommitAnalysis

type CommitAnalysis struct {
	Strategy string         `json:"strategy"` // single | split
	Commits  []CommitGroup  `json:"commits"`
	Excluded []ExcludedFile `json:"excluded"`
	Warnings []string       `json:"warnings"`
}

CommitAnalysis represents the AI's analysis of files for commit planning

type CommitGroup

type CommitGroup struct {
	Files   []string `json:"files"`
	Message string   `json:"message"`
	Type    string   `json:"type"`
}

CommitGroup represents a logical group of files to commit together

type CommitIntent

type CommitIntent struct {
	// IncludeUntracked indicates whether to include new/untracked files.
	IncludeUntracked bool
	// Filter is a glob pattern to filter files (e.g., "internal/*", "src/**").
	// Empty means no filter.
	Filter string
}

CommitIntent represents the user's intent for what to commit.

type CommitMessage

type CommitMessage struct {
	Type    string // feat, fix, chore, docs, etc.
	Subject string // Short description
	Full    string // Full conventional commit message
}

CommitMessage represents an AI-generated commit message

type CommitPlan

type CommitPlan struct {
	Files    []string `json:"files"`    // files for this commit
	Commit   string   `json:"commit"`   // commit message
	Commands []string `json:"commands"` // git commands to execute
}

CommitPlan - individual commit plan

type DiffChunk

type DiffChunk struct {
	// Files is the list of files included in this chunk.
	Files []string
	// Diff is the unified diff content for these files.
	Diff string
}

DiffChunk represents a logical subset of a git diff, small enough to be processed by an LLM in a single context window.

type ExcludedFile

type ExcludedFile struct {
	File   string `json:"file"`
	Reason string `json:"reason"`
}

ExcludedFile represents a file that shouldn't be committed

type FileStatus

type FileStatus struct {
	Path      string `json:"path"`
	Status    string `json:"status"` // M, A, D, R, C, U, ?
	Staged    bool   `json:"staged"`
	IsNew     bool   `json:"is_new"`
	IsDeleted bool   `json:"is_deleted"`
	IsRenamed bool   `json:"is_renamed"`
}

FileStatus represents a single file in the repository

type ModelSize

type ModelSize string

ModelSize represents the size category of an LLM model.

const (
	ModelSizeSmall  ModelSize = "small"  // 1B-7B
	ModelSizeMedium ModelSize = "medium" // 7B-14B
	ModelSizeLarge  ModelSize = "large"  // 14B+
)

func (ModelSize) ShouldUseLLMSecurityScan

func (m ModelSize) ShouldUseLLMSecurityScan() bool

ShouldUseLLMSecurityScan returns true if the model is large enough to be trusted for security scanning (14B+ parameters only).

type OperationPlan

type OperationPlan struct {
	Operation string            `json:"operation"`
	Args      map[string]string `json:"args"`
	Preview   string            `json:"preview"` // Human-readable description shown to the user
	CreatedAt int64             `json:"created_at"`

	// Operation metadata
	Messages    []string `json:"messages,omitempty"`
	Files       []string `json:"files,omitempty"`
	Reasoning   string   `json:"reasoning,omitempty"`   // Why these changes/files were chosen
	Instruction string   `json:"instruction,omitempty"` // Original user instruction

	// Commit-specific fields
	Chunks          [][]string `json:"chunks,omitempty"`        // Per-message file lists for per-chunk staging
	DeletedFiles    []string   `json:"deleted_files,omitempty"` // Files with status "D " to commit separately
	RejectedMessage string     `json:"rejected_message,omitempty"`
	DiffHash        string     `json:"diff_hash,omitempty"` // Fingerprint of the diff at START time
	Backup          Backup     `json:"backup,omitempty"`    // Backup information for rollback
}

OperationPlan represents a pending git operation awaiting user confirmation. Persisted to disk and read back when the user approves via *_APPLY.

type Release

type Release struct {
	Tag             string
	Changelog       string
	Version         string
	IsGitHubRelease bool
	CreatedAt       time.Time
}

Release represents a created release.

type ReleaseIntent

type ReleaseIntent struct {
	TagName              string // e.g., "v1.2.0"
	IsRelease            bool   // true if "sacar version"
	VersionBump          string // "major", "minor", "patch"
	UserSpecifiedVersion bool   // true if user explicitly provided a version
	Changelog            string
	BranchFrom           string   // current branch
	MergePath            []string // e.g., ["feature/xxx->develop", "develop->main"]
}

ReleaseIntent represents the user's intent to create a release.

type SecretDetection

type SecretDetection struct {
	File    string
	Line    int
	Type    string // api_key, password, token, etc.
	Content string // The detected secret (redacted)
}

SecretDetection represents a detected secret

type SecurityReason

type SecurityReason string

SecurityReason categorizes why a check failed.

const (
	// ReasonBlacklistedFile indicates a file is on the hard blacklist
	ReasonBlacklistedFile SecurityReason = "BLACKLISTED_FILE"
	// ReasonBlacklistedFolder indicates a file is in a blacklisted folder
	ReasonBlacklistedFolder SecurityReason = "BLACKLISTED_FOLDER"
	// ReasonBinaryFile indicates a file is a binary (detected by magic bytes)
	ReasonBinaryFile SecurityReason = "BINARY_FILE"
	// ReasonSecretDetected indicates a secret pattern was found
	ReasonSecretDetected SecurityReason = "SECRET_DETECTED"
	// ReasonSelfBinary indicates the file is git-courer's own binary
	ReasonSelfBinary SecurityReason = "SELF_BINARY"
)

type SecurityResult

type SecurityResult struct {
	Safe    bool
	Halted  bool
	Reason  SecurityReason
	File    string
	Line    int
	Type    string
	Message string
}

SecurityResult holds the result of a security check. It indicates whether the operation should proceed or be halted.

type Status

type Status struct {
	IsClean    bool         `json:"is_clean"`
	RepoPath   string       `json:"repo_path"`
	Branch     string       `json:"branch"`
	Files      []FileStatus `json:"files"`
	Staged     int          `json:"staged_count"`
	Modified   int          `json:"modified_count"`
	Untracked  int          `json:"untracked_count"`
	Conflicted int          `json:"conflicted_count"`
}

Status represents the current state of a git repository This is used by the git port interface

Jump to

Keyboard shortcuts

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