util

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProjectRoot

func FindProjectRoot(startDir string) string

FindProjectRoot walks up from startDir looking for .memtrace/ then .git/. Returns the absolute path of the project root, or "" if not found.

func GenerateID

func GenerateID() string

GenerateID returns a new time-sortable unique ID.

func GetConfigDir

func GetConfigDir() string

GetConfigDir returns the OS-appropriate config directory for memtrace.

  • macOS: $HOME/Library/Application Support/memtrace
  • Linux: $XDG_CONFIG_HOME/memtrace (fallback: $HOME/.config/memtrace)
  • Windows: %AppData%\memtrace

func GetConfigPath

func GetConfigPath() string

GetConfigPath returns the full path to config.json.

func GetProjectDbPath

func GetProjectDbPath(projectRoot string) string

GetProjectDbPath returns the path to the SQLite database for a project root.

func SaveProjectConfig

func SaveProjectConfig(cfg *ProjectConfig) error

SaveProjectConfig writes the config to disk, creating the directory if needed.

func StripPrivate added in v1.5.2

func StripPrivate(s string) string

StripPrivate removes all <private>...</private> blocks from s and normalises the resulting whitespace. It is case-insensitive.

This is applied to memory content before persistence so that agents can include sensitive details in a save request without those details ever reaching the database.

Types

type EmbedConfig

type EmbedConfig struct {
	Key      string `json:"key,omitempty"`
	URL      string `json:"url,omitempty"`
	Model    string `json:"model,omitempty"`
	Provider string `json:"provider,omitempty"` // "" or "auto" = auto-detect; "disabled" = off
}

EmbedConfig holds optional embedding API settings persisted in the global config. Environment variables always take precedence over these values.

type ProjectConfig

type ProjectConfig struct {
	Projects map[string]ProjectEntry `json:"projects"`
	Embed    EmbedConfig             `json:"embed,omitempty"`
}

ProjectConfig represents the contents of the global config.json.

func GetProjectConfig

func GetProjectConfig() *ProjectConfig

GetProjectConfig reads and returns the global config. Returns an empty config (not an error) if the file doesn't exist yet. If a legacy config exists at ~/.config/memtrace/config.json and contains projects not present in the primary config, they are merged in and the merged result is saved to the primary location.

type ProjectEntry

type ProjectEntry struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
}

ProjectEntry represents a single project in the config file.

Jump to

Keyboard shortcuts

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