Documentation
¶
Overview ¶
CommitService orchestrates the commit workflow: status → LLM decides what to stage → security check → chunk diff → LLM messages → git commit(s).
ReleaseService orchestrates the release workflow: get release intent → LLM interprets → generate changelog → create tag → create GitHub release.
Package workflow implements the unified git workflow engine.
All operations follow four phases:
- PREPARE — gather git context
- GENERATE — LLM interprets instruction → concrete args
- CONFIRM — (optional) save plan + blocker; return pending
- EXECUTE — run the git command
Operations that require confirmation use a three-step MCP protocol:
*_START → Run() → returns {status: "pending_approval", preview: "..."}
*_APPLY → Apply() → executes the saved plan
*_ABORT → Abort() → discards the plan
Index ¶
- Constants
- func DiffChunksToChunkFiles(chunks []domain.DiffChunk) [][]string
- type CommitResult
- type CommitService
- func (s *CommitService) Execute(instruction string, preview bool) (string, error)
- func (s *CommitService) ExecuteFromPlan(messages []string, chunkFiles [][]string, deletedFiles []string, ...) (string, error)
- func (s *CommitService) ExecutePrepared(messages []string, chunks []domain.DiffChunk, instruction string) (string, error)
- func (s *CommitService) PrepareCommit(instruction string) ([]string, []domain.DiffChunk, []string, []string, string, error)
- type CommitServiceConfig
- type LogChunker
- type PrepContext
- type ReleaseResult
- type ReleaseService
- func (s *ReleaseService) BuildPreview(intent *domain.ReleaseIntent, changelog string) string
- func (s *ReleaseService) ClearPending()
- func (s *ReleaseService) DetectBranchFlow() (string, error)
- func (s *ReleaseService) Execute(intent *domain.ReleaseIntent, changelog string) (string, error)
- func (s *ReleaseService) Generate(commits string) (string, []string, error)
- func (s *ReleaseService) GetConfig() ReleaseServiceConfig
- func (s *ReleaseService) LoadChangelog() (string, error)
- func (s *ReleaseService) LoadIntent() (*domain.ReleaseIntent, error)
- func (s *ReleaseService) LoadState() string
- func (s *ReleaseService) Prepare(instruction string, userBump string) (*domain.ReleaseIntent, string, []string, error)
- func (s *ReleaseService) PrepareAndGenerateAsync(instruction string, userBump string)
- func (s *ReleaseService) SaveChangelog(changelog string)
- func (s *ReleaseService) SaveIntent(intent *domain.ReleaseIntent)
- func (s *ReleaseService) SaveState(state string)
- type ReleaseServiceConfig
- type Result
- type Summary
- type Workflow
- func (w *Workflow) Abort() error
- func (w *Workflow) Apply(ctx context.Context) (Result, error)
- func (w *Workflow) HasPendingPlan() bool
- func (w *Workflow) PlanStatus() (string, error)
- func (w *Workflow) RequiresConfirm(op string, providedArgs map[string]string) bool
- func (w *Workflow) Run(ctx context.Context, op, instruction string, explicitArgs map[string]string) (Result, error)
Constants ¶
const ( StatusCompleted = "completed" StatusPending = "pending_approval" StatusAborted = "aborted" )
Status values returned in Result.
Variables ¶
This section is empty.
Functions ¶
func DiffChunksToChunkFiles ¶ added in v1.4.2
DiffChunksToChunkFiles converts domain.DiffChunk slices to per-message file lists for storage in OperationPlan. Each chunk's Files becomes a []string entry in the resulting slice. If chunks is empty, returns nil.
Types ¶
type CommitResult ¶
type CommitResult struct {
Operation string `json:"operation"`
Message string `json:"result,omitempty"`
Commits []string `json:"commits,omitempty"`
Excluded []domain.ExcludedFile `json:"excluded,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Type string `json:"type"`
}
CommitResult holds the outcome of a commit operation.
type CommitService ¶
type CommitService struct {
// contains filtered or unexported fields
}
CommitService handles the commit workflow.
func NewCommitService ¶
func NewCommitService(git ports.Git, llm ports.LLM, chunker ports.DiffChunker, security ports.SecurityService, cfg CommitServiceConfig) *CommitService
NewCommitService creates a new CommitService.
func (*CommitService) Execute ¶
func (s *CommitService) Execute(instruction string, preview bool) (string, error)
Execute runs the full commit workflow (prepare + execute).
func (*CommitService) ExecuteFromPlan ¶
func (s *CommitService) ExecuteFromPlan(messages []string, chunkFiles [][]string, deletedFiles []string, instruction string) (string, error)
ExecuteFromPlan commits using pre-approved messages and per-chunk file lists from the plan. chunkFiles[i] contains the files to stage for messages[i]. If chunkFiles is nil or shorter than messages, remaining messages are committed with whatever is currently staged. deletedFiles contains files with status "D " to commit separately at the end.
func (*CommitService) ExecutePrepared ¶
func (s *CommitService) ExecutePrepared(messages []string, chunks []domain.DiffChunk, instruction string) (string, error)
ExecutePrepared commits using pre-generated messages from PrepareCommit.
func (*CommitService) PrepareCommit ¶
func (s *CommitService) PrepareCommit(instruction string) ([]string, []domain.DiffChunk, []string, []string, string, error)
PrepareCommit prepares the commit without executing it. Returns generated messages, chunks, deleted files, warnings, reasoning, and error.
type CommitServiceConfig ¶
type CommitServiceConfig struct {
ChunkSize int // max chars per diff chunk sent to LLM
MaxLogLines int // circular buffer size for task.log
LogPath string // path to task log file
}
CommitServiceConfig holds tuneable values for the commit service.
func DefaultCommitServiceConfig ¶
func DefaultCommitServiceConfig(contextWindow, maxLogLines int, logPath string) CommitServiceConfig
DefaultCommitServiceConfig returns sensible defaults derived from Ollama context window.
type LogChunker ¶
type LogChunker interface {
// Chunk splits commits into chunks.
Chunk(commits string, maxPerChunk int) ([]string, error)
}
LogChunker splits a list of commits into chunks for changelog generation.
type PrepContext ¶
type PrepContext struct {
CurrentBranch string
Branches string
Tags string
Log string
UntrackedList string
}
PrepContext holds the git context gathered before calling the LLM.
type ReleaseResult ¶
type ReleaseResult struct {
Operation string `json:"operation"`
TagName string `json:"tag_name,omitempty"`
Changelog string `json:"changelog,omitempty"`
Message string `json:"result,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Type string `json:"type"`
}
ReleaseResult holds the outcome of a release operation.
type ReleaseService ¶
type ReleaseService struct {
// contains filtered or unexported fields
}
ReleaseService handles the release workflow.
func NewReleaseService ¶
func NewReleaseService(git ports.Git, llm ports.LLM, logChunker LogChunker, cfg ReleaseServiceConfig) *ReleaseService
NewReleaseService creates a new ReleaseService.
func (*ReleaseService) BuildPreview ¶
func (s *ReleaseService) BuildPreview(intent *domain.ReleaseIntent, changelog string) string
BuildPreview formats the release preview for user confirmation. Returns a formatted string for preview.
func (*ReleaseService) ClearPending ¶
func (s *ReleaseService) ClearPending()
func (*ReleaseService) DetectBranchFlow ¶
func (s *ReleaseService) DetectBranchFlow() (string, error)
DetectBranchFlow detects if the repository uses git flow. Returns the detected branch flow pattern: "gitflow", "trunk", or "unknown".
func (*ReleaseService) Execute ¶
func (s *ReleaseService) Execute(intent *domain.ReleaseIntent, changelog string) (string, error)
Execute creates the git tag and pushes it to remote. Includes security checks: - Validate tag with IsValidTagName - Check TagExists before creating - Always push tag after creation
func (*ReleaseService) Generate ¶
func (s *ReleaseService) Generate(commits string) (string, []string, error)
Generate generates the changelog from commits. Returns the generated changelog and any warnings. Supports background processing for large numbers of commits.
func (*ReleaseService) GetConfig ¶ added in v1.5.1
func (s *ReleaseService) GetConfig() ReleaseServiceConfig
GetConfig returns the service configuration.
func (*ReleaseService) LoadChangelog ¶
func (s *ReleaseService) LoadChangelog() (string, error)
func (*ReleaseService) LoadIntent ¶
func (s *ReleaseService) LoadIntent() (*domain.ReleaseIntent, error)
func (*ReleaseService) LoadState ¶
func (s *ReleaseService) LoadState() string
func (*ReleaseService) Prepare ¶
func (s *ReleaseService) Prepare(instruction string, userBump string) (*domain.ReleaseIntent, string, []string, error)
Prepare gets release intent and commits since last tag. NO LLM - uses regex to parse instruction and calculates bump from commits. If userBump is provided, use it; otherwise calculate from commits. Returns the release intent, commits, and any warnings.
func (*ReleaseService) PrepareAndGenerateAsync ¶
func (s *ReleaseService) PrepareAndGenerateAsync(instruction string, userBump string)
PrepareAndGenerateAsync runs the full Prepare+Generate flow in a goroutine. If userBump is provided, use it instead of LLM's proposal. Returns immediately — the caller should check LoadState() and LoadIntent()/LoadChangelog() for results.
func (*ReleaseService) SaveChangelog ¶
func (s *ReleaseService) SaveChangelog(changelog string)
func (*ReleaseService) SaveIntent ¶
func (s *ReleaseService) SaveIntent(intent *domain.ReleaseIntent)
func (*ReleaseService) SaveState ¶
func (s *ReleaseService) SaveState(state string)
type ReleaseServiceConfig ¶
type ReleaseServiceConfig struct {
ContextWindow int // LLM context window size
MaxCommitsPerChunk int // max commits per chunk sent to LLM
LogPath string // path to release log file
MaxLogLines int // circular buffer size for task.log
BackgroundThreshold int // chunks above which run async
}
ReleaseServiceConfig holds tuneable values for the release service.
func DefaultReleaseServiceConfig ¶
func DefaultReleaseServiceConfig(contextWindow, maxCommitsPerChunk, maxLogLines int, logPath string) ReleaseServiceConfig
DefaultReleaseServiceConfig returns sensible defaults derived from Ollama context window.
func DefaultReleaseServiceConfigWithPaths ¶
func DefaultReleaseServiceConfigWithPaths(contextWindow, maxCommitsPerChunk, maxLogLines int, logPath string) ReleaseServiceConfig
DefaultReleaseServiceConfigWithPaths returns config with explicit log path.
type Result ¶
type Result struct {
Status string // "completed" | "pending_approval" | "aborted"
Output string // Human-readable output (for completed)
Preview string // What will be done (for pending)
Args map[string]string // Resolved args from LLM (for pending)
Summary *Summary // Structured metadata for the user
}
Result is the return value of Run / Apply / Abort.
type Summary ¶ added in v1.4.2
type Summary struct {
Operation string `json:"operation"`
FilesAffected []string `json:"files_affected,omitempty"`
Impact string `json:"impact"` // "Low" | "Medium" | "High"
SecurityCheck string `json:"security_check"`
Message string `json:"message"`
Reasoning string `json:"reasoning,omitempty"`
Messages []string `json:"messages,omitempty"`
}
Summary provides a high-level overview of the operation's impact.
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow is the main workflow engine for git review operations.
func New ¶
func New(git ports.Git, llm ports.LLM, confirm ports.Confirm, cfg *config.Config, commit *CommitService, release *ReleaseService, security ports.SecurityService) *Workflow
New creates a new Workflow with all its specialized services.
func (*Workflow) HasPendingPlan ¶
HasPendingPlan returns true if there is a pending operation waiting for approval.
func (*Workflow) PlanStatus ¶
PlanStatus returns a human-readable summary of the current pending plan (if any).
func (*Workflow) RequiresConfirm ¶
RequiresConfirm returns true if the operation needs user confirmation before executing. If providedArgs contains preview="false", confirmation is skipped regardless of config.