commands

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OutputFormatJSON represents JSON output format
	OutputFormatJSON = "json"
	// OutputFormatText represents text output format
	OutputFormatText = "text"
)

Variables

This section is empty.

Functions

func IsRecoverable

func IsRecoverable(err error) bool

IsRecoverable checks if an error is recoverable

func SafeApplyResolutions

func SafeApplyResolutions(
	repoPath string,
	resolutions []gitutils.ConflictResolution,
	options SafeApplyOptions,
) (*gitutils.ResolutionResult, error)

SafeApplyResolutions applies resolutions with validation and safety checks

func ShouldRetry

func ShouldRetry(err error, attempt int, maxAttempts int) bool

ShouldRetry determines if an operation should be retried based on the error

func ValidateProject

func ValidateProject(rootPath, outputFile string, timeoutSeconds int, verbose bool) error

ValidateProject is a convenience function for running validation

Types

type AIApplyCommand

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

AIApplyCommand implements the ai-apply subcommand

func NewAIApplyCommand

func NewAIApplyCommand(options AIApplyOptions) *AIApplyCommand

NewAIApplyCommand creates a new ai-apply command

func (*AIApplyCommand) Execute

func (a *AIApplyCommand) Execute() (*AIApplyResult, error)

Execute runs the ai-apply command

type AIApplyOptions

type AIApplyOptions struct {
	PayloadFile    string
	RepoPath       string
	APIKey         string
	APIEndpoint    string
	OutputFile     string
	DryRun         bool
	Verbose        bool
	AutoApply      bool
	MinConfidence  float64
	BackupFiles    bool
	MaxRetries     int
	TimeoutSeconds int
}

AIApplyOptions contains options for the ai-apply command

type AIApplyResult

type AIApplyResult struct {
	Success            bool                          `json:"success"`
	ProcessedFiles     int                           `json:"processed_files"`
	AppliedResolutions int                           `json:"applied_resolutions"`
	SkippedResolutions int                           `json:"skipped_resolutions"`
	FailedResolutions  int                           `json:"failed_resolutions"`
	Resolutions        []gitutils.ConflictResolution `json:"resolutions"`
	ApplicationResult  *gitutils.ResolutionResult    `json:"application_result,omitempty"`
	ErrorMessage       string                        `json:"error_message,omitempty"`
	AIResponse         *AIResolveResponse            `json:"ai_response,omitempty"`
}

AIApplyResult represents the result of the AI application

func ApplyAIResolutions

func ApplyAIResolutions(payloadFile, repoPath, apiKey string) (*AIApplyResult, error)

ApplyAIResolutions is a convenience function for applying AI resolutions

func ApplyAIResolutionsDryRun

func ApplyAIResolutionsDryRun(payloadFile, repoPath, apiKey string) (*AIApplyResult, error)

ApplyAIResolutionsDryRun is a convenience function for dry-run AI resolution

type AIPreferences

type AIPreferences struct {
	MinConfidence    float64 `json:"min_confidence"`
	PreferExplicit   bool    `json:"prefer_explicit"`
	IncludeReasoning bool    `json:"include_reasoning"`
	PreserveBoth     bool    `json:"preserve_both_when_uncertain"`
	MaxResolutions   int     `json:"max_resolutions"`
}

AIPreferences contains preferences for AI resolution

type AIResolveRequest

type AIResolveRequest struct {
	Payload     *payload.ConflictPayload `json:"payload"`
	Preferences AIPreferences            `json:"preferences"`
	Context     string                   `json:"context"`
}

AIResolveRequest represents the request sent to Claude Code API

type AIResolveResponse

type AIResolveResponse struct {
	Success           bool                          `json:"success"`
	Resolutions       []gitutils.ConflictResolution `json:"resolutions"`
	OverallConfidence float64                       `json:"overall_confidence"`
	Reasoning         string                        `json:"reasoning,omitempty"`
	Warnings          []string                      `json:"warnings,omitempty"`
	ErrorMessage      string                        `json:"error_message,omitempty"`
	RequestID         string                        `json:"request_id,omitempty"`
	ProcessingTime    float64                       `json:"processing_time,omitempty"`
}

AIResolveResponse represents the response from Claude Code API

type DetectCommand

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

DetectCommand implements the detect subcommand

func NewDetectCommand

func NewDetectCommand(options DetectOptions) *DetectCommand

NewDetectCommand creates a new detect command

func (*DetectCommand) Execute

func (d *DetectCommand) Execute() (*DetectResult, error)

Execute runs the detect command

type DetectOptions

type DetectOptions struct {
	RepoPath        string
	OutputFormat    string // "json", "text"
	OutputFile      string
	IncludeContext  bool
	MaxContextLines int
	Verbose         bool
	ExcludePatterns []string
	// Performance metrics collection support
	EnableMetrics bool
	MetricsFile   string
	// Timeout support for long-running operations
	TimeoutSeconds int
	// Retry mechanism for failed operations
	MaxRetries int
	RetryDelay time.Duration
	// Enhanced logging options
	EnableDetailed bool
	LogFile        string
}

DetectOptions contains options for the detect command

type DetectResult

type DetectResult struct {
	Success         bool                     `json:"success"`
	ConflictReport  *gitutils.ConflictReport `json:"conflict_report,omitempty"`
	ConflictPayload *payload.ConflictPayload `json:"conflict_payload,omitempty"`
	ErrorMessage    string                   `json:"error_message,omitempty"`
	Summary         DetectSummary            `json:"summary"`
}

DetectResult represents the result of conflict detection

func DetectConflicts

func DetectConflicts(repoPath string) (*DetectResult, error)

DetectConflicts is a convenience function for simple conflict detection

func DetectConflictsText

func DetectConflictsText(repoPath string) (*DetectResult, error)

DetectConflictsText is a convenience function for text format output

func DetectConflictsVerbose

func DetectConflictsVerbose(repoPath string, outputFile string) (*DetectResult, error)

DetectConflictsVerbose is a convenience function for verbose conflict detection

type DetectSummary

type DetectSummary struct {
	TotalFiles       int    `json:"total_files"`
	TotalConflicts   int    `json:"total_conflicts"`
	ExcludedFiles    int    `json:"excluded_files"`
	ProcessableFiles int    `json:"processable_files"`
	RepoPath         string `json:"repo_path"`
	InMergeState     bool   `json:"in_merge_state"`
}

DetectSummary provides a summary of the detection results

type ErrorHandler

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

ErrorHandler provides centralized error handling and recovery

func NewErrorHandler

func NewErrorHandler(verbose bool) *ErrorHandler

NewErrorHandler creates a new error handler

func (*ErrorHandler) Handle

func (eh *ErrorHandler) Handle(err error) string

Handle processes an error and returns a user-friendly message

type ErrorType

type ErrorType string

ErrorType represents different types of errors that can occur

const (
	ErrorTypeRepository     ErrorType = "repository"
	ErrorTypeConflict       ErrorType = "conflict"
	ErrorTypePayload        ErrorType = "payload"
	ErrorTypeAPI            ErrorType = "api"
	ErrorTypeFileSystem     ErrorType = "filesystem"
	ErrorTypeValidation     ErrorType = "validation"
	ErrorTypeAuthentication ErrorType = "authentication"
	ErrorTypeNetwork        ErrorType = "network"
	ErrorTypeConfiguration  ErrorType = "configuration"
)

func GetErrorType

func GetErrorType(err error) ErrorType

GetErrorType returns the error type if it's a SyncwrightError

type FormatCommand

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

FormatCommand implements the format subcommand

func NewFormatCommand

func NewFormatCommand(options FormatOptions) *FormatCommand

NewFormatCommand creates a new format command

func (*FormatCommand) Execute

func (f *FormatCommand) Execute() (*FormatResult, error)

Execute runs the format command

type FormatOptions

type FormatOptions struct {
	RepoPath            string               `json:"repo_path"`
	OutputFile          string               `json:"output_file"`
	OutputFormat        string               `json:"output_format"` // "json", "text"
	DryRun              bool                 `json:"dry_run"`
	Verbose             bool                 `json:"verbose"`
	PreferredFormatters []string             `json:"preferred_formatters,omitempty"`
	ExcludeFormatters   []string             `json:"exclude_formatters,omitempty"`
	IncludeExtensions   []string             `json:"include_extensions,omitempty"`
	ExcludeExtensions   []string             `json:"exclude_extensions,omitempty"`
	FilePaths           []string             `json:"file_paths,omitempty"`
	ScanRecent          bool                 `json:"scan_recent"`
	RecentDays          int                  `json:"recent_days"`
	FormatOptions       format.FormatOptions `json:"format_options"`
}

FormatOptions contains options for the format command

type FormatResult

type FormatResult struct {
	Success       bool                       `json:"success"`
	FormatCommand *format.FormatCommand      `json:"format_command,omitempty"`
	ErrorMessage  string                     `json:"error_message,omitempty"`
	Summary       FormatSummary              `json:"summary"`
	Discovery     *format.FormatterDiscovery `json:"discovery,omitempty"`
}

FormatResult represents the result of the format command

func FormatAllFiles

func FormatAllFiles(repoPath string) (*FormatResult, error)

FormatAllFiles is a convenience function for formatting all files in a repository

func FormatFiles

func FormatFiles(repoPath string, filePaths []string) (*FormatResult, error)

FormatFiles is a convenience function for simple file formatting

func FormatRecentFiles

func FormatRecentFiles(repoPath string, days int) (*FormatResult, error)

FormatRecentFiles is a convenience function for formatting recently modified files

type FormatSummary

type FormatSummary struct {
	FilesScanned        int      `json:"files_scanned"`
	FilesProcessed      int      `json:"files_processed"`
	FilesFormatted      int      `json:"files_formatted"`
	FilesFailed         int      `json:"files_failed"`
	AvailableFormatters int      `json:"available_formatters"`
	SupportedExtensions []string `json:"supported_extensions"`
	RepoPath            string   `json:"repo_path"`
	Timestamp           string   `json:"timestamp"`
	Duration            string   `json:"duration"`
}

FormatSummary provides a summary of the formatting results

type ProgressReporter

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

ProgressReporter provides progress reporting for long operations

func NewProgressReporter

func NewProgressReporter(total int, verbose bool) *ProgressReporter

NewProgressReporter creates a new progress reporter

func (*ProgressReporter) Complete

func (pr *ProgressReporter) Complete(message string)

Complete marks the progress as complete

func (*ProgressReporter) Update

func (pr *ProgressReporter) Update(current int, message string)

Update updates the progress and optionally displays it

type SafeApplyOptions

type SafeApplyOptions struct {
	ValidateBeforeApply        bool
	ContinueOnValidationErrors bool
	CreateBackups              bool
	Verbose                    bool
}

SafeApplyOptions contains options for safe resolution application

func DefaultSafeApplyOptions

func DefaultSafeApplyOptions() SafeApplyOptions

DefaultSafeApplyOptions returns default safe apply options

type SyncwrightError

type SyncwrightError struct {
	Type        ErrorType `json:"type"`
	Message     string    `json:"message"`
	Details     string    `json:"details,omitempty"`
	FilePath    string    `json:"file_path,omitempty"`
	LineNumber  int       `json:"line_number,omitempty"`
	Suggestions []string  `json:"suggestions,omitempty"`
	Recoverable bool      `json:"recoverable"`
}

SyncwrightError represents a structured error with context

func NewAPIError

func NewAPIError(message, details string, statusCode int) *SyncwrightError

NewAPIError creates a new API-related error

func NewAuthenticationError

func NewAuthenticationError(message, details string) *SyncwrightError

NewAuthenticationError creates a new authentication-related error

func NewConfigurationError

func NewConfigurationError(message, details string) *SyncwrightError

NewConfigurationError creates a new configuration-related error

func NewConflictError

func NewConflictError(message, details, filePath string, lineNumber int) *SyncwrightError

NewConflictError creates a new conflict-related error

func NewFileSystemError

func NewFileSystemError(message, details, filePath string) *SyncwrightError

NewFileSystemError creates a new filesystem-related error

func NewNetworkError

func NewNetworkError(message, details string) *SyncwrightError

NewNetworkError creates a new network-related error

func NewPayloadError

func NewPayloadError(message, details string, recoverable bool) *SyncwrightError

NewPayloadError creates a new payload-related error

func NewRepositoryError

func NewRepositoryError(message, details string, suggestions []string) *SyncwrightError

NewRepositoryError creates a new repository-related error

func NewValidationError

func NewValidationError(message, details string) *SyncwrightError

NewValidationError creates a new validation-related error

func WrapError

func WrapError(err error, errorType ErrorType, message string) *SyncwrightError

WrapError wraps a standard error as a SyncwrightError

func (*SyncwrightError) Error

func (e *SyncwrightError) Error() string

Error implements the error interface

type ValidateCommand

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

ValidateCommand implements the validate subcommand

func NewValidateCommand

func NewValidateCommand(options ValidateOptions) *ValidateCommand

NewValidateCommand creates a new validate command

func (*ValidateCommand) Execute

func (v *ValidateCommand) Execute() error

Execute runs the validate command

type ValidateOptions

type ValidateOptions struct {
	RootPath       string
	OutputFile     string
	TimeoutSeconds int
	Verbose        bool
}

ValidateOptions contains options for the validate command

type ValidationResult

type ValidationResult struct {
	Valid         bool     `json:"valid"`
	Errors        []string `json:"errors,omitempty"`
	Warnings      []string `json:"warnings,omitempty"`
	SyntaxValid   bool     `json:"syntax_valid"`
	SemanticValid bool     `json:"semantic_valid"`
}

ValidationResult represents the result of validating a resolution

func ValidateResolution

func ValidateResolution(resolution gitutils.ConflictResolution, repoPath string) ValidationResult

ValidateResolution validates a conflict resolution before applying it

Jump to

Keyboard shortcuts

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