app

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package app wires together the mnemos configuration, logger, and storage into a single App value shared across CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(verbose bool) *slog.Logger

NewLogger returns a slog text logger writing to stderr. When verbose is set the level is Debug, otherwise Info.

Types

type App

type App struct {
	Config *config.Config
	Logger *slog.Logger
	DB     *sql.DB
	// contains filtered or unexported fields
}

App holds the process-wide dependencies: parsed configuration, a structured logger, and an open database handle. Commands receive a built App rather than reaching for globals.

func Load

func Load(configPath string, verbose bool) (*App, error)

Load builds an App: it resolves and layers configuration (defaults, then ~/.mnemos.toml and ./.mnemos.toml, or the explicit configPath when set) and constructs the logger. It does NOT open the database; call OpenStore once the storage path is known and the directory exists.

A relative storage.path is resolved here, once, against the same tree root as capture/forget/move (the --config directory, or the current directory in auto-discovery mode) so the stored path is absolute and every command, log line, and error message shares a single source of truth. Without this, a relative path silently followed the process cwd — which, for an MCP stdio server launched by a client, is not the project directory.

func (*App) Close

func (a *App) Close() error

Close releases the database handle if one is open.

func (*App) OpenStore

func (a *App) OpenStore(allowCreate bool) error

OpenStore opens the configured SQLite database and runs migrations, storing the handle on the App. Callers are responsible for ensuring the parent directory exists.

allowCreate gates database creation. Write/populate commands (init, ingest, watch, okfy) pass true and may create a fresh database. Read commands (serve, search, ls, status, task, reindex, forget, mv) pass false: if the database is absent or empty, OpenStore returns an actionable error rather than letting the SQLite driver silently create an empty database — the failure mode that made a misconfigured MCP server return no results while appearing to work.

func (*App) TreeRoot

func (a *App) TreeRoot() string

TreeRoot returns the writable OKF tree root: the directory caller-supplied paths for capture, forget, and move are resolved relative to (and confined within). With an explicit --config it is that file's directory; in auto-discovery mode it is the current working directory.

Jump to

Keyboard shortcuts

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