Documentation
¶
Index ¶
- Constants
- func ComputeAvgFieldLen(entries []Entry) float64
- func ComputeIDF(entries []Entry) map[string]float64
- func IndexPath() (string, error)
- func NeedsRebuild(cached Index, sourceDirs []string) bool
- func Save(idx Index) error
- func SourceDirs() ([]string, error)
- type Entry
- type EntryType
- type Frontmatter
- type Index
- type ScanResult
Constants ¶
const CurrentVersion = 9
CurrentVersion is the index schema version; bump when Entry shape changes.
Variables ¶
This section is empty.
Functions ¶
func ComputeAvgFieldLen ¶
ComputeAvgFieldLen returns the average number of keywords per entry. Used as the avgdl denominator in BM25 length normalization.
func ComputeIDF ¶
ComputeIDF calculates dampened inverse document frequency for all keywords. Returns a multiplier ranging from 0.5 (ubiquitous) to 2.0 (unique).
func NeedsRebuild ¶
NeedsRebuild checks whether the cached index is stale relative to source dirs. It also accounts for changes to ~/.config/claudette/aliases.yaml — both modification (mtime change) and deletion/creation (zero-vs-nonzero mtime).
func SourceDirs ¶
SourceDirs returns the directories to scan, combining user-configured source_dirs (from config.json) with defaults and plugin directories.
Types ¶
type Entry ¶
type Entry struct {
Type EntryType `json:"type"`
Name string `json:"name"`
Title string `json:"title"`
Desc string `json:"desc,omitzero"` // one-liner from frontmatter description
Category string `json:"category"`
FilePath string `json:"file_path"`
FileMtime time.Time `json:"file_mtime"` // mtime of the source .md file at scan time
Keywords map[string]int `json:"keywords"` // word -> field weight (name=3, title=2, tag=2, desc=1)
Bigrams []string `json:"bigrams,omitzero"` // consecutive word pairs from title
HitCount int `json:"hit_count,omitzero"` // raw aggregated usage count (diagnostics only)
HitCountDecayed float64 `json:"hit_count_decayed,omitempty"` // exponentially-decayed hit count (scorer uses this)
SuggestedAliases []string `json:"suggested_aliases,omitempty"` // co-occurrence-derived alias candidates (populated at rebuild; scored at weight 1)
}
Entry is a single searchable item in the index.
type Frontmatter ¶
type Frontmatter struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Tags []string `yaml:"tags"`
Aliases []string `yaml:"aliases"`
}
Frontmatter holds parsed YAML header from component .md files.
func ParseFrontmatter ¶
func ParseFrontmatter(content []byte) (Frontmatter, error)
ParseFrontmatter extracts YAML between --- delimiters. Returns zero Frontmatter if no valid frontmatter found.
type Index ¶
type Index struct {
Version int `json:"version"`
BuildTime time.Time `json:"build_time"`
SourceMtime time.Time `json:"source_mtime"`
FileCount int `json:"file_count"`
AliasesMtime time.Time `json:"aliases_mtime,omitzero"` // mtime of aliases.yaml at build time (zero if absent)
ZeroKeywordCount int `json:"zero_keyword_count,omitzero"` // entries with no keywords after parse (authoring signal)
ColdEntryCount int `json:"cold_entry_count,omitzero"` // entries never hit, >90d old, not brand-new (>7d old)
FrequentMissTokens []string `json:"frequent_miss_tokens,omitempty"` // top missed tokens above threshold; empty when below
SuggestedAliasCount int `json:"suggested_alias_count,omitzero"` // entries with alias candidates pending review
Entries []Entry `json:"entries"`
IDF map[string]float64 `json:"idf,omitzero"` // inverse document frequency per keyword
AvgFieldLen float64 `json:"avg_field_len"` // average number of keywords per entry (for BM25)
}
Index is the on-disk cache of all scanned entries.
func ForceRebuild ¶
ForceRebuild scans, builds, and persists a fresh index unconditionally.