Documentation
¶
Index ¶
Constants ¶
const ( CommitTypeFeat = "feat" CommitTypeFix = "fix" CommitTypeDocs = "docs" CommitTypeStyle = "style" CommitTypeRefactor = "refactor" CommitTypePerf = "perf" CommitTypeTest = "test" CommitTypeChore = "chore" )
CommitType constants for semantic commits
Variables ¶
This section is empty.
Functions ¶
func AppendFooter ¶ added in v0.4.0
AppendFooter appends the Loam footer to an arbitrary message if not present. Used for free-form -m "msg" commits.
func FormatCommitMessage ¶ added in v0.4.0
FormatCommitMessage builds a Conventional Commit message. logic:
<type>(<scope>): <subject> <body> Powered-by: Loam
func IsDevRun ¶ added in v0.3.0
func IsDevRun() bool
IsDevRun checks if the current process is running via `go run` or `go test`. It relies on the fact that these commands build binaries in temporary directories.
func ResolveVaultPath ¶ added in v0.3.0
ResolveVaultPath determines the actual path for the vault based on safety rules. If isDev is true (or forced), it re-roots the path into a temporary directory to avoid polluting the user's workspace/host repo.
Types ¶
type Metadata ¶
type Metadata map[string]interface{}
Metadata aliases the flexible YAML frontmatter map.
type Note ¶
type Note struct {
ID string // Typically the filename without extension
Metadata Metadata // Parsed YAML frontmatter
Content string // The markdown body
}
Note represents a Markdown file with optional YAML frontmatter.
type Option ¶ added in v0.3.0
Option is a functional option for configuring a Vault.
func WithAutoInit ¶ added in v0.3.0
WithAutoInit enables automatic initialization of the vault directory and git repository if they do not exist.
func WithGitless ¶ added in v0.3.0
WithGitless forces the vault to operate without Git interactions. If false, it tries to auto-detect if git is available.
func WithMustExist ¶ added in v0.3.0
func WithMustExist() Option
WithMustExist enforces that the vault directory must already exist. It overrides AutoInit behavior.
func WithTempDir ¶ added in v0.3.0
func WithTempDir() Option
WithTempDir forces the vault to use a temporary directory for safety. This is useful for tests and examples.
type Transaction ¶ added in v0.2.0
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents a multi-step operation that holds the lock.
func (*Transaction) Apply ¶ added in v0.2.0
func (tx *Transaction) Apply(msg string) error
Apply persists the transaction changes: git add + git commit + unlock.
func (*Transaction) Rollback ¶ added in v0.2.0
func (tx *Transaction) Rollback() error
Rollback undoes changes made during the transaction and releases the lock.
func (*Transaction) Write ¶ added in v0.2.0
func (tx *Transaction) Write(n *Note) error
Write saves a note to disk within the transaction. It does NOT stage the file in Git.
type Vault ¶
type Vault struct {
Path string
Git *git.Client
Logger *slog.Logger
// contains filtered or unexported fields
}
Vault represents a directory containing notes backed by Git.
func NewVault ¶
NewVault creates a Vault instance rooted at the given path. It accepts options to configure behavior (AutoInit, Gitless, Safety).
func (*Vault) Begin ¶ added in v0.2.0
func (v *Vault) Begin() (*Transaction, error)
Begin starts a new transaction. It acquires the global lock.
func (*Vault) IsGitless ¶ added in v0.3.0
IsGitless returns true if the vault is operating in gitless mode.
func (*Vault) List ¶
List returns a list of all notes in the vault. It scans the directory recursively for .md files and parses them.
func (*Vault) Read ¶
Read loads a note by its ID (filename without extension). It looks for {ID}.md in the vault root.