memory

package
v0.0.0-...-6c5c7c9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultChunkTokens             = 400
	DefaultChunkOverlap            = 80
	DefaultWatchDebounceMs         = 1500
	DefaultSessionDeltaBytes       = 100_000
	DefaultSessionDeltaMessages    = 50
	DefaultMaxResults              = 6
	DefaultMinScore                = 0.35
	DefaultHybridEnabled           = true
	DefaultHybridVectorWeight      = 0.7
	DefaultHybridTextWeight        = 0.3
	DefaultHybridCandidateMultiple = 4
	DefaultCacheEnabled            = true
	DefaultMemorySource            = "memory"
)

Variables

This section is empty.

Functions

func BM25RankToScore

func BM25RankToScore(rank float64) float64

BM25RankToScore normalizes an FTS5 bm25 rank into a 0-1-ish score.

func BuildFtsQuery

func BuildFtsQuery(raw string) string

BuildFtsQuery builds a simple AND query for FTS5 from raw input.

func ComputeProviderKey

func ComputeProviderKey(providerID, model, baseURL string, headers map[string]string) string

Types

type BatchConfig

type BatchConfig struct {
	Enabled        bool
	Wait           bool
	Concurrency    int
	PollIntervalMs int
	TimeoutMinutes int
}

type CacheConfig

type CacheConfig struct {
	Enabled    bool
	MaxEntries int
}

type Chunk

type Chunk struct {
	StartLine int
	EndLine   int
	Text      string
	Hash      string
}

func ChunkMarkdown

func ChunkMarkdown(content string, tokens, overlap int) []Chunk

type ChunkingConfig

type ChunkingConfig struct {
	Tokens  int
	Overlap int
}

type EmbeddingProvider

type EmbeddingProvider interface {
	ID() string
	Model() string
	EmbedQuery(ctx context.Context, text string) ([]float64, error)
	EmbedBatch(ctx context.Context, texts []string) ([][]float64, error)
}

type ExperimentalConfig

type ExperimentalConfig struct {
	SessionMemory bool
}

type FallbackStatus

type FallbackStatus struct {
	From   string `json:"from,omitempty"`
	Reason string `json:"reason,omitempty"`
}

type HybridConfig

type HybridConfig struct {
	Enabled             bool
	VectorWeight        float64
	TextWeight          float64
	CandidateMultiplier int
}

type HybridKeywordResult

type HybridKeywordResult struct {
	ID        string
	Path      string
	StartLine int
	EndLine   int
	Source    string
	Snippet   string
	TextScore float64
}

type HybridVectorResult

type HybridVectorResult struct {
	ID          string
	Path        string
	StartLine   int
	EndLine     int
	Source      string
	Snippet     string
	VectorScore float64
}

type ProviderStatus

type ProviderStatus struct {
	Provider string
	Model    string
	Fallback *FallbackStatus
}

type QueryConfig

type QueryConfig struct {
	MaxResults       int
	MinScore         float64
	MaxInjectedChars int
	Hybrid           HybridConfig
}

type RemoteConfig

type RemoteConfig struct {
	BaseURL string
	APIKey  string
	Headers map[string]string
	Batch   BatchConfig
}

type ResolvedConfig

type ResolvedConfig struct {
	Enabled      bool
	Sources      []string
	ExtraPaths   []string
	Provider     string
	Model        string
	Fallback     string
	Remote       RemoteConfig
	Store        StoreConfig
	Chunking     ChunkingConfig
	Sync         SyncConfig
	Query        QueryConfig
	Cache        CacheConfig
	Experimental ExperimentalConfig
}

type SearchOptions

type SearchOptions struct {
	MaxResults int
	MinScore   float64
	SessionKey string
	// Mode controls search strategy.
	// - auto: prefer hybrid (vector + keyword), else keyword, else semantic, else scan fallback
	// - semantic: vector-only
	// - keyword: keyword-only (FTS if available; else scan fallback)
	// - hybrid: merge vector + keyword when possible
	// - list: list recent files (ignores query text)
	Mode string
	// Sources restrict which indexed sources to search (e.g. ["memory","workspace"]).
	// If empty, uses the manager's configured sources.
	Sources []string
	// PathPrefix restricts results to paths under this prefix (virtual paths).
	// Example: "workspace/projects/acme/".
	PathPrefix string
}

type SearchResult

type SearchResult struct {
	Path      string  `json:"path"`
	StartLine int     `json:"startLine"`
	EndLine   int     `json:"endLine"`
	Score     float64 `json:"score"`
	Snippet   string  `json:"snippet"`
	Source    string  `json:"source"`
}

func MergeHybridResults

func MergeHybridResults(vector []HybridVectorResult, keyword []HybridKeywordResult, vectorWeight, textWeight float64) []SearchResult

MergeHybridResults merges vector + keyword results with weighted scores.

type SessionSyncConfig

type SessionSyncConfig struct {
	DeltaBytes    int
	DeltaMessages int
	RetentionDays int
}

type StoreConfig

type StoreConfig struct {
	Driver string
	Path   string
	Vector VectorConfig
}

type SyncConfig

type SyncConfig struct {
	OnSessionStart  bool
	OnSearch        bool
	Watch           bool
	WatchDebounceMs int
	IntervalMinutes int
	Sessions        SessionSyncConfig
}

type VectorConfig

type VectorConfig struct {
	Enabled       bool
	ExtensionPath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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