Documentation
¶
Index ¶
- type CodeEdit
- type CodeRequest
- type CodeResult
- type CodeStyle
- type CoderAgent
- func (c *CoderAgent) ApplyChanges(ctx context.Context, result *CodeResult, basePath string) error
- func (c *CoderAgent) CanHandle(task *pkg.Task) bool
- func (c *CoderAgent) Execute(ctx context.Context, task *pkg.Task) (*pkg.TaskResult, error)
- func (c *CoderAgent) FixCode(ctx context.Context, code string, errorMessage string, language string) (string, error)
- func (c *CoderAgent) GenerateFunction(ctx context.Context, name string, signature string, description string, ...) (string, error)
- func (c *CoderAgent) Name() string
- func (c *CoderAgent) Priority() int
- func (c *CoderAgent) RefactorCode(ctx context.Context, code string, instructions string, language string) (string, error)
- func (c *CoderAgent) RegisterTool(tool ToolInterface)
- type FileChange
- type FileContext
- type ToolInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeEdit ¶
type CodeEdit struct {
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
OldCode string `json:"old_code"`
NewCode string `json:"new_code"`
Reason string `json:"reason,omitempty"`
}
CodeEdit represents a specific edit in a file
type CodeRequest ¶
type CodeRequest struct {
Task string `json:"task"` // What to do: "generate", "modify", "refactor", "fix"
Description string `json:"description"` // Detailed description
Language string `json:"language"` // Target language
FilePath string `json:"file_path"` // Target file path (optional)
Context []FileContext `json:"context"` // Related files for context
Constraints []string `json:"constraints"` // Code constraints/requirements
Style CodeStyle `json:"style"` // Code style preferences
}
CodeRequest represents a code generation request
type CodeResult ¶
type CodeResult struct {
Success bool `json:"success"`
Files []FileChange `json:"files"`
Explanation string `json:"explanation"`
Warnings []string `json:"warnings,omitempty"`
Suggestions []string `json:"suggestions,omitempty"`
}
CodeResult represents the result of code generation
type CodeStyle ¶
type CodeStyle struct {
Formatting string `json:"formatting,omitempty"` // e.g., "prettier", "gofmt"
NamingStyle string `json:"naming_style,omitempty"` // e.g., "camelCase", "snake_case"
Comments string `json:"comments,omitempty"` // e.g., "jsdoc", "godoc"
MaxLineWidth int `json:"max_line_width,omitempty"`
}
CodeStyle defines code style preferences
type CoderAgent ¶
type CoderAgent struct {
// contains filtered or unexported fields
}
CoderAgent handles code generation, modification, and refactoring
func (*CoderAgent) ApplyChanges ¶
func (c *CoderAgent) ApplyChanges(ctx context.Context, result *CodeResult, basePath string) error
ApplyChanges applies file changes to the filesystem
func (*CoderAgent) CanHandle ¶
func (c *CoderAgent) CanHandle(task *pkg.Task) bool
CanHandle determines if this agent can handle the task
func (*CoderAgent) Execute ¶
func (c *CoderAgent) Execute(ctx context.Context, task *pkg.Task) (*pkg.TaskResult, error)
Execute processes a coding task
func (*CoderAgent) FixCode ¶
func (c *CoderAgent) FixCode(ctx context.Context, code string, errorMessage string, language string) (string, error)
FixCode attempts to fix code issues
func (*CoderAgent) GenerateFunction ¶
func (c *CoderAgent) GenerateFunction(ctx context.Context, name string, signature string, description string, language string) (string, error)
GenerateFunction generates a single function
func (*CoderAgent) Priority ¶
func (c *CoderAgent) Priority() int
Priority returns the agent's priority
func (*CoderAgent) RefactorCode ¶
func (c *CoderAgent) RefactorCode(ctx context.Context, code string, instructions string, language string) (string, error)
RefactorCode refactors existing code
func (*CoderAgent) RegisterTool ¶
func (c *CoderAgent) RegisterTool(tool ToolInterface)
RegisterTool registers a tool for the coder agent to use
type FileChange ¶
type FileChange struct {
Path string `json:"path"`
Action string `json:"action"` // "create", "modify", "delete"
Content string `json:"content,omitempty"`
Diff string `json:"diff,omitempty"`
Sections []CodeEdit `json:"sections,omitempty"` // For partial modifications
}
FileChange represents a change to a file
type FileContext ¶
type FileContext struct {
Path string `json:"path"`
Content string `json:"content"`
Summary string `json:"summary,omitempty"` // Optional summary for large files
}
FileContext provides context from a file
type ToolInterface ¶
type ToolInterface interface {
Name() string
Description() string
Schema() llm.JSONSchema
Execute(ctx context.Context, input map[string]interface{}) (*pkg.ToolResult, error)
}
ToolInterface defines what a tool needs to implement