Documentation
¶
Index ¶
- func IsTextFile(filename string) bool
- func List() []string
- func MustRegister(processor LanguageProcessor)
- func ProcessWithDependencyAnalysis(ctx context.Context, proc *Processor, filePath string, opts ProcessOptions) (*ir.DistilledFile, error)
- func Register(processor LanguageProcessor) error
- type BaseProcessor
- type ClassDefinition
- type DependencyAnalyzer
- type DistilledCodeSnippet
- type DistilledMultiFile
- type DistilledProject
- type FileResult
- type FileTask
- type FunctionDefinition
- type LanguageProcessor
- type MultiError
- type ProcessOptions
- type Processor
- func (p *Processor) CanProcess(filename string) bool
- func (p *Processor) GetLanguage(filename string) string
- func (p *Processor) GetSupportedExtensions() []string
- func (p *Processor) Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
- func (p *Processor) ProcessFile(filename string, opts ProcessOptions) (*ir.DistilledFile, error)
- func (p *Processor) ProcessPath(path string, opts ProcessOptions) (ir.DistilledNode, error)
- type ProcessorError
- type RawProcessor
- func (p *RawProcessor) CanProcessRaw(filename string) bool
- func (p *RawProcessor) Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
- func (p *RawProcessor) ProcessWithOptions(ctx context.Context, reader io.Reader, filename string, opts ProcessOptions) (*ir.DistilledFile, error)
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTextFile ¶
IsTextFile checks if a file might be a text file based on extension
func MustRegister ¶
func MustRegister(processor LanguageProcessor)
MustRegister registers a processor and panics on error
func ProcessWithDependencyAnalysis ¶ added in v1.4.0
func ProcessWithDependencyAnalysis(ctx context.Context, proc *Processor, filePath string, opts ProcessOptions) (*ir.DistilledFile, error)
ProcessWithDependencyAnalysis processes a file with dependency-aware analysis
func Register ¶
func Register(processor LanguageProcessor) error
Register adds a processor to the default registry
Types ¶
type BaseProcessor ¶
type BaseProcessor struct {
// contains filtered or unexported fields
}
BaseProcessor provides common functionality for language processors
func NewBaseProcessor ¶
func NewBaseProcessor(language, version string, extensions []string) BaseProcessor
NewBaseProcessor creates a new base processor
func (BaseProcessor) CanProcess ¶
func (p BaseProcessor) CanProcess(filename string) bool
CanProcess implements LanguageProcessor
func (BaseProcessor) Language ¶
func (p BaseProcessor) Language() string
Language implements LanguageProcessor
func (BaseProcessor) SupportedExtensions ¶
func (p BaseProcessor) SupportedExtensions() []string
SupportedExtensions implements LanguageProcessor
func (BaseProcessor) Version ¶
func (p BaseProcessor) Version() string
Version implements LanguageProcessor
type ClassDefinition ¶ added in v1.4.0
type ClassDefinition struct {
Name string
FQN string
FilePath string
StartByte uint32
EndByte uint32
Language string
}
ClassDefinition holds metadata about a class for distillation
type DependencyAnalyzer ¶ added in v1.4.0
type DependencyAnalyzer struct {
// contains filtered or unexported fields
}
DependencyAnalyzer performs cross-file dependency analysis and call graph traversal
func NewDependencyAnalyzer ¶ added in v1.4.0
func NewDependencyAnalyzer(projectRoot string, maxDepth int) (*DependencyAnalyzer, error)
NewDependencyAnalyzer creates a new dependency analyzer
func (*DependencyAnalyzer) AnalyzeDependencies ¶ added in v1.4.0
func (da *DependencyAnalyzer) AnalyzeDependencies(ctx context.Context, file *ir.DistilledFile) (*ir.DistilledFile, error)
AnalyzeDependencies performs dependency-aware analysis on a distilled file
func (*DependencyAnalyzer) CreateDistilledProject ¶ added in v1.4.0
func (da *DependencyAnalyzer) CreateDistilledProject(ctx context.Context, entryPoints []string) (*DistilledProject, error)
CreateDistilledProject creates a multi-file distilled project
type DistilledCodeSnippet ¶ added in v1.4.0
type DistilledCodeSnippet struct {
StartByte uint32
EndByte uint32
FQN string // Fully Qualified Name of the symbol
Type string // "function", "class", "method"
}
DistilledCodeSnippet represents a piece of code extracted from a file
type DistilledMultiFile ¶ added in v1.4.0
type DistilledMultiFile struct {
OriginalFilePath string
OriginalContent []byte
Snippets []DistilledCodeSnippet
DistilledContent string
Language string
}
DistilledMultiFile represents a single file with its distilled content
type DistilledProject ¶ added in v1.4.0
type DistilledProject struct {
Files map[string]*DistilledMultiFile // Map of file path to distilled file
EntryPoints []string // Entry point FQNs
}
DistilledProject is the container for all distilled files
type FileResult ¶
type FileResult struct {
Index int
Result *ir.DistilledFile
Error error
}
FileResult represents the result of processing a file
type FunctionDefinition ¶ added in v1.4.0
type FunctionDefinition struct {
Name string
FQN string
FilePath string
StartByte uint32
EndByte uint32
Language string
}
FunctionDefinition holds metadata about a function for distillation
type LanguageProcessor ¶
type LanguageProcessor interface {
// Language returns the language identifier (e.g., "go", "python", "javascript")
Language() string
// Version returns the processor version
Version() string
// SupportedExtensions returns file extensions this processor handles
SupportedExtensions() []string
// CanProcess checks if this processor can handle the given file
CanProcess(filename string) bool
// Process parses source code and returns the IR representation
Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
// ProcessWithOptions parses with specific options
ProcessWithOptions(ctx context.Context, reader io.Reader, filename string, opts ProcessOptions) (*ir.DistilledFile, error)
}
LanguageProcessor defines the interface for language-specific processors
func Get ¶
func Get(language string) (LanguageProcessor, bool)
Get returns a processor from the default registry
func GetByFilename ¶
func GetByFilename(filename string) (LanguageProcessor, bool)
GetByFilename returns a processor from the default registry
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError represents multiple processing errors
func (MultiError) Error ¶
func (e MultiError) Error() string
type ProcessOptions ¶
type ProcessOptions struct {
// IncludeImplementation includes function/method bodies
IncludeImplementation bool
// IncludeComments includes comment nodes
IncludeComments bool
// IncludeImports includes import statements
IncludeImports bool
// IncludePrivate includes private/internal declarations (legacy - removes both private and protected)
IncludePrivate bool
// RemovePrivateOnly removes only private members (not protected)
RemovePrivateOnly bool
// RemoveProtectedOnly removes only protected members (not private)
RemoveProtectedOnly bool
// RemoveInternalOnly removes only internal/package-private members
RemoveInternalOnly bool
// IncludePublic includes public members (for formatter instructions)
IncludePublic bool
// IncludeProtected includes protected members (for formatter instructions)
IncludeProtected bool
// IncludeInternal includes internal/package-private members (for formatter instructions)
IncludeInternal bool
// IncludeDocstrings includes documentation comments (when false, removes them)
IncludeDocstrings bool
// IncludeAnnotations includes decorators/annotations (when false, removes them)
IncludeAnnotations bool
// IncludeFields includes class fields/properties (when false, removes them)
IncludeFields bool
// IncludeMethods includes methods/functions (when false, removes them)
IncludeMethods bool
// ExpandSymbols holds glob patterns; functions/methods whose name matches
// keep their implementation even when implementations are otherwise stripped.
ExpandSymbols []string
// MaxDepth limits the depth of nested structures
MaxDepth int
// SymbolResolution enables symbol cross-referencing
SymbolResolution bool
// IncludeLineNumbers adds line number information
IncludeLineNumbers bool
// Workers specifies the number of parallel workers for processing
// 0 = auto (80% of CPU cores), 1 = serial processing
Workers int
// RawMode processes all text files without parsing
RawMode bool
// Recursive controls whether to process directories recursively
Recursive bool
// BasePath is the original path provided by the user (for relative path calculation)
BasePath string
// FilePathType controls how paths appear in output: "relative" or "absolute"
FilePathType string
// RelativePathPrefix is a custom prefix for relative paths (e.g., "src/")
RelativePathPrefix string
// IncludePatterns are file patterns to include (e.g., "*.go", "*.py")
IncludePatterns []string
// ExcludePatterns are file patterns to exclude (e.g., "*test*", "*.json")
ExcludePatterns []string
// ExplicitInclude indicates this file was explicitly included via !pattern
ExplicitInclude bool
}
ProcessOptions configures the processing behavior
func DefaultProcessOptions ¶
func DefaultProcessOptions() ProcessOptions
DefaultProcessOptions returns default processing options
func (ProcessOptions) ToStripperOptions ¶
func (opts ProcessOptions) ToStripperOptions() stripper.Options
ToStripperOptions converts ProcessOptions to stripper.Options
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor processes files and directories
func NewWithContext ¶
NewWithContext creates a new processor with a context
func (*Processor) CanProcess ¶
CanProcess checks if a file can be processed
func (*Processor) GetLanguage ¶
GetLanguage returns the language for a file
func (*Processor) GetSupportedExtensions ¶
GetSupportedExtensions returns all supported file extensions
func (*Processor) Process ¶
func (p *Processor) Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
Process processes a reader
func (*Processor) ProcessFile ¶
func (p *Processor) ProcessFile(filename string, opts ProcessOptions) (*ir.DistilledFile, error)
ProcessFile processes a single file
func (*Processor) ProcessPath ¶
func (p *Processor) ProcessPath(path string, opts ProcessOptions) (ir.DistilledNode, error)
ProcessPath processes a file or directory
type ProcessorError ¶
type ProcessorError struct {
File string
Line int
Column int
Message string
Severity string // "error", "warning", "info"
Code string // Error code for tooling
}
ProcessorError represents a processing error with context
func (ProcessorError) Error ¶
func (e ProcessorError) Error() string
type RawProcessor ¶
type RawProcessor struct {
BaseProcessor
}
RawProcessor handles all text files without parsing
func NewRawProcessor ¶
func NewRawProcessor() *RawProcessor
NewRawProcessor creates a new raw processor
func (*RawProcessor) CanProcessRaw ¶
func (p *RawProcessor) CanProcessRaw(filename string) bool
CanProcessRaw checks if a file can be processed as raw text
func (*RawProcessor) Process ¶
func (p *RawProcessor) Process(ctx context.Context, reader io.Reader, filename string) (*ir.DistilledFile, error)
Process implements LanguageProcessor
func (*RawProcessor) ProcessWithOptions ¶
func (p *RawProcessor) ProcessWithOptions(ctx context.Context, reader io.Reader, filename string, opts ProcessOptions) (*ir.DistilledFile, error)
ProcessWithOptions implements LanguageProcessor
type Registry ¶
type Registry interface {
// Register adds a processor to the registry
Register(processor LanguageProcessor) error
// Get returns a processor for the given language
Get(language string) (LanguageProcessor, bool)
// GetByFilename returns a processor that can handle the file
GetByFilename(filename string) (LanguageProcessor, bool)
// List returns all registered language identifiers
List() []string
}
Registry manages language processors