yamlstore

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.0.5

type Option func(*options)

Option is a functional option for configuring YAMLStore.

func WithAutoHitCounting added in v0.0.5

func WithAutoHitCounting(enabled bool) Option

WithAutoHitCounting controls whether queries automatically increment HitCount and LastHit. Enabled by default; pass false to disable.

type YAMLStore

type YAMLStore struct {
	// contains filtered or unexported fields
}

YAMLStore holds one or more scope directories, each containing one YAML file per category.

Example layout:

~/.mnemonic/global/
 ├── avoidance.yaml
 └── security.yaml
~/.mnemonic/teams/acme/
 └── avoidance.yaml
.mnemonic/project/
 └── domain.yaml

func New

func New(scopeDirs map[store.Scope]string, logger *slog.Logger, opts ...Option) (*YAMLStore, error)

New creates a YAMLStore. Call with a mapping of scope names to directory paths. Expands "~" to the home directory. Each directory is scanned for *.yaml files on startup; each file is treated as a category (filename without extension).

Example:

store, err := yamlstore.New(map[Scope]string{
    "global":    "~/.mnemonic/global/",
    "team:acme": "~/.mnemonic/teams/acme/",
}, logger)

func (*YAMLStore) All

func (s *YAMLStore) All(scopes []store.Scope) ([]store.Entry, error)

func (*YAMLStore) AllByCategory

func (s *YAMLStore) AllByCategory(category string, topK int, scopes []store.Scope) ([]store.Entry, error)

AllByCategory returns entries in the given category, sorted by weighted score. Only the per-category file for each scope is accessed, not all files.

func (*YAMLStore) Close

func (s *YAMLStore) Close() error

Close stops the background flush goroutine and persists any dirty categories.

func (*YAMLStore) Delete

func (s *YAMLStore) Delete(id string) error

func (*YAMLStore) Get

func (s *YAMLStore) Get(id string) (*store.Entry, error)

func (*YAMLStore) ListHeads

func (s *YAMLStore) ListHeads(scopes []store.Scope) ([]store.HeadInfo, error)

func (*YAMLStore) Promote

func (s *YAMLStore) Promote(id string, targetScope store.Scope) error

func (*YAMLStore) Query

func (s *YAMLStore) Query(category string, tags []string) ([]store.Entry, error)

func (*YAMLStore) QueryByCategory

func (s *YAMLStore) QueryByCategory(category, query string, topK int, scopes []store.Scope) ([]store.Entry, error)

QueryByCategory returns entries in the given category whose content or tags contain any query term (case-insensitive), sorted by weighted score. Only the per-category file is accessed per scope.

func (*YAMLStore) Score

func (s *YAMLStore) Score(id string, delta float64) error

func (*YAMLStore) Upsert

func (s *YAMLStore) Upsert(entry *store.Entry) error

Jump to

Keyboard shortcuts

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