Documentation
¶
Overview ¶
Package ports defines the interfaces (inward-facing) that the core depends on. Adapters implement these interfaces; the core never imports adapters directly.
Package ports defines the interfaces (inward-facing) that the core depends on. Adapters implement these interfaces; the core never imports adapters directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Confirm ¶
type Confirm interface {
// Lock management — prevents concurrent operations.
AcquireLock() error
ReleaseLock() error
// Plan management — persists the pending operation to disk.
WritePlan(plan domain.OperationPlan) error
ReadPlan() (*domain.OperationPlan, error)
DeletePlan() error
IsPlanExpired() bool
// Blocker management — signals that an operation is waiting for user approval.
CreateBlocker() error
HasBlocker() bool
RemoveBlocker() error
}
Confirm handles the plan/blocker/lock lifecycle for any confirmable operation. Three-phase protocol: START (saves plan + blocker) → APPLY (reads plan + executes) → ABORT.
type DiffChunker ¶
type DiffChunker interface {
// Chunk splits a unified diff into logical chunks.
// Each chunk is small enough to fit in an LLM context window.
// maxChunkSize is the maximum size in characters per chunk.
Chunk(diff string, maxChunkSize int) ([]domain.DiffChunk, error)
}
DiffChunker splits a large unified diff into smaller, LLM-friendly chunks.
type Git ¶
type Git interface {
// --- Read ---
Status() (domain.Status, error)
Diff(paths ...string) (string, error)
DiffStaged(paths ...string) (string, error)
ListUntracked() ([]string, error)
Log(limit int, paths ...string) (string, error)
LogFull(limit int) (string, error)
CurrentBranch() (string, error)
ListBranches(pattern ...string) (string, error)
ListTags(pattern ...string) ([]string, error)
IsRepo() bool
// --- GitHub CLI Integration ---
LatestTag() (string, error)
CommitsFromTag(sinceTag string) (string, error)
TagExists(name string) (bool, error)
IsGHAuthenticated() (bool, error)
CreateRelease(name, changelog string) (string, error)
// --- Backup ---
CreateBackup(operation string, stashUntracked bool) (domain.Backup, error)
RestoreBackup(backup domain.Backup) error
DeleteBackup(backup domain.Backup) error
// --- Write · Direct (no LLM needed) ---
Add(paths []string) error
Remove(paths []string) error
Checkout(name string) (string, error)
Switch(name string) error
Push() (string, error)
PushTag(name string) (string, error)
PushTags() (string, error)
Pull() (string, error)
Fetch() (string, error)
Stash() (string, error)
StashPop() (string, error)
// --- Write · Workflow (LLM + optional confirm) ---
Commit(message string) (string, error)
Branch(name string) (string, error)
RenameBranch(oldName, newName string) (string, error)
DeleteBranch(name string) (string, error)
Reset(mode string, commit string) (string, error)
Merge(branch string) (string, error)
Tag(name string) (string, error)
DeleteTag(name string) (string, error)
DeleteTagRemote(name string) (string, error)
}
Git is the unified interface for all git operations. Direct ops (add, push, pull…) are called by handlers without LLM. Workflow ops (commit, merge, branch…) are routed through the workflow engine.
type LLM ¶
type LLM interface {
// GenerateChunkMessage generates a conventional commit message for a single diff chunk.
GenerateChunkMessage(chunk domain.DiffChunk) (string, error)
// DecideCommit determines what files to stage based on user instruction and git status.
DecideCommit(instruction, gitStatus, untracked, modified, deleted string) (domain.CommitIntent, error)
// InterpretGitOp interprets a natural language instruction for a given git operation.
// Returns a map of concrete args (e.g. {"branch": "feat/login"}).
// context provides extra git state (branches, log, tags) for better accuracy.
InterpretGitOp(op, instruction string, context map[string]string) (map[string]string, error)
// SetRetryContext stores a previously rejected message so the LLM generates a different one.
SetRetryContext(previousMessage string)
// ClearRetryContext clears the retry context after commit or abort.
ClearRetryContext()
// IsAvailable returns true if the LLM backend is reachable.
IsAvailable() bool
// VerifySecrets uses the LLM to verify if a diff contains sensitive information.
VerifySecrets(diff string, findings []domain.SecretDetection) (bool, error)
// AuditBinaryContent uses the LLM to determine if content is binary noise or legitimate text.
AuditBinaryContent(filename, content string) (bool, error)
// GenerateChangelog generates changelog from commits and returns it.
GenerateChangelog(commits, previousChangelog, outputFile string) (string, error)
// RegenerateMessage generates new commit messages based on feedback.
// Used when the user requests regeneration of commit messages in preview mode.
RegenerateMessage(previousMessages []string, feedback string, chunks []domain.DiffChunk) ([]string, error)
}
LLM defines the interface for AI/LLM operations.
type SecurityCheckResult ¶
type SecurityCheckResult struct {
Blocked bool
Files []SecurityResult
}
SecurityCheckResult holds the aggregated result of security checks.
func (*SecurityCheckResult) FirstBlocking ¶
func (r *SecurityCheckResult) FirstBlocking() *SecurityResult
FirstBlocking returns the first SecurityResult that was blocked, or nil if none.
func (*SecurityCheckResult) IsBlocked ¶
func (r *SecurityCheckResult) IsBlocked() bool
IsBlocked returns true if any security check failed.
type SecurityResult ¶
type SecurityResult struct {
Halted bool
Reason string
File string
Line int
Type string
Message string
}
SecurityResult represents a single security check finding.
type SecurityService ¶
type SecurityService interface {
// CheckFiles performs all security checks on the given files.
// Returns a SecurityCheckResult with all findings.
// If Blocked is true, the operation should abort immediately.
CheckFiles(files []string, diff string) *SecurityCheckResult
// ShouldUseLLMScan returns true if the underlying model
// is large enough for LLM-based security scanning.
ShouldUseLLMScan() bool
}
SecurityService defines the interface for security checks. Implementations should provide blacklist, magic bytes, regex, and optionally LLM-based security scanning.