Documentation
¶
Overview ¶
Package payload provides functionality for generating AI-ready payloads from conflict data
Index ¶
- Constants
- func DefaultSensitivePatterns() []string
- func DetectFileType(filePath string) string
- func DetectLanguage(filePath string) string
- func GenerateAIPayload(context *ConflictContext) map[string]interface{}
- type BinaryFileFilter
- type BranchInfo
- type CommitInfo
- type ConflictContext
- type ConflictFilePayload
- type ConflictHunkPayload
- type ConflictPayload
- type ContextExtractor
- type FileContext
- type FileFilter
- type FileMetadata
- type GeneratedFileFilter
- type GenericContextExtractor
- type GoContextExtractor
- type JavaContextExtractor
- type JavaScriptContextExtractor
- type LockfileFilter
- type PayloadBuilder
- type PayloadMetadata
- type ProjectInfo
- type PythonContextExtractor
- type RepositoryContext
- type ResolutionPreferences
- type SensitiveFileFilter
- type TypeScriptContextExtractor
Constants ¶
const ( LanguageJavaScript = "javascript" LanguageTypeScript = "typescript" LanguagePython = "python" LanguageGo = "go" LanguageJSON = "json" LanguageJava = "java" FileTypeText = "text" )
Constants for commonly used languages and file types
Variables ¶
This section is empty.
Functions ¶
func DefaultSensitivePatterns ¶
func DefaultSensitivePatterns() []string
DefaultSensitivePatterns returns default patterns for sensitive content
func DetectFileType ¶
DetectFileType determines the general file type
func DetectLanguage ¶
DetectLanguage determines the programming language from file extension
func GenerateAIPayload ¶
func GenerateAIPayload(context *ConflictContext) map[string]interface{}
GenerateAIPayload creates a structured payload for AI processing
Types ¶
type BinaryFileFilter ¶
type BinaryFileFilter struct {
// contains filtered or unexported fields
}
BinaryFileFilter filters out binary files
func NewBinaryFileFilter ¶
func NewBinaryFileFilter() *BinaryFileFilter
NewBinaryFileFilter creates a new binary file filter
func (*BinaryFileFilter) GetReason ¶
func (f *BinaryFileFilter) GetReason() string
GetReason returns the reason for exclusion
func (*BinaryFileFilter) ShouldExclude ¶
func (f *BinaryFileFilter) ShouldExclude(filePath string) bool
ShouldExclude returns true if the file is binary
type BranchInfo ¶
type BranchInfo struct {
CurrentBranch string `json:"current_branch"`
MergeBranch string `json:"merge_branch"`
BaseBranch string `json:"base_branch,omitempty"`
MergeBase string `json:"merge_base,omitempty"`
}
BranchInfo contains information about the branches being merged
type CommitInfo ¶
type CommitInfo struct {
OursCommit string `json:"ours_commit"`
TheirsCommit string `json:"theirs_commit"`
BaseCommit string `json:"base_commit,omitempty"`
MergeMessage string `json:"merge_message,omitempty"`
}
CommitInfo contains commit-related information
type ConflictContext ¶
type ConflictContext struct {
File string `json:"file"`
ConflictID string `json:"conflict_id"`
BeforeLines []string `json:"before_lines"`
OurLines []string `json:"our_lines"`
TheirLines []string `json:"their_lines"`
AfterLines []string `json:"after_lines"`
}
ConflictContext represents the context around a merge conflict
func ExtractConflictContext ¶
func ExtractConflictContext(filepath string, startLine, endLine int) (*ConflictContext, error)
ExtractConflictContext extracts the context around a merge conflict
type ConflictFilePayload ¶
type ConflictFilePayload struct {
Path string `json:"path"`
Language string `json:"language"`
FileType string `json:"file_type"`
Conflicts []ConflictHunkPayload `json:"conflicts"`
Context FileContext `json:"context"`
Metadata FileMetadata `json:"metadata"`
}
ConflictFilePayload represents a single file's conflict data for AI processing
type ConflictHunkPayload ¶
type ConflictHunkPayload struct {
ID string `json:"id"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
OursLines []string `json:"ours_lines"`
TheirsLines []string `json:"theirs_lines"`
BaseLines []string `json:"base_lines,omitempty"`
PreContext []string `json:"pre_context"`
PostContext []string `json:"post_context"`
ConflictType string `json:"conflict_type"`
}
ConflictHunkPayload represents a conflict hunk with minimal context
type ConflictPayload ¶
type ConflictPayload struct {
Metadata PayloadMetadata `json:"metadata"`
Files []ConflictFilePayload `json:"files"`
Context RepositoryContext `json:"context"`
Preferences ResolutionPreferences `json:"preferences"`
}
ConflictPayload represents the JSON payload sent to AI for resolution
func FromJSON ¶
func FromJSON(data []byte) (*ConflictPayload, error)
FromJSON creates a payload from JSON
func (*ConflictPayload) ToJSON ¶
func (p *ConflictPayload) ToJSON() ([]byte, error)
ToJSON converts the payload to JSON
type ContextExtractor ¶
type ContextExtractor interface {
ExtractContext(filePath string, content []string) FileContext
GetLanguage() string
}
ContextExtractor extracts language-specific context
type FileContext ¶
type FileContext struct {
BeforeLines []string `json:"before_lines,omitempty"`
AfterLines []string `json:"after_lines,omitempty"`
Imports []string `json:"imports,omitempty"`
Functions []string `json:"functions,omitempty"`
Classes []string `json:"classes,omitempty"`
}
FileContext provides surrounding context for better AI understanding
type FileFilter ¶
FileFilter represents a filter for excluding files
type FileMetadata ¶
type FileMetadata struct {
Size int64 `json:"size"`
LineCount int `json:"line_count"`
Encoding string `json:"encoding"`
LineEndings string `json:"line_endings"`
HasTests bool `json:"has_tests"`
IsGenerated bool `json:"is_generated"`
}
FileMetadata contains file-specific metadata
type GeneratedFileFilter ¶
type GeneratedFileFilter struct {
// contains filtered or unexported fields
}
GeneratedFileFilter filters out generated files
func NewGeneratedFileFilter ¶
func NewGeneratedFileFilter() *GeneratedFileFilter
NewGeneratedFileFilter creates a new generated file filter
func (*GeneratedFileFilter) GetReason ¶
func (f *GeneratedFileFilter) GetReason() string
GetReason returns the reason for exclusion
func (*GeneratedFileFilter) ShouldExclude ¶
func (f *GeneratedFileFilter) ShouldExclude(filePath string) bool
ShouldExclude returns true if the file is generated
type GenericContextExtractor ¶
type GenericContextExtractor struct {
// contains filtered or unexported fields
}
GenericContextExtractor provides basic context extraction for any language
func NewGenericContextExtractor ¶
func NewGenericContextExtractor(language string) *GenericContextExtractor
NewGenericContextExtractor creates a new generic context extractor
func (*GenericContextExtractor) ExtractContext ¶
func (g *GenericContextExtractor) ExtractContext(filePath string, content []string) FileContext
ExtractContext extracts basic context from any file
func (*GenericContextExtractor) GetLanguage ¶
func (g *GenericContextExtractor) GetLanguage() string
GetLanguage returns the language name
type GoContextExtractor ¶
type GoContextExtractor struct{}
GoContextExtractor extracts Go-specific context
func NewGoContextExtractor ¶
func NewGoContextExtractor() *GoContextExtractor
NewGoContextExtractor creates a new Go context extractor
func (*GoContextExtractor) ExtractContext ¶
func (g *GoContextExtractor) ExtractContext(filePath string, content []string) FileContext
ExtractContext extracts Go-specific context from file content
func (*GoContextExtractor) GetLanguage ¶
func (g *GoContextExtractor) GetLanguage() string
GetLanguage returns the language name
type JavaContextExtractor ¶
type JavaContextExtractor struct{}
JavaContextExtractor extracts Java-specific context
func NewJavaContextExtractor ¶
func NewJavaContextExtractor() *JavaContextExtractor
NewJavaContextExtractor creates a new Java context extractor
func (*JavaContextExtractor) ExtractContext ¶
func (j *JavaContextExtractor) ExtractContext(filePath string, content []string) FileContext
ExtractContext extracts Java-specific context
func (*JavaContextExtractor) GetLanguage ¶
func (j *JavaContextExtractor) GetLanguage() string
GetLanguage returns the language name
type JavaScriptContextExtractor ¶
type JavaScriptContextExtractor struct{}
JavaScriptContextExtractor extracts JavaScript-specific context
func NewJavaScriptContextExtractor ¶
func NewJavaScriptContextExtractor() *JavaScriptContextExtractor
NewJavaScriptContextExtractor creates a new JavaScript context extractor
func (*JavaScriptContextExtractor) ExtractContext ¶
func (j *JavaScriptContextExtractor) ExtractContext(filePath string, content []string) FileContext
ExtractContext extracts JavaScript-specific context
func (*JavaScriptContextExtractor) GetLanguage ¶
func (j *JavaScriptContextExtractor) GetLanguage() string
GetLanguage returns the language name
type LockfileFilter ¶
type LockfileFilter struct {
// contains filtered or unexported fields
}
LockfileFilter filters out lockfiles and dependency files
func NewLockfileFilter ¶
func NewLockfileFilter() *LockfileFilter
NewLockfileFilter creates a new lockfile filter
func (*LockfileFilter) GetReason ¶
func (f *LockfileFilter) GetReason() string
GetReason returns the reason for exclusion
func (*LockfileFilter) ShouldExclude ¶
func (f *LockfileFilter) ShouldExclude(filePath string) bool
ShouldExclude returns true if the file is a lockfile
type PayloadBuilder ¶
type PayloadBuilder struct {
// contains filtered or unexported fields
}
PayloadBuilder builds conflict payloads for AI processing
func NewPayloadBuilder ¶
func NewPayloadBuilder() *PayloadBuilder
NewPayloadBuilder creates a new payload builder with default configuration
func (*PayloadBuilder) BuildPayload ¶
func (pb *PayloadBuilder) BuildPayload(report *gitutils.ConflictReport) (*ConflictPayload, error)
BuildPayload creates a conflict payload from a conflict report
func (*PayloadBuilder) SetMaxContextLines ¶
func (pb *PayloadBuilder) SetMaxContextLines(maxLines int)
SetMaxContextLines sets the maximum number of context lines
type PayloadMetadata ¶
type PayloadMetadata struct {
Timestamp time.Time `json:"timestamp"`
RepoPath string `json:"repo_path"`
TotalFiles int `json:"total_files"`
TotalConflicts int `json:"total_conflicts"`
PayloadHash string `json:"payload_hash"`
Version string `json:"version"`
}
PayloadMetadata contains metadata about the conflict resolution request
type ProjectInfo ¶
type ProjectInfo struct {
Language string `json:"language"`
Framework string `json:"framework,omitempty"`
BuildTool string `json:"build_tool,omitempty"`
ConfigFiles []string `json:"config_files,omitempty"`
Conventions map[string]string `json:"conventions,omitempty"`
}
ProjectInfo contains project-specific information
type PythonContextExtractor ¶
type PythonContextExtractor struct{}
PythonContextExtractor extracts Python-specific context
func NewPythonContextExtractor ¶
func NewPythonContextExtractor() *PythonContextExtractor
NewPythonContextExtractor creates a new Python context extractor
func (*PythonContextExtractor) ExtractContext ¶
func (p *PythonContextExtractor) ExtractContext(filePath string, content []string) FileContext
ExtractContext extracts Python-specific context
func (*PythonContextExtractor) GetLanguage ¶
func (p *PythonContextExtractor) GetLanguage() string
GetLanguage returns the language name
type RepositoryContext ¶
type RepositoryContext struct {
BranchInfo BranchInfo `json:"branch_info"`
CommitInfo CommitInfo `json:"commit_info"`
ProjectInfo ProjectInfo `json:"project_info"`
Dependencies []string `json:"dependencies,omitempty"`
BuildSystem string `json:"build_system,omitempty"`
}
RepositoryContext provides repository-wide context
type ResolutionPreferences ¶
type ResolutionPreferences struct {
PreferOurs bool `json:"prefer_ours"`
PreferTheirs bool `json:"prefer_theirs"`
PreserveBoth bool `json:"preserve_both"`
ExcludeGenerated bool `json:"exclude_generated"`
ExcludeLockfiles bool `json:"exclude_lockfiles"`
MaxContextLines int `json:"max_context_lines"`
IncludeComments bool `json:"include_comments"`
IncludeTests bool `json:"include_tests"`
SensitivePatterns []string `json:"sensitive_patterns,omitempty"`
}
ResolutionPreferences contains preferences for how conflicts should be resolved
type SensitiveFileFilter ¶
type SensitiveFileFilter struct {
// contains filtered or unexported fields
}
SensitiveFileFilter filters out files that may contain sensitive information
func NewSensitiveFileFilter ¶
func NewSensitiveFileFilter() *SensitiveFileFilter
NewSensitiveFileFilter creates a new sensitive file filter
func (*SensitiveFileFilter) GetReason ¶
func (f *SensitiveFileFilter) GetReason() string
GetReason returns the reason for exclusion
func (*SensitiveFileFilter) ShouldExclude ¶
func (f *SensitiveFileFilter) ShouldExclude(filePath string) bool
ShouldExclude returns true if the file should be excluded
type TypeScriptContextExtractor ¶
type TypeScriptContextExtractor struct{}
TypeScriptContextExtractor extracts TypeScript-specific context
func NewTypeScriptContextExtractor ¶
func NewTypeScriptContextExtractor() *TypeScriptContextExtractor
NewTypeScriptContextExtractor creates a new TypeScript context extractor
func (*TypeScriptContextExtractor) ExtractContext ¶
func (t *TypeScriptContextExtractor) ExtractContext(filePath string, content []string) FileContext
ExtractContext extracts TypeScript-specific context
func (*TypeScriptContextExtractor) GetLanguage ¶
func (t *TypeScriptContextExtractor) GetLanguage() string
GetLanguage returns the language name