Documentation
¶
Index ¶
- Constants
- Variables
- func AddFeedback(db *sql.DB, userInput, botResponse string) (bool, error)
- func AddKnowledge(db *sql.DB, language, topic, content string) error
- func AddKnowledgeContent(db *sql.DB, language, topic, path string, content []byte, maxContentBytes int, ...) (int, error)
- func AddKnowledgeEntry(db *sql.DB, entry KnowledgeEntry) (bool, error)
- func CalculateQND(comp Compressor, prompt string, content string) float64
- func CalculateQNDWithPromptSize(comp Compressor, prompt string, content string, promptCompressedSize int) float64
- func CanCheckCompilation(filename string) bool
- func CheckCompilation(code string, filename string) (bool, bool)
- func DBFilePath(dir string) string
- func DetectLanguage(prompt string) string
- func DetectNegativeFeedback(input string) string
- func ExpandQueryForPackMode(query, mode string) string
- func IndexDirectory(db *sql.DB, root string, filter LanguageFilter) (int, error)
- func IndexDirectoryWithOptions(db *sql.DB, root string, filter LanguageFilter, options IndexOptions) (int, error)
- func IndexFileWithOptions(db *sql.DB, root, path string, filter LanguageFilter, options IndexOptions) (int, error)
- func IndexFilesWithOptions(db *sql.DB, root string, paths []string, filter LanguageFilter, ...) (int, error)
- func InitDB(dir string) (*sql.DB, error)
- func LanguageFromPath(path string) string
- func LoadSnapZipIgnore(root string) ([]string, error)
- func NormalizeLanguage(value string) string
- func ProjectConfigPath(root string) string
- func RenderContextPack(pack ContextPack) string
- func RenderDependencyGraph(graph DependencyGraph) string
- func RenderImportContext(context ImportContext) string
- func RenderRepoMap(repoMap RepoMap) string
- func RenderSearchResult(result SearchResult) string
- func RenderSymbolContext(context SymbolContext) string
- func ReplaceImportsForFile(db *sql.DB, language, path string, content []byte) error
- func ReplaceSymbolReferencesForFile(db *sql.DB, language, path string, content []byte) error
- func ReplaceSymbolsForFile(db *sql.DB, language, path string, content []byte) error
- func ResetDB(dir string) error
- func ResolveImportTargets(db *sql.DB) error
- func VerifyCompilation(code string, filename string) bool
- func WriteDefaultProjectConfig(root string, force bool) (string, bool, error)
- type AffectedFile
- type AffectedReport
- type BCAConfig
- type BCAOptimizer
- type Compressor
- type ContextBundle
- type ContextPack
- func BuildContextPack(db *sql.DB, comp Compressor, query string, limit int, budgetBytes int, ...) (ContextPack, error)
- func BuildContextPackWithMode(db *sql.DB, comp Compressor, query, mode string, limit int, budgetBytes int, ...) (ContextPack, error)
- func BuildRepairContextPack(db *sql.DB, comp Compressor, failureOutput, extraQuery, mode string, limit int, ...) (ContextPack, error)
- type ContextQuality
- type ContextQualityMetrics
- type ContextReceipt
- type DatabaseStats
- type DependencyGraph
- type FailureAnalysis
- type FailureFileRef
- type Feedback
- type ImportContext
- type ImportReference
- type IndexOptions
- type KnowledgeEntry
- type LanguageFilter
- type LanguageStat
- type ProjectConfig
- type ProjectValidationConfig
- type RepoMap
- type RepoMapFile
- type SearchResult
- type Snippet
- type SuggestedValidationCommand
- type Symbol
- type SymbolContext
- type SymbolReference
- type ValidationPlan
- type ZlibCompressor
- type ZstdCompressor
Constants ¶
const DefaultContextLimitBytes = 2 * 1024 * 1024
const DefaultContextPackBudgetBytes = 12 * 1024
const DefaultMaxIndexFileBytes int64 = 1024 * 1024
const DefaultMaxKnowledgeContentBytes = 64 * 1024
const DefaultProjectConfigTOML = `` /* 421-byte string literal not displayed */
const MaxContextPackBudgetBytes = 200 * 1024
const MinContextPackBudgetBytes = 512
Variables ¶
var DBPath string
Functions ¶
func AddFeedback ¶
AddFeedback inserts a feedback record when negative sentiment is detected.
func AddKnowledge ¶
AddKnowledge inserts a new codebase template or config note into SQLite and the FTS5 index
func AddKnowledgeContent ¶
func AddKnowledgeEntry ¶
func AddKnowledgeEntry(db *sql.DB, entry KnowledgeEntry) (bool, error)
func CalculateQND ¶
func CalculateQND(comp Compressor, prompt string, content string) float64
CalculateQND computes the Query-Normalized Compression Distance between a prompt and document content
func CalculateQNDWithPromptSize ¶
func CalculateQNDWithPromptSize(comp Compressor, prompt string, content string, promptCompressedSize int) float64
func CanCheckCompilation ¶
func DBFilePath ¶
func DetectLanguage ¶
DetectLanguage parses terms in a query to find the target programming language
func DetectNegativeFeedback ¶
func ExpandQueryForPackMode ¶
func IndexDirectory ¶
func IndexDirectoryWithOptions ¶
func IndexDirectoryWithOptions(db *sql.DB, root string, filter LanguageFilter, options IndexOptions) (int, error)
func IndexFileWithOptions ¶
func IndexFileWithOptions(db *sql.DB, root, path string, filter LanguageFilter, options IndexOptions) (int, error)
func IndexFilesWithOptions ¶
func IndexFilesWithOptions(db *sql.DB, root string, paths []string, filter LanguageFilter, options IndexOptions) (int, error)
func LanguageFromPath ¶
func LoadSnapZipIgnore ¶
func NormalizeLanguage ¶
func ProjectConfigPath ¶
func RenderContextPack ¶
func RenderContextPack(pack ContextPack) string
func RenderDependencyGraph ¶
func RenderDependencyGraph(graph DependencyGraph) string
func RenderImportContext ¶
func RenderImportContext(context ImportContext) string
func RenderRepoMap ¶
func RenderSearchResult ¶
func RenderSearchResult(result SearchResult) string
func RenderSymbolContext ¶
func RenderSymbolContext(context SymbolContext) string
func ReplaceImportsForFile ¶
func ReplaceSymbolsForFile ¶
func ResolveImportTargets ¶
func VerifyCompilation ¶
VerifyCompilation runs the compiler/linter check on a temporary file
Types ¶
type AffectedFile ¶
type AffectedReport ¶
type AffectedReport struct {
InputPaths []string `json:"input_paths"`
Tests []AffectedFile `json:"tests"`
Related []AffectedFile `json:"related,omitempty"`
}
func FindAffectedTests ¶
type BCAOptimizer ¶
type BCAOptimizer struct {
// contains filtered or unexported fields
}
BCAOptimizer implements the Bayesian Compression Agent optimization loop
func NewBCAOptimizer ¶
func NewBCAOptimizer(cfg BCAConfig, dictBytes []byte, vocab []string) (*BCAOptimizer, error)
func (*BCAOptimizer) CompressDraft ¶
func (o *BCAOptimizer) CompressDraft(draft []byte) int
CompressDraft calculates compressed size C(X | Y) using the pre-primed dictionary
func (*BCAOptimizer) Mutate ¶
func (o *BCAOptimizer) Mutate(draft []byte, r *rand.Rand) []byte
Mutate proposes a conservative code transition X -> X' by replacing one identifier with an identifier observed in local context.
func (*BCAOptimizer) Optimize ¶
func (o *BCAOptimizer) Optimize(seedCode string, filename string) string
Optimize runs the Metropolis-Hastings MCMC sampling loop
func (*BCAOptimizer) PriorScore ¶
func (o *BCAOptimizer) PriorScore(draft []byte) float64
PriorScore evaluates the syntax/grammar penalty score of a draft. Lower score is better (representing fewer syntactic violations).
type Compressor ¶
type ContextBundle ¶
func LoadContextDirectory ¶
func LoadContextDirectory(root string, filter LanguageFilter, maxBytes int) (ContextBundle, error)
type ContextPack ¶
type ContextPack struct {
Query string `json:"query"`
ExpandedQuery string `json:"expanded_query,omitempty"`
Mode string `json:"mode,omitempty"`
BudgetBytes int `json:"budget_bytes"`
UsedBytes int `json:"used_bytes"`
Truncated bool `json:"truncated"`
Quality ContextQuality `json:"quality"`
Snippets []Snippet `json:"snippets"`
Receipts []ContextReceipt `json:"receipts,omitempty"`
Feedback []Feedback `json:"feedback,omitempty"`
}
func BuildContextPack ¶
func BuildContextPack(db *sql.DB, comp Compressor, query string, limit int, budgetBytes int, feedbackLimit int) (ContextPack, error)
func BuildContextPackWithMode ¶
func BuildContextPackWithMode(db *sql.DB, comp Compressor, query, mode string, limit int, budgetBytes int, feedbackLimit int) (ContextPack, error)
func BuildRepairContextPack ¶
func BuildRepairContextPack(db *sql.DB, comp Compressor, failureOutput, extraQuery, mode string, limit int, budgetBytes int, feedbackLimit int) (ContextPack, error)
type ContextQuality ¶
type ContextQuality struct {
Score float64 `json:"score"`
Grade string `json:"grade"`
Summary string `json:"summary"`
Metrics ContextQualityMetrics `json:"metrics"`
Strengths []string `json:"strengths,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
func ScoreContextPack ¶
func ScoreContextPack(pack ContextPack) ContextQuality
type ContextQualityMetrics ¶
type ContextQualityMetrics struct {
SnippetCount int `json:"snippet_count"`
SourceSnippetCount int `json:"source_snippet_count"`
TestSnippetCount int `json:"test_snippet_count"`
DependencySnippetCount int `json:"dependency_snippet_count"`
DefinitionCount int `json:"definition_count"`
ReferenceCount int `json:"reference_count"`
ReceiptCount int `json:"receipt_count"`
ReceiptCoverage float64 `json:"receipt_coverage"`
EvidenceCount int `json:"evidence_count"`
EvidenceDensity float64 `json:"evidence_density"`
UniquePathCount int `json:"unique_path_count"`
UniquePathRatio float64 `json:"unique_path_ratio"`
DuplicatePathCount int `json:"duplicate_path_count"`
FeedbackCount int `json:"feedback_count"`
BudgetUtilization float64 `json:"budget_utilization"`
Truncated bool `json:"truncated"`
}
type ContextReceipt ¶
type ContextReceipt struct {
Rank int `json:"rank"`
Path string `json:"path,omitempty"`
StartLine int `json:"start_line,omitempty"`
EndLine int `json:"end_line,omitempty"`
Topic string `json:"topic,omitempty"`
Language string `json:"language,omitempty"`
Score float64 `json:"score"`
Confidence float64 `json:"confidence"`
Reasons []string `json:"reasons"`
Evidence []string `json:"evidence,omitempty"`
}
type DatabaseStats ¶
type DatabaseStats struct {
KnowledgeRows int `json:"knowledge_rows"`
FeedbackRows int `json:"feedback_rows"`
SymbolRows int `json:"symbol_rows"`
SymbolReferenceRows int `json:"symbol_reference_rows"`
ImportRows int `json:"import_rows"`
Languages []LanguageStat `json:"languages"`
}
func GetDatabaseStats ¶
func GetDatabaseStats(db *sql.DB) (DatabaseStats, error)
type DependencyGraph ¶
type DependencyGraph struct {
Path string `json:"path"`
Language string `json:"language,omitempty"`
Imports []ImportReference `json:"imports,omitempty"`
ImportedBy []ImportReference `json:"imported_by,omitempty"`
}
func BuildDependencyGraph ¶
type FailureAnalysis ¶
type FailureAnalysis struct {
Query string `json:"query"`
FileRefs []FailureFileRef `json:"file_refs,omitempty"`
Symbols []string `json:"symbols,omitempty"`
Identifiers []string `json:"identifiers,omitempty"`
}
func AnalyzeFailureOutput ¶
func AnalyzeFailureOutput(output, extra string) FailureAnalysis
type FailureFileRef ¶
type Feedback ¶
type Feedback struct {
ID int `json:"id"`
Sentiment string `json:"sentiment"`
UserInput string `json:"user_input"`
BotResponse string `json:"bot_response"`
CreatedAt string `json:"created_at"`
}
Feedback represents a logged negative feedback entry.
type ImportContext ¶
type ImportContext struct {
Query string `json:"query"`
Imports []ImportReference `json:"imports"`
}
func BuildImportContext ¶
type ImportReference ¶
type ImportReference struct {
ID int `json:"id,omitempty"`
ImportPath string `json:"import_path"`
Alias string `json:"alias,omitempty"`
Language string `json:"language"`
Path string `json:"path"`
TargetPath string `json:"target_path,omitempty"`
Line int `json:"line"`
Context string `json:"context,omitempty"`
}
func ExtractImports ¶
func ExtractImports(language, path, content string) []ImportReference
func SearchImports ¶
type IndexOptions ¶
type IndexOptions struct {
MaxFileBytes int64
MaxContentBytes int
SkipDirs map[string]bool
SkipFiles map[string]bool
IgnorePatterns []string
}
func DefaultIndexOptions ¶
func DefaultIndexOptions() IndexOptions
type KnowledgeEntry ¶
type LanguageFilter ¶
type LanguageFilter struct {
// contains filtered or unexported fields
}
func NewLanguageFilter ¶
func NewLanguageFilter(input string) LanguageFilter
func (LanguageFilter) Description ¶
func (f LanguageFilter) Description() string
func (LanguageFilter) Matches ¶
func (f LanguageFilter) Matches(language string) bool
type LanguageStat ¶
type ProjectConfig ¶
type ProjectConfig struct {
Path string `json:"path,omitempty"`
Found bool `json:"found"`
Validation ProjectValidationConfig `json:"validation,omitempty"`
}
func LoadProjectConfig ¶
func LoadProjectConfig(root string) (ProjectConfig, error)
func ParseProjectConfig ¶
func ParseProjectConfig(content string) (ProjectConfig, error)
type ProjectValidationConfig ¶
type RepoMap ¶
type RepoMap struct {
Files []RepoMapFile `json:"files"`
}
type RepoMapFile ¶
type RepoMapFile struct {
Path string `json:"path"`
Language string `json:"language"`
Symbols []Symbol `json:"symbols,omitempty"`
}
func RelatedFiles ¶
type SearchResult ¶
type SearchResult struct {
Query string `json:"query"`
ExpandedQuery string `json:"expanded_query,omitempty"`
Mode string `json:"mode,omitempty"`
Snippets []Snippet `json:"snippets"`
Receipts []ContextReceipt `json:"receipts,omitempty"`
Feedback []Feedback `json:"feedback,omitempty"`
}
func SearchMemory ¶
func SearchMemory(db *sql.DB, comp Compressor, query string, limit int, feedbackLimit int) (SearchResult, error)
func SearchMemoryWithMode ¶
func SearchMemoryWithMode(db *sql.DB, comp Compressor, query, mode string, limit int, feedbackLimit int) (SearchResult, error)
type Snippet ¶
type Snippet struct {
ID int `json:"id"`
Language string `json:"language"`
Topic string `json:"topic"`
Path string `json:"path,omitempty"`
StartLine int `json:"start_line,omitempty"`
EndLine int `json:"end_line,omitempty"`
Content string `json:"content"`
ContentHash string `json:"content_hash,omitempty"`
SourceMTime int64 `json:"source_mtime,omitempty"`
Score float64 `json:"score"`
}
func RetrieveSimilarSnippets ¶
func RetrieveSimilarSnippets(db *sql.DB, comp Compressor, prompt string, limit int) ([]Snippet, error)
RetrieveSimilarSnippets executes FTS5 full-text lookup and then parallel compression-aware re-ranking.
type SuggestedValidationCommand ¶
type SuggestedValidationCommand struct {
Command string `json:"command"`
Reason string `json:"reason"`
Confidence float64 `json:"confidence"`
}
func ConfiguredValidationCommands ¶
func ConfiguredValidationCommands(config ProjectConfig, report AffectedReport) []SuggestedValidationCommand
func MergeValidationCommands ¶
func MergeValidationCommands(groups ...[]SuggestedValidationCommand) []SuggestedValidationCommand
func SuggestValidationCommands ¶
func SuggestValidationCommands(report AffectedReport) []SuggestedValidationCommand
type Symbol ¶
type Symbol struct {
ID int `json:"id,omitempty"`
Name string `json:"name"`
Kind string `json:"kind"`
Signature string `json:"signature"`
Language string `json:"language"`
Path string `json:"path"`
Line int `json:"line"`
}
func ExtractSymbols ¶
type SymbolContext ¶
type SymbolContext struct {
Query string `json:"query"`
Definitions []Symbol `json:"definitions"`
References []SymbolReference `json:"references"`
}
func BuildSymbolContext ¶
type SymbolReference ¶
type SymbolReference struct {
ID int `json:"id,omitempty"`
Name string `json:"name"`
Language string `json:"language"`
Path string `json:"path"`
Line int `json:"line"`
Context string `json:"context,omitempty"`
}
func ExtractSymbolReferences ¶
func ExtractSymbolReferences(language, path, content string) []SymbolReference
func SearchSymbolReferences ¶
type ValidationPlan ¶
type ValidationPlan struct {
InputPaths []string `json:"input_paths"`
Affected AffectedReport `json:"affected"`
SuggestedCommands []SuggestedValidationCommand `json:"suggested_commands,omitempty"`
}
func BuildValidationPlan ¶
type ZlibCompressor ¶
type ZlibCompressor struct{}
ZlibCompressor wraps the standard zlib library using a recycled pool of writers
func (ZlibCompressor) Compress ¶
func (zc ZlibCompressor) Compress(data []byte) int
func (ZlibCompressor) Name ¶
func (zc ZlibCompressor) Name() string
type ZstdCompressor ¶
type ZstdCompressor struct {
// contains filtered or unexported fields
}
ZstdCompressor wraps a Klauspost Zstd encoder for high-performance, allocation-free compression
func NewZstdCompressor ¶
func NewZstdCompressor(level zstd.EncoderLevel) (*ZstdCompressor, error)
func (*ZstdCompressor) Compress ¶
func (zc *ZstdCompressor) Compress(data []byte) int
func (*ZstdCompressor) Name ¶
func (zc *ZstdCompressor) Name() string