Documentation
¶
Overview ¶
Package workspace resolves the single MNEMOS_DIR anchor and the fixed layout derived from it. Every location mnemos uses — config, knowledge base, index database, embedding models — is a fixed subpath of MNEMOS_DIR; none is individually configurable. This replaces the earlier model where a relative [storage].path and [capture].dir were resolved against a config-derived tree root.
Index ¶
Constants ¶
const ( // DirName is the project-local anchor directory discovered by walking up // from the cwd (bounded by the git root). DirName = ".mnemos" // ConfigName is the config file inside a MNEMOS_DIR. ConfigName = "mnemos.toml" // CaptureName is the reserved subdirectory of the knowledge base where // auto-named notes (remember) are written. Its URIs are "capture/<file>". CaptureName = "capture" )
Fixed names within a MNEMOS_DIR. The knowledge base (kb) is the single URI namespace and write-confinement root; capture lives inside it. State (the index database) and models live alongside kb but outside the URI namespace.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Layout ¶
type Layout struct {
// MnemosDir is the resolved anchor (absolute).
MnemosDir string
// Config is the mnemos.toml path. Usually MnemosDir/mnemos.toml; an explicit
// --config overrides just this filename.
Config string
// KB is the knowledge base root: the tree root, URI namespace, and write
// confinement boundary. Everything URI-addressable lives under it.
KB string
// Capture is where auto-named notes (remember) are written: KB/capture.
Capture string
// DB is the SQLite index: MnemosDir/state/index.db — derived state, outside
// the URI namespace.
DB string
// Models is the embedding-model directory: MnemosDir/models.
Models string
// Source describes how MnemosDir was resolved, for status output and logs.
Source string
}
Layout is the set of absolute paths derived from a MNEMOS_DIR. It is the single source of truth for where mnemos reads and writes.
func New ¶
New builds a Layout from a MNEMOS_DIR by applying the fixed subpath rules. The directory is cleaned but not required to exist (init creates it).
func Resolve ¶
Resolve determines the MNEMOS_DIR and its Layout by precedence:
- --config <file> → MnemosDir is the file's directory; Config is the file
- --mnemos-dir <dir> → that directory
- $MNEMOS_DIR → that directory
- $CLAUDE_PROJECT_DIR → resolve within that project, FAIL CLOSED: if the project has no .mnemos, bind to its canonical (uninitialized) location so the absent database yields an actionable "run mnemos init" error, never a silent fall-through to the global default. Claude Code sets this variable in a spawned MCP server's environment, so an unpinned `serve` lands on the right project's workspace instead of leaking the global one.
- project ./.mnemos → nearest one walking up from cwd, bounded by the git root (so an unrelated parent's .mnemos is never picked up)
- ~/.mnemos → the global default (reached only when no project context is signalled)
The chosen directory need not exist; commands that read state fail with an actionable error when the database is absent.
MCP roots/list would be a more robust project signal than $CLAUDE_PROJECT_DIR, but the client only answers it inside an initialized session — after serve has already opened the store — so consuming it requires deferring workspace resolution and DB binding until post-init. That lifecycle change is tracked separately; $CLAUDE_PROJECT_DIR gives the same routing at process start.
type Options ¶
type Options struct {
// ExplicitDir is the value of --mnemos-dir (highest precedence after config).
ExplicitDir string
// ConfigPath is the value of --config: an explicit mnemos.toml path. Its
// directory becomes MnemosDir and it overrides the config filename.
ConfigPath string
// Env reads an environment variable (os.Getenv in production).
Env func(string) string
// Home is the user's home directory (os.UserHomeDir in production).
Home string
// Cwd is the current working directory (os.Getwd in production).
Cwd string
}
Options carries the inputs to Resolve. The environment, home, and cwd are injected so resolution is deterministic and testable.