Documentation
¶
Overview ¶
CommitService orchestrates the commit workflow: status → LLM decides what to stage → security check → chunk diff → LLM messages → git commit(s).
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
- type CommitResult
- type CommitService
- func (s *CommitService) Execute(instruction string, preview bool) (string, error)
- func (s *CommitService) ExecuteFromPlan(messages []string, files []string, instruction 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, error)
- type CommitServiceConfig
- type PrepContext
- type Result
- type Workflow
- func (w *Workflow) Abort() error
- func (w *Workflow) Apply(ctx context.Context) (Result, error)
- func (w *Workflow) PlanStatus() (string, error)
- func (w *Workflow) RequiresConfirm(op 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 ¶
This section is empty.
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, files []string, instruction string) (string, error)
ExecuteFromPlan commits using pre-approved messages and files from the plan. This avoids re-running PrepareCommit which might produce different results.
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, error)
PrepareCommit prepares the commit without executing it. Returns generated messages, chunks, warnings, and the decision reasoning.
type CommitServiceConfig ¶
type CommitServiceConfig struct {
BackgroundThreshold int // diff size (chars) above which we run async
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, backgroundThreshold, maxLogLines int, logPath string) CommitServiceConfig
DefaultCommitServiceConfig returns sensible defaults derived from Ollama context window.
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. Each operation populates only the fields it needs.
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)
}
Result is the return value of Run / Apply / Abort.
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow is the main workflow engine for git review operations.
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.