preset

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSafetyThreshold = "HIGH"

DefaultSafetyThreshold is the default safety threshold value

Variables

View Source
var BuiltInPresets = map[string]Preset{
	"quick": {
		Name:        "quick",
		Description: "Fast, high-level review focusing on critical issues only",
		Prompt: `## Review Mode: Quick Review

Focus ONLY on:
- Critical bugs that would cause crashes or data loss
- Security vulnerabilities
- Obvious logic errors

Skip:
- Style suggestions
- Minor improvements
- Documentation issues
- Performance micro-optimizations

Keep your response concise - aim for the top 3-5 most important issues only.`,
	},
	"strict": {
		Name:        "strict",
		Description: "Thorough, nitpicky review covering all aspects",
		Prompt: `## Review Mode: Strict Review

Be extremely thorough and nitpicky. Review EVERYTHING:
- Every possible edge case
- All error handling paths
- Memory and resource management
- Thread safety and race conditions
- API design and consistency
- Documentation completeness
- Test coverage gaps
- Code style and formatting
- Naming conventions
- Dead code and unused imports

Flag even minor issues. Nothing is too small to mention.`,
	},
	"security": {
		Name:        "security",
		Description: "Security-focused analysis for vulnerabilities",
		Prompt: `## Review Mode: Security Audit

Focus exclusively on security concerns:
- Input validation and sanitization
- SQL injection vulnerabilities
- XSS and CSRF risks
- Authentication and authorization flaws
- Hardcoded secrets or credentials
- Insecure cryptographic practices
- Path traversal vulnerabilities
- Command injection risks
- Sensitive data exposure
- Insecure deserialization
- Dependency vulnerabilities
- Access control issues

Rate each finding by severity (Critical/High/Medium/Low).`,
	},
	"performance": {
		Name:        "performance",
		Description: "Performance optimization focused review",
		Prompt: `## Review Mode: Performance Review

Focus on performance implications:
- Unnecessary allocations and memory usage
- Inefficient algorithms (O(n²) when O(n) possible)
- Database query optimization (N+1 queries)
- Caching opportunities
- Goroutine and channel efficiency
- Buffer reuse opportunities
- Unnecessary copying of data
- Lock contention and synchronization
- I/O optimization
- Lazy loading opportunities
- Connection pooling

Suggest specific optimizations with expected impact.`,
	},
	"logic": {
		Name:        "logic",
		Description: "Logic and algorithm correctness verification",
		Prompt: `## Review Mode: Logic Review

Focus on correctness and logic:
- Algorithm correctness
- Edge case handling
- Boundary conditions
- Off-by-one errors
- Null/nil handling
- Boolean logic errors
- State machine correctness
- Control flow issues
- Loop termination conditions
- Recursive function base cases
- Mathematical operations accuracy
- Business logic correctness

Trace through the code logic step by step.`,
	},
	"style": {
		Name:        "style",
		Description: "Code style and formatting review",
		Prompt: `## Review Mode: Style Review

Focus on code style and readability:
- Consistent formatting
- Idiomatic patterns for the language
- Code organization
- Function and file length
- Comment quality and necessity
- Magic numbers and constants
- DRY principle violations
- SOLID principle adherence
- Clean code practices
- Readability improvements
- Consistent error handling patterns

Reference style guides where applicable.`,
	},
	"typo": {
		Name:        "typo",
		Description: "Typo and spelling error detection",
		Prompt: `## Review Mode: Typo Detection

Focus on finding typos and spelling errors:
- Variable name typos
- Function name typos
- Comment spelling errors
- String literal typos
- Documentation errors
- Inconsistent spelling (e.g., color vs colour)
- Common programming typos (recieve, occured, etc.)
- Copy-paste errors
- Wrong word usage

List each typo with its location and correct spelling.`,
	},
	"naming": {
		Name:        "naming",
		Description: "Variable and function naming review",
		Prompt: `## Review Mode: Naming Review

Focus on naming quality:
- Descriptive variable names
- Self-documenting function names
- Consistent naming conventions
- Avoiding abbreviations
- Domain-appropriate terminology
- Boolean naming (is/has/can prefixes)
- Collection naming (plural forms)
- Constant naming (UPPER_CASE where appropriate)
- Package/module naming
- Avoiding generic names (data, info, temp)
- Name length appropriateness

Suggest specific renamed alternatives.`,
	},
}

BuiltInPresets contains all built-in review presets

Functions

func ClearDefaultPreset

func ClearDefaultPreset() error

ClearDefaultPreset removes the default preset from the config file

func DeleteSystemPrompt

func DeleteSystemPrompt() error

DeleteSystemPrompt removes the custom system prompt file to restore default

func GetAllPresetNames

func GetAllPresetNames() []string

GetAllPresetNames returns a list of all preset names (built-in + custom)

func GetDefaultPreset

func GetDefaultPreset() (string, error)

GetDefaultPreset returns the default preset name from config, or empty string if not set

func GetSystemPromptPath

func GetSystemPromptPath() (string, error)

GetSystemPromptPath returns the path to the system prompt preset file

func ListNames

func ListNames() string

ListNames returns a comma-separated list of available preset names (built-in + custom)

func LoadSystemPrompt

func LoadSystemPrompt() (string, bool, error)

LoadSystemPrompt loads the system prompt from custom file or returns empty string to use default Returns the prompt text and a boolean indicating if custom prompt was found

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig saves the configuration to ~/.config/revcli/config.yaml

func SaveSystemPrompt

func SaveSystemPrompt(promptText string) error

SaveSystemPrompt saves a custom system prompt to file

func SetDefaultPreset

func SetDefaultPreset(presetName string) error

SetDefaultPreset sets the default preset in the config file

Types

type Config

type Config struct {
	DefaultPreset string        `yaml:"default_preset,omitempty"`
	Gemini        *GeminiConfig `yaml:"gemini,omitempty"`
}

Config defines the revcli configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from ~/.config/revcli/config.yaml

type GeminiConfig

type GeminiConfig struct {
	ModelParams    *ModelParams    `yaml:"model_params,omitempty"`
	SafetySettings *SafetySettings `yaml:"safety_settings,omitempty"`
}

GeminiConfig defines Gemini API client configuration

type ModelParams

type ModelParams struct {
	Temperature float32 `yaml:"temperature,omitempty"`
	TopP        float32 `yaml:"top_p,omitempty"`
	TopK        int     `yaml:"top_k,omitempty"`
}

ModelParams defines model generation parameters

type Preset

type Preset struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Prompt      string `yaml:"prompt"`
	Replace     bool   `yaml:"replace,omitempty"` // If true, replace base prompt instead of appending
}

Preset defines a review preset configuration

func Get

func Get(name string) (*Preset, error)

Get returns a preset by name, checking built-in first then custom

func List

func List() []Preset

List returns all built-in presets

func (*Preset) ApplyToPrompt

func (p *Preset) ApplyToPrompt(basePrompt string) string

ApplyToPrompt appends the preset's prompt modifier to the base system prompt

func (*Preset) MarshalYAML

func (p *Preset) MarshalYAML() (interface{}, error)

MarshalYAML implements custom YAML marshaling to use literal block scalars for multiline prompts

type SafetySettings

type SafetySettings struct {
	Threshold string `yaml:"threshold,omitempty"` // "HIGH", "MEDIUM_AND_ABOVE", "LOW_AND_ABOVE", "NONE", "OFF"
}

SafetySettings defines safety filtering configuration

Jump to

Keyboard shortcuts

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