code

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package code provides code-aware features: context extraction, lenses, actions, and explainer. See ../REFACTOR_PLAN.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFix

func ApplyFix(action CodeAction, content string) (string, error)

func DescribeControlFlow

func DescribeControlFlow(funcBody string) string

func DetectSideEffects

func DetectSideEffects(funcBody string) []string

func FormatContext

func FormatContext(ctx *CodeContext) string

func FormatExplanation

func FormatExplanation(exp *CodeExplanation) string

func FormatLenses

func FormatLenses(file string, lenses []CodeLens) string

func FormatSuggestions

func FormatSuggestions(actions []CodeAction, maxDisplay int) string

func InferPurpose

func InferPurpose(name string, params, returns []string) string

Types

type ActionDetector

type ActionDetector struct {
	Rules []ActionRule
	// contains filtered or unexported fields
}

func NewActionDetector

func NewActionDetector() *ActionDetector

func (*ActionDetector) Detect

func (ad *ActionDetector) Detect(path, content string) []CodeAction

func (*ActionDetector) DetectForDiff

func (ad *ActionDetector) DetectForDiff(diff string) []CodeAction

type ActionRule

type ActionRule struct {
	ID          string
	Name        string
	Category    string
	Language    string
	Pattern     *regexp.Regexp
	Antipattern *regexp.Regexp
	Priority    int
	Message     string
	FixTemplate string
}

type CodeAction

type CodeAction struct {
	ID          string
	Title       string
	Description string
	File        string
	Line        int
	Category    string
	Priority    int
	Fix         string
	Confidence  float64
}

type CodeContext

type CodeContext struct {
	Snippets    []CodeSnippet
	TotalTokens int
	Query       string
	// contains filtered or unexported fields
}

type CodeExplainer

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

func NewCodeExplainer

func NewCodeExplainer() *CodeExplainer

func (*CodeExplainer) ExplainFile

func (ce *CodeExplainer) ExplainFile(path, content string) (*CodeExplanation, error)

func (*CodeExplainer) ExplainFunction

func (ce *CodeExplainer) ExplainFunction(file, content, funcName string) (*CodeExplanation, error)

func (*CodeExplainer) ExplainType

func (ce *CodeExplainer) ExplainType(file, content, typeName string) (*CodeExplanation, error)

type CodeExplanation

type CodeExplanation struct {
	File         string
	Symbol       string
	Summary      string
	Sections     []ExplanationSection
	Complexity   string
	Dependencies []string
	UsedBy       []string
}

type CodeLens

type CodeLens struct {
	File     string
	Line     int
	Label    string
	Category string
	Command  string
	Tooltip  string
}

func FilterByCategory

func FilterByCategory(lenses []CodeLens, category string) []CodeLens

func GenerateAgeLens

func GenerateAgeLens(file, content string) []CodeLens

func GenerateComplexityLens

func GenerateComplexityLens(file, content string) []CodeLens

func GenerateCoverageLens

func GenerateCoverageLens(file, content string) []CodeLens

func GenerateReferenceLens

func GenerateReferenceLens(file, content string) []CodeLens

func GenerateTestLens

func GenerateTestLens(file, content string) []CodeLens

type CodeLensProvider

type CodeLensProvider struct {
	Providers map[string]LensGenerator
	// contains filtered or unexported fields
}

func NewCodeLensProvider

func NewCodeLensProvider() *CodeLensProvider

func (*CodeLensProvider) Generate

func (p *CodeLensProvider) Generate(file, content string) []CodeLens

func (*CodeLensProvider) Register

func (p *CodeLensProvider) Register(name string, generator LensGenerator)

type CodeSnippet

type CodeSnippet struct {
	File      string
	StartLine int
	EndLine   int
	Content   string
	Relevance float64
	Type      string
	Symbol    string
}

type ContextExtractor

type ContextExtractor struct {
	ProjectDir string
	MaxTokens  int
	// contains filtered or unexported fields
}

func NewContextExtractor

func NewContextExtractor(projectDir string, maxTokens int) *ContextExtractor

func (*ContextExtractor) ExtractForTask

func (ce *ContextExtractor) ExtractForTask(task string) (*CodeContext, error)

func (*ContextExtractor) ExtractFunction

func (ce *ContextExtractor) ExtractFunction(file, funcName string) (*CodeSnippet, error)

func (*ContextExtractor) ExtractImports

func (ce *ContextExtractor) ExtractImports(file string) (*CodeSnippet, error)

func (*ContextExtractor) ExtractSurrounding

func (ce *ContextExtractor) ExtractSurrounding(file string, line, contextLines int) (*CodeSnippet, error)

func (*ContextExtractor) ExtractType

func (ce *ContextExtractor) ExtractType(file, typeName string) (*CodeSnippet, error)

func (*ContextExtractor) FindRelevantSymbols

func (ce *ContextExtractor) FindRelevantSymbols(query string, limit int) []CodeSnippet

func (*ContextExtractor) RankSnippets

func (ce *ContextExtractor) RankSnippets(snippets []CodeSnippet, query string) []CodeSnippet

type ExplanationSection

type ExplanationSection struct {
	Title   string
	Content string
	CodeRef string
}

type LensGenerator

type LensGenerator func(file, content string) []CodeLens

Jump to

Keyboard shortcuts

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