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
- type CommitResult
- type CommitService
- func (s *CommitService) Execute(instruction string, preview bool) (string, error)
- func (s *CommitService) ExecuteFromPlan(messages []string, chunkFiles [][]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 LogChunker
- type PrepContext
- type ReleaseResult
- type ReleaseService
- func (s *ReleaseService) BuildPreview(intent *domain.ReleaseIntent, changelog string) string
- func (s *ReleaseService) DeletePendingFiles()
- func (s *ReleaseService) DeleteState()
- func (s *ReleaseService) DetectBranchFlow() (string, error)
- func (s *ReleaseService) Execute(intent *domain.ReleaseIntent, changelog string, createGHRelease bool) (string, error)
- func (s *ReleaseService) Generate(commits string) (string, []string, error)
- func (s *ReleaseService) LoadChangelog() (string, error)
- func (s *ReleaseService) LoadIntent() (*domain.ReleaseIntent, error)
- func (s *ReleaseService) LoadState() string
- func (s *ReleaseService) Prepare(instruction string) (*domain.ReleaseIntent, string, []string, error)
- func (s *ReleaseService) PrepareAndGenerateAsync(instruction string)
- func (s *ReleaseService) SaveIntent(intent *domain.ReleaseIntent) error
- func (s *ReleaseService) SaveState(state string)
- type ReleaseServiceConfig
- type Result
- 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) 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, chunkFiles [][]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.
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 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. Each operation populates only the fields it needs.
type ReleaseResult ¶
type ReleaseResult struct {
Operation string `json:"operation"`
TagName string `json:"tag_name,omitempty"`
Changelog string `json:"changelog,omitempty"`
IsGitHubRelease bool `json:"is_github_release,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) DeletePendingFiles ¶
func (s *ReleaseService) DeletePendingFiles()
DeletePendingFiles removes the persisted intent, changelog, and state files after a successful release.
func (*ReleaseService) DeleteState ¶
func (s *ReleaseService) DeleteState()
DeleteState removes the state file to signal that the background operation is ready.
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, createGHRelease bool) (string, error)
Execute creates the git tag and optional GitHub release. Includes security checks: - Validate tag with IsValidTagName - Check TagExists before creating - Check IsGHAuthenticated before gh release - Don't ignore gh errors
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) LoadChangelog ¶
func (s *ReleaseService) LoadChangelog() (string, error)
LoadChangelog reads the background-generated changelog from disk. Returns empty string (no error) if the file does not exist yet.
func (*ReleaseService) LoadIntent ¶
func (s *ReleaseService) LoadIntent() (*domain.ReleaseIntent, error)
LoadIntent reads a previously saved release intent from disk.
func (*ReleaseService) LoadState ¶
func (s *ReleaseService) LoadState() string
LoadState reads the current background operation state. Returns empty string if no state file exists (meaning: not started or completed).
func (*ReleaseService) Prepare ¶
func (s *ReleaseService) Prepare(instruction string) (*domain.ReleaseIntent, string, []string, error)
Prepare gets release intent and commits since last tag. Returns the release intent, commits, and any warnings.
func (*ReleaseService) PrepareAndGenerateAsync ¶
func (s *ReleaseService) PrepareAndGenerateAsync(instruction string)
PrepareAndGenerateAsync runs the full Prepare+Generate flow in a goroutine. Returns immediately — the caller should check LoadState() and LoadIntent()/LoadChangelog() for results.
func (*ReleaseService) SaveIntent ¶
func (s *ReleaseService) SaveIntent(intent *domain.ReleaseIntent) error
SaveIntent persists the release intent to disk so RELEASE_APPLY survives a server restart.
func (*ReleaseService) SaveState ¶
func (s *ReleaseService) SaveState(state string)
SaveState writes the current background operation state ("processing", "error: ...").
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
ChangelogPath string // path to write the generated changelog
IntentPath string // path to persist the release intent JSON
}
ReleaseServiceConfig holds tuneable values for the release service.
func DefaultReleaseServiceConfig ¶
func DefaultReleaseServiceConfig(contextWindow, maxCommitsPerChunk, maxLogLines int, logPath, changelogPath, intentPath string) ReleaseServiceConfig
DefaultReleaseServiceConfig returns sensible defaults derived from Ollama context window.
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) 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.