Help us shape the future of Go! Take the 2026 Go Developer Survey

storage

package
v0.122.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: BSD-2-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// CheckboxRegex matches a Markdown checkbox line with either `-` or `*` as
	// the list marker. Capture groups: 1=leading whitespace, 2=state (` `, `x`,
	// or `/`), 3=task text. Shared across storage and ops packages to keep the
	// parser shape in one place.
	CheckboxRegex = regexp.MustCompile(`^(\s*)[-*] \[([ x/])\] (.+)$`)

	// CheckboxCompleteRegex matches an unchecked or in-progress checkbox marker
	// (` ` or `/`) and is used by rewriters that force a line to checked.
	// Capture groups: 1=list marker (`-` or `*`), 2=state (` ` or `/`).
	CheckboxCompleteRegex = regexp.MustCompile(`([-*]) \[([ /])\]`)

	// CheckboxUncompleteRegex matches a checked checkbox marker and is used by
	// rewriters that force a line to unchecked. Capture group 1=list marker.
	CheckboxUncompleteRegex = regexp.MustCompile(`([-*]) \[x\]`)
)
View Source
var ErrNotFound = stderrors.New("file not found")

ErrNotFound indicates a requested markdown file could not be resolved by name within a vault. Callers (notably the multi-vault dispatcher) test for it with errors.Is to distinguish a genuine not-found from other failures (e.g. a precondition failure such as incomplete subtasks).

Functions

This section is empty.

Types

type Config

type Config struct {
	TasksDir      string
	GoalsDir      string
	ThemesDir     string
	ObjectivesDir string
	VisionDir     string
	DailyDir      string
	Excludes      []string
}

Config holds the configuration for storage paths.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default storage configuration.

func NewConfigFromVault

func NewConfigFromVault(vault *config.Vault) *Config

NewConfigFromVault creates a Config from a Vault.

type DailyNoteStorage added in v0.25.3

type DailyNoteStorage interface {
	ReadDailyNote(ctx context.Context, vaultPath string, date string) (string, error)
	WriteDailyNote(ctx context.Context, vaultPath string, date string, content string) error
}

func NewDailyNoteStorage added in v0.25.3

func NewDailyNoteStorage(storageConfig *Config) DailyNoteStorage

NewDailyNoteStorage creates a storage for daily note operations only.

type DecisionStorage added in v0.25.3

type DecisionStorage interface {
	ListDecisions(ctx context.Context, vaultPath string) ([]*domain.Decision, error)
	FindDecisionByName(ctx context.Context, vaultPath string, name string) (*domain.Decision, error)
	WriteDecision(ctx context.Context, decision *domain.Decision) error
}

func NewDecisionStorage added in v0.25.3

func NewDecisionStorage(storageConfig *Config) DecisionStorage

NewDecisionStorage creates a storage for decision operations only.

type GoalStorage added in v0.25.3

type GoalStorage interface {
	WriteGoal(ctx context.Context, goal *domain.Goal) error
	FindGoalByName(ctx context.Context, vaultPath string, name string) (*domain.Goal, error)
}

func NewGoalStorage added in v0.25.3

func NewGoalStorage(storageConfig *Config) GoalStorage

NewGoalStorage creates a storage for goal operations only.

type ObjectiveStorage added in v0.29.0

type ObjectiveStorage interface {
	WriteObjective(ctx context.Context, objective *domain.Objective) error
	FindObjectiveByName(
		ctx context.Context,
		vaultPath string,
		name string,
	) (*domain.Objective, error)
}

func NewObjectiveStorage added in v0.29.0

func NewObjectiveStorage(storageConfig *Config) ObjectiveStorage

NewObjectiveStorage creates a storage for objective operations only.

type PageStorage added in v0.25.3

type PageStorage interface {
	ListPages(ctx context.Context, vaultPath string, pagesDir string) ([]*domain.Page, error)
}

func NewPageStorage added in v0.25.3

func NewPageStorage(storageConfig *Config) PageStorage

NewPageStorage creates a storage for page operations only.

type Storage

type Storage interface {
	TaskStorage
	GoalStorage
	ThemeStorage
	ObjectiveStorage
	VisionStorage
	DailyNoteStorage
	PageStorage
	DecisionStorage
	// Legacy methods — used by storage tests, not by ops.
	// Keep on composed interface for backward compat; not on narrow interfaces.
	ReadTask(ctx context.Context, vaultPath string, taskID domain.TaskID) (*domain.Task, error)
	ListTasks(ctx context.Context, vaultPath string) ([]*domain.Task, error)
	ReadGoal(ctx context.Context, vaultPath string, goalID domain.GoalID) (*domain.Goal, error)
	ReadTheme(ctx context.Context, vaultPath string, themeID domain.ThemeID) (*domain.Theme, error)
	ReadObjective(
		ctx context.Context,
		vaultPath string,
		objectiveID domain.ObjectiveID,
	) (*domain.Objective, error)
	ReadVision(
		ctx context.Context,
		vaultPath string,
		visionID domain.VisionID,
	) (*domain.Vision, error)
}

func NewStorage

func NewStorage(storageConfig *Config) Storage

NewStorage creates a new markdown storage instance with custom configuration.

type TaskStorage added in v0.25.3

type TaskStorage interface {
	WriteTask(ctx context.Context, task *domain.Task) error
	FindTaskByName(ctx context.Context, vaultPath string, name string) (*domain.Task, error)
	ListTasks(ctx context.Context, vaultPath string) ([]*domain.Task, error)
}

func NewTaskStorage added in v0.25.3

func NewTaskStorage(storageConfig *Config) TaskStorage

NewTaskStorage creates a storage for task operations only.

type ThemeStorage added in v0.29.0

type ThemeStorage interface {
	WriteTheme(ctx context.Context, theme *domain.Theme) error
	FindThemeByName(ctx context.Context, vaultPath string, name string) (*domain.Theme, error)
}

func NewThemeStorage added in v0.29.0

func NewThemeStorage(storageConfig *Config) ThemeStorage

NewThemeStorage creates a storage for theme operations only.

type VisionStorage added in v0.29.0

type VisionStorage interface {
	WriteVision(ctx context.Context, vision *domain.Vision) error
	FindVisionByName(ctx context.Context, vaultPath string, name string) (*domain.Vision, error)
}

func NewVisionStorage added in v0.29.0

func NewVisionStorage(storageConfig *Config) VisionStorage

NewVisionStorage creates a storage for vision operations only.

Jump to

Keyboard shortcuts

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