evolution

package
v0.0.0-...-c11c1a8 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package evolution provides autonomous code evolution capabilities through iterative improvement cycles with safety checks and version control integration.

Architecture

The evolution system is the core self-improvement engine of iterate. It operates in phases: plan, code, review, and merge. Each phase uses specialized tools and agents to safely modify the codebase.

Phase Overview

  • Plan Phase: Analyzes the codebase, identifies bugs/issues, and creates a SESSION_PLAN.md with tasks. Uses read-only tools. See: Engine.RunPlanPhase(), BuildSystemPromptAider()

  • Code Phase: Executes tasks from the plan, generating unified diffs that fix bugs or add features. Supports parallel task execution via git worktrees to avoid conflicts. See: Engine.RunCodePhase(), ApplyUnifiedDiffs()

  • Review Phase: Validates changes through build, test, and vet checks. Rejects changes that break the codebase. See: Engine.RunReviewPhase(), verifyProtected()

  • Merge Phase: Commits and optionally creates pull requests with detailed descriptions of changes made. See: phases_pr.go, buildPRBody()

Diff Application

The system uses unified diff format (git-style) for code changes, which is 3x more effective than custom formats. Three fallback strategies ensure robust application:

  1. Strategy 1: Exact match with context lines
  2. Strategy 2: Normalized whitespace matching
  3. Strategy 3: Block-level replacement without context

See: prompts_aider.go (ApplyUnifiedDiffs, applyDiffStrategy1-3)

Safety Mechanisms

  • Sandboxed execution: Commands validated against allowlists and blocked patterns (sandbox.go)
  • Protected files: Git-related and config files cannot be modified (safety.go)
  • Protected directories: vendor, node_modules, .git are excluded
  • Verification gates: go build, go vet, go test run after changes (verify.go)
  • Git snapshots: Automatic backup before changes (snapshot.go)

Multi-Agent Architecture

Specialized agent types handle different aspects:

  • Plan Agent: Analyzes codebase, creates plans (read-only tools)
  • Build Agent: Implements code changes (full tool access)
  • Review Agent: Validates changes (read + test tools)
  • Test Agent: Writes and runs tests

See: agents.go for AgentType, AgentConfig

Provider Management

Supports multiple AI model providers with automatic fallback on rate limits or failures.

See: provider_pool.go

Memory & Learning

The system maintains memory of:

  • Active learnings (memory/ACTIVE_LEARNINGS.md)
  • Evolution journal (internal/evolution/journal.go)
  • Failure patterns (failure_learning.go)
  • Historical evolution data (memory.go)

Test-Driven Development

TDD enforcement ensures code changes include tests:

  • Write failing test → Write code fix → Verify test passes

See: tdd.go

MCP Integration

Model Context Protocol support for external tool integration.

See: mcp.go

Repository Mapping

Builds comprehensive maps of files, functions, and imports for better context during planning.

See: repo_map.go

Index

Constants

This section is empty.

Variables

View Source
var DefaultAgentConfigs = map[AgentType]AgentConfig{
	AgentPlan: {
		Type:        AgentPlan,
		Name:        "planner",
		Description: "Analyzes codebase and creates implementation plans without making changes",
		Tools:       []string{"glob", "grep", "read", "bash"},
		MaxSteps:    20,
		Timeout:     5 * time.Minute,
	},
	AgentBuild: {
		Type:        AgentBuild,
		Name:        "builder",
		Description: "Implements code changes based on plans",
		Tools:       []string{"glob", "grep", "read", "write", "edit", "bash", "todo"},
		MaxSteps:    50,
		Timeout:     15 * time.Minute,
	},
	AgentReview: {
		Type:        AgentReview,
		Name:        "reviewer",
		Description: "Reviews code changes for quality and correctness",
		Tools:       []string{"glob", "grep", "read", "bash"},
		MaxSteps:    30,
		Timeout:     10 * time.Minute,
	},
	AgentTest: {
		Type:        AgentTest,
		Name:        "tester",
		Description: "Writes and verifies tests",
		Tools:       []string{"glob", "grep", "read", "write", "edit", "bash"},
		MaxSteps:    40,
		Timeout:     10 * time.Minute,
	},
}
View Source
var DefaultSandboxConfig = SandboxConfig{
	AllowedCommands: []string{
		"go", "git", "ls", "cat", "grep", "find", "echo", "pwd",
		"mkdir", "rm", "cp", "mv", "chmod", "chown",
		"npm", "yarn", "pnpm", "pip", "python", "python3",
		"cargo", "rustc", "make", "cmake",
		"docker", "docker-compose",
		"curl", "wget",
	},
	BlockedPatterns: []string{
		`rm\s+-rf\s+/(?!\.)`,
		`dd\s+of=`,
		`mkfs`,
		`curl.*\|.*sh`,
		`wget.*\|.*sh`,
		`:(){ :|:& };:`,
		`fork\(\)`,
		`chmod\s+777`,
		`>\s*/dev/sd`,
		`curl\s+.+\s+-o\s+/etc`,
		`sudo\s+rm`,
		`git\s+push\s+--force`,
		`git\s+push\s+-f`,
	},
	AllowedPaths: []string{
		"/home/runner/work",
		"/tmp",
	},
	Timeout:       5 * time.Minute,
	MaxOutputSize: 1024 * 1024,
	EnvWhitelist: []string{
		"HOME", "PATH", "USER", "GITHUB_TOKEN", "GITHUB_REPOSITORY",
		"GO111MODULE", "GOPROXY", "GOSUMDB",
	},
}
View Source
var DefaultTDDVerification = TDDVerification{
	RequireTest:        true,
	RequireFailingTest: true,
	RequirePassingTest: true,
}
View Source
var LanguageExtensions = map[string]string{
	".go":    "go",
	".py":    "python",
	".js":    "javascript",
	".ts":    "typescript",
	".tsx":   "typescript",
	".jsx":   "javascript",
	".java":  "java",
	".c":     "c",
	".cpp":   "cpp",
	".h":     "c",
	".hpp":   "cpp",
	".rs":    "rust",
	".rb":    "ruby",
	".php":   "php",
	".cs":    "csharp",
	".swift": "swift",
	".kt":    "kotlin",
	".scala": "scala",
	".html":  "html",
	".css":   "css",
	".scss":  "scss",
	".sql":   "sql",
	".sh":    "bash",
	".yaml":  "yaml",
	".yml":   "yaml",
	".json":  "json",
	".md":    "markdown",
}
View Source
var ProtectedFiles = []string{

	"internal/evolution/engine.go",
	"internal/evolution/*.go",

	".github/workflows/evolve.yml",
	".github/workflows/*.yml",

	"cmd/iterate/repl.go",
	"cmd/iterate/main.go",

	".iterate/config.json",

	"scripts/evolution/evolve.sh",
	"scripts/social/social.sh",
}

ProtectedFiles defines patterns for files the agent MUST NOT edit during evolution. These are core infrastructure that could break the evolution system itself.

Functions

func BuildRetryPrompt

func BuildRetryPrompt(attempt int, previousOutput string) string

BuildRetryPrompt creates an escalating prompt for retry attempts

func BuildRetryPromptAider

func BuildRetryPromptAider(attempt int, previousOutput string) string

BuildRetryPromptAider creates an escalating retry prompt

func BuildSystemPromptAider

func BuildSystemPromptAider(repoPath, identity string) string

BuildSystemPromptAider creates a prompt inspired by Aider's approach Uses unified diff format (like git diff) - this is 3X more effective than custom formats

func BuildUserMessageAider

func BuildUserMessageAider(repoPath, journal, issues string, mode string) string

BuildUserMessageAider creates an aggressive, action-oriented user message

func CountUnifiedDiffs

func CountUnifiedDiffs(output string) int

CountUnifiedDiffs returns the number of unified diff blocks

func CreateMCPConfigFile

func CreateMCPConfigFile(repoPath string, servers []MCPServerConfig) error

func DetectUnifiedDiffs

func DetectUnifiedDiffs(output string) bool

DetectUnifiedDiffs checks if output contains unified diffs

func FindMCPConfigFiles

func FindMCPConfigFiles(repoPath string) []string

func ValidateUnifiedDiffs

func ValidateUnifiedDiffs(diffs []UnifiedDiff) []string

ValidateUnifiedDiffs checks if diffs are well-formed - Lenient version

Types

type AgentConfig

type AgentConfig struct {
	Type         AgentType
	Name         string
	Description  string
	Tools        []string
	SystemPrompt string
	MaxSteps     int
	Timeout      time.Duration
}

type AgentResult

type AgentResult struct {
	Success     bool
	Output      string
	Changes     []string
	TestResults string
	Error       error
	StepsUsed   int
	Duration    time.Duration
}

type AgentType

type AgentType string
const (
	AgentPlan   AgentType = "plan"
	AgentBuild  AgentType = "build"
	AgentReview AgentType = "review"
	AgentTest   AgentType = "test"
)

type CodeAnalysis

type CodeAnalysis struct {
	TODOs      []string // file:line: content
	Hotspots   []string // most changed files
	NoTestPkgs []string // packages without test files
	BuildOK    bool
	TestOK     bool
}

CodeAnalysis holds analysis results for the codebase.

func AnalyzeCodebase

func AnalyzeCodebase(repoPath string) CodeAnalysis

AnalyzeCodebase scans the repo for improvement opportunities.

func (CodeAnalysis) FormatAnalysis

func (a CodeAnalysis) FormatAnalysis() string

FormatAnalysis returns a human-readable summary for the agent.

type CoverageConfig

type CoverageConfig struct {
	MinCoverage     float64 // Minimum overall coverage percentage (0-100)
	MinFileCoverage float64 // Minimum per-file coverage percentage (0-100)
	MaxCoverageDrop float64 // Max allowed coverage drop from baseline
}

CoverageConfig defines coverage enforcement thresholds.

func DefaultCoverageConfig

func DefaultCoverageConfig() CoverageConfig

DefaultCoverageConfig returns sensible coverage enforcement defaults.

type DiffHunk

type DiffHunk struct {
	Context []string
	Added   []string
	Removed []string
}

DiffHunk represents a single hunk in a unified diff

type DryRunSandbox

type DryRunSandbox struct {
	Sandbox
	Commands []string
}

func (*DryRunSandbox) Execute

func (d *DryRunSandbox) Execute(ctx context.Context, cmd string) (string, error)

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine runs one evolution session.

func New

func New(repoPath string, logger *slog.Logger) *Engine

New creates a new evolution engine.

func (*Engine) AnalyzeFailures

func (e *Engine) AnalyzeFailures() ([]*FailurePattern, error)

func (*Engine) ApplyUnifiedDiffs

func (e *Engine) ApplyUnifiedDiffs(diffs []UnifiedDiff) ([]string, error)

ApplyUnifiedDiffs applies unified diffs to files with flexible error recovery

func (*Engine) BuildRepoMap

func (e *Engine) BuildRepoMap() (*RepoMap, error)

func (*Engine) CallMCPTool

func (e *Engine) CallMCPTool(ctx context.Context, server, tool string, args map[string]interface{}) (string, error)

func (*Engine) CreateSnapshot

func (e *Engine) CreateSnapshot(ctx context.Context, message string) (*Snapshot, error)

func (*Engine) GetAvoidanceGuidelines

func (e *Engine) GetAvoidanceGuidelines() string

func (*Engine) GetFailurePatternSummary

func (e *Engine) GetFailurePatternSummary() string

func (*Engine) GetMCPTools

func (e *Engine) GetMCPTools() []iteragent.Tool

func (*Engine) GetRepoMapForPrompt

func (e *Engine) GetRepoMapForPrompt() (string, error)

func (*Engine) GetSnapshotList

func (e *Engine) GetSnapshotList() []*Snapshot

func (*Engine) NewMultiAgent

func (e *Engine) NewMultiAgent(agentType AgentType) *MultiAgentEngine

func (*Engine) RecordAndAnalyzeFailure

func (e *Engine) RecordAndAnalyzeFailure(taskTitle, reason string) error

func (*Engine) RestoreSnapshot

func (e *Engine) RestoreSnapshot(ctx context.Context, snapshotID string) error

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, p iteragent.Provider, issues string) (*RunResult, error)

func (*Engine) RunCommunicatePhase

func (e *Engine) RunCommunicatePhase(ctx context.Context, p iteragent.Provider) error

RunCommunicatePhase writes journal, posts issue comments, records learnings.

func (*Engine) RunImplementPhase

func (e *Engine) RunImplementPhase(ctx context.Context, p iteragent.Provider) error

RunImplementPhase reads SESSION_PLAN.md and executes tasks.

func (*Engine) RunMergePhase

func (e *Engine) RunMergePhase(ctx context.Context) error

RunMergePhase merges the open PR, clears state, and returns to main.

func (*Engine) RunPRPhase

func (e *Engine) RunPRPhase(ctx context.Context) error

RunPRPhase creates a feature branch from the current HEAD, pushes it, and opens a PR. It is designed to run after RunImplementPhase has already committed changes to main.

func (*Engine) RunPlanPhase

func (e *Engine) RunPlanPhase(ctx context.Context, p iteragent.Provider, issues string) error

RunPlanPhase runs the planning phase. Creates SESSION_PLAN.md via agent or fallback.

func (*Engine) RunReviewPhase

func (e *Engine) RunReviewPhase(ctx context.Context, p iteragent.Provider) error

RunReviewPhase runs an AI self-review of the open PR.

func (*Engine) RunSafetyChecks

func (e *Engine) RunSafetyChecks(ctx context.Context, prFiles []string) (bool, string, error)

func (*Engine) TraceID

func (e *Engine) TraceID() string

TraceID returns the trace ID for this engine instance.

func (*Engine) WithEventSink

func (e *Engine) WithEventSink(sink chan<- iteragent.Event) *Engine

WithEventSink sets a channel that receives live agent events during evolution.

func (*Engine) WithThinking

func (e *Engine) WithThinking(level iteragent.ThinkingLevel) *Engine

WithThinking sets the extended thinking level for all agents spawned by this engine.

func (*Engine) WriteLearningsToMemory

func (e *Engine) WriteLearningsToMemory(title, context, takeaway string) error

WriteLearningsToMemory is the public entry point for the synthesize workflow.

type FailureAnalyzer

type FailureAnalyzer struct {
	// contains filtered or unexported fields
}

func NewFailureAnalyzer

func NewFailureAnalyzer(repoPath string, logger *slog.Logger) *FailureAnalyzer

func (*FailureAnalyzer) AnalyzeFailures

func (fa *FailureAnalyzer) AnalyzeFailures() ([]*FailurePattern, error)

func (*FailureAnalyzer) GetAvoidanceGuidelines

func (fa *FailureAnalyzer) GetAvoidanceGuidelines() string

func (*FailureAnalyzer) GetPatternSummary

func (fa *FailureAnalyzer) GetPatternSummary() string

func (*FailureAnalyzer) SavePatterns

func (fa *FailureAnalyzer) SavePatterns() error

type FailureEntry

type FailureEntry struct {
	Day    int    `json:"day"`
	Task   string `json:"task"`
	Reason string `json:"reason"`
	TS     string `json:"ts"`
	Type   string `json:"type"`
}

type FailurePattern

type FailurePattern struct {
	Pattern      string   `json:"pattern"`
	Category     string   `json:"category"`
	Count        int      `json:"count"`
	FirstSeen    string   `json:"first_seen"`
	LastSeen     string   `json:"last_seen"`
	Suggestions  []string `json:"suggestions"`
	ExampleTasks []string `json:"example_tasks"`
}

type FileInfo

type FileInfo struct {
	Path       string   `json:"path"`
	Name       string   `json:"name"`
	Language   string   `json:"language"`
	Size       int64    `json:"size"`
	Functions  []string `json:"functions"`
	Classes    []string `json:"classes"`
	Interfaces []string `json:"interfaces"`
	Imports    []string `json:"imports"`
	Exports    []string `json:"exports"`
}

type MCPClient

type MCPClient struct {
	// contains filtered or unexported fields
}

func GetMCPClient

func GetMCPClient(repoPath string, logger *slog.Logger) *MCPClient

func (*MCPClient) CallTool

func (m *MCPClient) CallTool(ctx context.Context, serverName, toolName string, args map[string]interface{}) (string, error)

func (*MCPClient) Close

func (m *MCPClient) Close()

func (*MCPClient) GetAvailableTools

func (m *MCPClient) GetAvailableTools() []iteragent.Tool

func (*MCPClient) HealthCheck

func (m *MCPClient) HealthCheck() map[string]bool

func (*MCPClient) Init

func (m *MCPClient) Init(ctx context.Context) error

func (*MCPClient) ListTools

func (m *MCPClient) ListTools(serverName string) ([]MCPTool, error)

func (*MCPClient) LoadConfig

func (m *MCPClient) LoadConfig(configPath string) error

func (*MCPClient) ReconnectServer

func (m *MCPClient) ReconnectServer(ctx context.Context, serverName string) error

type MCPConfig

type MCPConfig struct {
	Enabled       bool              `json:"enabled"`
	Servers       []MCPServerConfig `json:"servers"`
	Timeout       time.Duration     `json:"timeout"`
	RetryAttempts int               `json:"retry_attempts"`
}

func DefaultMCPConfig

func DefaultMCPConfig() MCPConfig

func LoadMCPConfigFromDefaultLocations

func LoadMCPConfigFromDefaultLocations(repoPath string) (*MCPConfig, error)

type MCPConnection

type MCPConnection struct {
	// contains filtered or unexported fields
}

type MCPError

type MCPError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type MCPMessage

type MCPMessage struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      int             `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *MCPError       `json:"error,omitempty"`
}

type MCPRequest

type MCPRequest struct {
	JSONRPC string                 `json:"jsonrpc"`
	ID      int                    `json:"id,omitempty"`
	Method  string                 `json:"method"`
	Params  map[string]interface{} `json:"params,omitempty"`
}

type MCPServerConfig

type MCPServerConfig struct {
	Name        string            `json:"name"`
	Command     string            `json:"command"`
	Args        []string          `json:"args"`
	Env         map[string]string `json:"env"`
	Transport   string            `json:"transport"` // stdio, http
	URL         string            `json:"url"`
	AutoConnect bool              `json:"auto_connect"`
}

func GetCommonMCPServers

func GetCommonMCPServers() []MCPServerConfig

type MCPTool

type MCPTool struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	InputSchema string `json:"inputSchema"`
}

type MultiAgentEngine

type MultiAgentEngine struct {
	// contains filtered or unexported fields
}

func (*MultiAgentEngine) Execute

type PRState

type PRState struct {
	PRNumber int    `json:"pr_number"`
	PRURL    string `json:"pr_url"`
	Branch   string `json:"branch"`
}

PRState persists PR info between phases (evolve.sh runs phases as separate CLI invocations).

type ParallelAgent

type ParallelAgent struct {
	// contains filtered or unexported fields
}

func NewParallelAgent

func NewParallelAgent(e *Engine, agentTypes ...AgentType) *ParallelAgent

func (*ParallelAgent) Execute

func (pa *ParallelAgent) Execute(ctx context.Context, p iteragent.Provider, tasks []string) []*AgentResult

type ProviderConfig

type ProviderConfig struct {
	Name               string
	Priority           int
	RateLimitPerMinute int
}

type ProviderPool

type ProviderPool struct {
	// contains filtered or unexported fields
}

func CreateProviderPoolForEngine

func CreateProviderPoolForEngine(logger *slog.Logger, modelName string) *ProviderPool

func NewProviderPool

func NewProviderPool(logger *slog.Logger) *ProviderPool

func (*ProviderPool) AddProvider

func (p *ProviderPool) AddProvider(provider iteragent.Provider, config ProviderConfig)

func (*ProviderPool) GetProvider

func (p *ProviderPool) GetProvider() iteragent.Provider

func (*ProviderPool) GetStats

func (p *ProviderPool) GetStats() map[string]ProviderStats

func (*ProviderPool) RecordFailure

func (p *ProviderPool) RecordFailure(providerName string, err error)

func (*ProviderPool) RecordSuccess

func (p *ProviderPool) RecordSuccess(providerName string)

type ProviderStats

type ProviderStats struct {
	TotalCalls   int
	SuccessCalls int
	FailedCalls  int
	RateLimited  int
	LastCall     time.Time
	LastError    string
}

type ProviderWithStats

type ProviderWithStats struct {
	iteragent.Provider
	Config ProviderConfig
	Stats  ProviderStats
}

type RepoMap

type RepoMap struct {
	RootPath   string               `json:"root_path"`
	Files      map[string]*FileInfo `json:"files"`
	Functions  map[string][]string  `json:"functions"`
	Classes    map[string][]string  `json:"classes"`
	Imports    map[string][]string  `json:"imports"`
	DepGraph   map[string][]string  `json:"dependency_graph"`
	LastUpdate string               `json:"last_update"`
	// contains filtered or unexported fields
}

func LoadRepoMap

func LoadRepoMap(path string) (*RepoMap, error)

func NewRepoMap

func NewRepoMap(rootPath string) *RepoMap

func (*RepoMap) Build

func (rm *RepoMap) Build() error

func (*RepoMap) FindFilesByKeyword

func (rm *RepoMap) FindFilesByKeyword(keyword string) []*FileInfo

func (*RepoMap) FindRelatedFiles

func (rm *RepoMap) FindRelatedFiles(filePath string) []string

func (*RepoMap) Save

func (rm *RepoMap) Save(path string) error

func (*RepoMap) ToJSON

func (rm *RepoMap) ToJSON() (string, error)

func (*RepoMap) ToPrompt

func (rm *RepoMap) ToPrompt() string

type RunResult

type RunResult struct {
	Status     string
	StartedAt  time.Time
	FinishedAt time.Time
	PRNumber   int
	PRURL      string
}

RunResult holds the outcome of a completed evolution run.

type SafetyCheck

type SafetyCheck struct {
	LintCheck             bool
	TestModificationCheck bool
	SmokeTestCheck        bool
	RequireHumanReview    bool
}

func DefaultSafetyCheck

func DefaultSafetyCheck() *SafetyCheck

type Sandbox

type Sandbox struct {
	// contains filtered or unexported fields
}

func NewSandbox

func NewSandbox(dir string) *Sandbox

func (*Sandbox) Execute

func (s *Sandbox) Execute(ctx context.Context, cmd string) (string, error)

func (*Sandbox) ExecuteWithRetry

func (s *Sandbox) ExecuteWithRetry(ctx context.Context, cmd string, maxRetries int) (string, error)

type SandboxConfig

type SandboxConfig struct {
	AllowedCommands []string
	BlockedPatterns []string
	AllowedPaths    []string
	Timeout         time.Duration
	MaxOutputSize   int
	EnvWhitelist    []string
}

type SequentialAgent

type SequentialAgent struct {
	// contains filtered or unexported fields
}

func NewSequentialAgent

func NewSequentialAgent(e *Engine, agentTypes ...AgentType) *SequentialAgent

func (*SequentialAgent) Execute

func (sa *SequentialAgent) Execute(ctx context.Context, p iteragent.Provider, task string) *AgentResult

type Snapshot

type Snapshot struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	CommitSHA string    `json:"commit_sha"`
	Message   string    `json:"message"`
	Files     []string  `json:"files"`
}

type SnapshotManager

type SnapshotManager struct {
	// contains filtered or unexported fields
}

func NewSnapshotManager

func NewSnapshotManager(repoPath string, logger *slog.Logger) *SnapshotManager

func (*SnapshotManager) Create

func (sm *SnapshotManager) Create(ctx context.Context, message string) (*Snapshot, error)

func (*SnapshotManager) CreateBranch

func (sm *SnapshotManager) CreateBranch(ctx context.Context, branchName, baseSnapshotID string) error

func (*SnapshotManager) Delete

func (sm *SnapshotManager) Delete(ctx context.Context, snapshotID string) error

func (*SnapshotManager) Diff

func (sm *SnapshotManager) Diff(ctx context.Context, snapshotID string) (string, error)

func (*SnapshotManager) DiscardUncommittedChanges

func (sm *SnapshotManager) DiscardUncommittedChanges(ctx context.Context) error

func (*SnapshotManager) Get

func (sm *SnapshotManager) Get(snapshotID string) (*Snapshot, bool)

func (*SnapshotManager) HasUncommittedChanges

func (sm *SnapshotManager) HasUncommittedChanges(ctx context.Context) (bool, error)

func (*SnapshotManager) List

func (sm *SnapshotManager) List() []*Snapshot

func (*SnapshotManager) LoadSnapshots

func (sm *SnapshotManager) LoadSnapshots() error

func (*SnapshotManager) Restore

func (sm *SnapshotManager) Restore(ctx context.Context, snapshotID string) error

func (*SnapshotManager) SaveSnapshotMetadata

func (sm *SnapshotManager) SaveSnapshotMetadata(snapshot *Snapshot) error

type TDDEngine

type TDDEngine struct {
	// contains filtered or unexported fields
}

func NewTDDEngine

func NewTDDEngine(e *Engine) *TDDEngine

func (*TDDEngine) ExecuteTask

func (t *TDDEngine) ExecuteTask(ctx context.Context, task string) *TDDResult

func (*TDDEngine) Verify

func (t *TDDEngine) Verify(result *TDDResult) error

type TDDPhase

type TDDPhase string
const (
	TDDPhaseWriteTest TDDPhase = "write_test"
	TDDPhaseRunTest   TDDPhase = "run_test"
	TDDPhaseWriteCode TDDPhase = "write_code"
	TDDPhaseVerify    TDDPhase = "verify"
)

type TDDResult

type TDDResult struct {
	Phase    TDDPhase
	Success  bool
	TestFile string
	CodeFile string
	Output   string
	Error    error
}

type TDDVerification

type TDDVerification struct {
	RequireTest        bool
	RequireFailingTest bool
	RequirePassingTest bool
}

type UnifiedDiff

type UnifiedDiff struct {
	OldFile string
	NewFile string
	Hunks   []DiffHunk
}

UnifiedDiff represents a parsed unified diff

func ParseUnifiedDiffs

func ParseUnifiedDiffs(output string) []UnifiedDiff

ParseUnifiedDiffs extracts unified diffs from LLM output

type VerboseSandbox

type VerboseSandbox struct {
	Sandbox
	Log func(string)
}

func (*VerboseSandbox) Execute

func (v *VerboseSandbox) Execute(ctx context.Context, cmd string) (string, error)

type VerificationResult

type VerificationResult struct {
	BuildPassed  bool
	TestPassed   bool
	VetPassed    bool
	Coverage     float64
	CoverageOK   bool
	CoveredFiles int
	TotalFiles   int
	Output       string
	Error        error
	Violations   []string
	Duration     time.Duration
}

VerificationResult holds the outcome of a build + test verification run.

Jump to

Keyboard shortcuts

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