memory

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultChunkTokens             = 400
	DefaultChunkOverlap            = 80
	DefaultWatchDebounceMs         = 1500
	DefaultSessionDeltaBytes       = 100_000
	DefaultSessionDeltaMessages    = 50
	DefaultMaxResults              = 6
	DefaultMinScore                = 0.35
	DefaultHybridCandidateMultiple = 4
	DefaultCacheEnabled            = true
	UnlimitedCacheEntries          = -1
	DefaultMemorySource            = "memory"
)

Variables

View Source
var TokenRE = regexp.MustCompile(`[A-Za-z0-9_]+`)

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 HashText

func HashText(text 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 // -1 means unlimited; 0 is normalized to -1 for backward compatibility.
}

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 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
}

HybridKeywordResult holds a single keyword/FTS search result with a text relevance score.

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"`
}

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
}

Jump to

Keyboard shortcuts

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