projectconfig

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package projectconfig parses the .mememory file that lives at a project root.

The file is a JSON document that pins the canonical project name (and, in future schema versions, additional bootstrap/recall preferences) for any directory within the project tree. It is discovered via walk-up search from the current working directory, mirroring how git locates its repository root.

Schema is versioned. v1 requires only the "version" and "project" fields. Reserved fields for future versions are documented in docs/config/mememory-file.md.

Index

Constants

View Source
const CurrentSchemaVersion = 1

CurrentSchemaVersion is the highest schema version this build understands. Files with a higher version are read on a best-effort basis with a warning; unknown fields are ignored silently within a major version.

View Source
const FileName = ".mememory"

FileName is the canonical name of the project config file. It lives at the project root and is discovered by walk-up search from any descendant directory.

Variables

View Source
var ErrNotFound = errors.New("projectconfig: .mememory file not found")

ErrNotFound is returned by FindWalkUp when no .mememory file exists in the starting directory or any of its ancestors up to the filesystem root.

Functions

This section is empty.

Types

type File

type File struct {
	// Version is the schema version of this document. Required.
	Version int `json:"version"`

	// Project is the canonical project name used by mememory for scoping
	// memories. Required in v1.
	Project string `json:"project"`
}

File is the in-memory representation of a parsed .mememory document.

Only fields defined in the current schema version are decoded explicitly. Unknown fields are dropped by encoding/json's default behavior, which gives us forward compatibility within the major version: a file written by a newer build of mememory remains readable by an older build, the older build just ignores fields it does not recognize.

func Load

func Load(path string) (*File, error)

Load reads and validates a .mememory file at the given absolute path. The caller is expected to have located the file (e.g. via FindWalkUp); Load does not perform walk-up search.

func (*File) IsFutureVersion

func (f *File) IsFutureVersion() bool

IsFutureVersion reports whether the file uses a schema version newer than what this build understands. Callers may choose to emit a warning and continue with best-effort parsing of the fields they recognize.

func (*File) Validate

func (f *File) Validate() error

Validate checks the parsed file against the current schema rules. It is exported so tests and external callers can validate File values constructed in memory.

type Found

type Found struct {
	Path string
	File File
}

Found bundles a successfully located config file with the absolute path it was loaded from. The path is reported back to the user so they can see which file is governing the current session.

func FindWalkUp

func FindWalkUp(startDir string) (*Found, error)

FindWalkUp searches for a .mememory file starting at startDir and walking upward through parent directories until one is found or the filesystem root is reached. The first match wins; ancestor files are not merged.

Returns ErrNotFound if no file exists anywhere on the path. Returns a non-nil error wrapping the underlying parse failure if a file is found but invalid — callers must distinguish "not found" (silent fallback) from "found but broken" (loud failure).

Jump to

Keyboard shortcuts

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