vault

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vault holds the side-effect-light logic behind `ki vault mcp`: where a note goes, what its frontmatter is, how the folder note is updated, and what must never be written. The conventions come from the vault's own AGENTS.md and templates/, read at call time, so changing them needs no release. Nothing here runs git; the cli package does that around these calls.

Index

Constants

View Source
const (
	KindNote     = "note"
	KindDecision = "decision"
	KindIncident = "incident"
	KindRunbook  = "runbook"
	KindMeeting  = "meeting"
)

Kinds of note. Dated kinds carry the date in their file name.

View Source
const (
	AreaProjects    = "projects"
	AreaEngineering = "engineering"
	AreaReference   = "reference"
	AreaWriting     = "writing"
	AreaIdeas       = "ideas"
)

Areas are the top-level folders an agent may write into. Everything else (inbox, daily, people, career, archive, diagrams, attachments) is the owner's by hand.

Variables

View Source
var ErrRefused = errors.New("refused")

ErrRefused is wrapped by every refusal: a bad request, not a broken vault.

Functions

func AddToFolderNote

func AddToFolderNote(content, stem, kind string) (string, bool)

AddToFolderNote returns the folder note with a wikilink to stem appended to its section (## Decisions for decisions, ## Notes otherwise), creating the section at the end when missing. Already-linked notes leave it unchanged.

func FolderNote

func FolderNote(root, folder string) string

FolderNote finds the folder note of a project folder: the one note named like the folder (projects/beacon/Beacon.md, projects/kio/kio.md). It returns "" when the folder has none.

func Render

func Render(tmpl string, r Request, p Placement, now time.Time) (string, error)

Render builds the note: frontmatter from the kind's template when the vault has one, else the minimal block, followed by the body. A leading H1 in the body is dropped: the file name is the title.

func SafeRel

func SafeRel(rel string) bool

SafeRel reports whether rel stays inside the vault and outside the folders no tool may touch.

func SecretLine

func SecretLine(text string) int

SecretLine returns the 1-based line of the first credential-shaped value, or 0.

Types

type Entry

type Entry struct {
	Name  string
	IsDir bool
}

Entry is one line of vault_list.

func List

func List(root, folder string) ([]Entry, error)

List returns the folders and notes directly under folder ("" for the root).

type Hit

type Hit struct {
	Rel  string
	Line int
	Text string
}

Hit is one vault_search result.

func Search(root, query string, limit int) ([]Hit, error)

Search returns the notes whose name or text contains query, case-insensitive, with the first matching line, at most limit of them.

type Note

type Note struct {
	Rel  string
	Stem string
}

Note is a vault file found by name.

func Find

func Find(root, stem string) ([]Note, error)

Find returns every note whose name is stem, anywhere in the vault. Names are unique by convention, so more than one result is itself a finding.

type Placement

type Placement struct {
	// Rel is the vault-relative path, e.g. "projects/acme/decisions/2026-10-18 Use Postgres.md".
	Rel string
	// Stem is the note name without ".md": what wikilinks use.
	Stem string
	// Folder is the vault-relative folder whose folder note lists the note; "" when none applies.
	Folder string
}

Placement is where a note goes and what it is called.

func Place

func Place(r Request, now time.Time) (Placement, error)

Place decides the path for a request on a given day.

type Reader added in v0.2.1

type Reader struct {
	Root  string
	Allow []string
}

Reader reads a vault. Allow limits it to vault-relative folders; empty means the whole vault. Use NewReader for a list that came from outside.

func NewReader added in v0.2.1

func NewReader(root string, allow []string) (Reader, error)

NewReader returns a Reader confined to the given vault-relative folders, after refusing any that is not a plain relative path.

func (Reader) Find added in v0.2.1

func (r Reader) Find(stem string) ([]Note, error)

Find is the package-level Find limited to the readable folders.

func (Reader) List added in v0.2.1

func (r Reader) List(folder string) ([]Entry, error)

List is the package-level List limited to the readable folders. Above them it shows only the way down to them.

func (Reader) Search added in v0.2.1

func (r Reader) Search(query string, limit int) ([]Hit, error)

Search is the package-level Search limited to the readable folders.

type Request

type Request struct {
	Area      string
	Project   string
	Kind      string
	Title     string
	Body      string
	Overwrite bool
}

Request is one vault_write call.

Jump to

Keyboard shortcuts

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