meta

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package meta holds the business logic behind `lore meta`: walking a document tree, extracting each document's YAML frontmatter, and letting plugins enrich the result. It lives under the openlore namespace but is a separate package from pkg/openlore (which imports cmds): keeping meta cmds-free lets the shell command (pkg/shell/cmds) call it without an import cycle, while the parent openlore host reuses it too. It depends only on pkg/vfs and pkg/okf, so the same scanning logic backs `lore meta` on every path (as pkg/okf backs write-side validation).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extender

type Extender func(absPath string, content []byte, frontmatter map[string]any) map[string]any

Extender augments a scanned document's fields. It receives the document's absolute display path (so it can resolve which docset owns it), its raw bytes, and its already-parsed frontmatter, and returns extra fields to merge into the record. Returning nil adds nothing. The okf plugin registers one to annotate documents with OKF conformance where OKF applies, so read-side discovery agrees with write-side enforcement.

type Filter

type Filter struct {
	Name          string
	Aliases       []string
	Roots         []string
	AbsolutePaths bool
	Selector      func(absPath string, record Record) bool
}

Filter is a plugin-provided, session-bound metadata query.

type Record

type Record struct {
	Path   string
	Fields map[string]any
}

Record is one scanned document: its path relative to the scan root and the merged field map (frontmatter plus any extender-contributed fields). Path is kept separate so callers decide how to surface it.

func Scan

func Scan(fsys vfs.FileSystem, root string, extenders ...Extender) ([]Record, error)

Scan walks *.md documents under root in fsys and returns one Record per document that opens with a parseable YAML frontmatter block, sorted by path. It is a generic reader, not a validator: documents without (or with an unparseable) frontmatter block are skipped, and the full frontmatter map is passed through. Each record's Fields are the frontmatter merged with the output of every extender (applied in order). Paths are relative to root so they feed straight back into cat/grep from that directory.

Jump to

Keyboard shortcuts

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