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
- Variables
- func AddToFolderNote(content, stem, kind string) (string, bool)
- func FolderNote(root, folder string) string
- func Render(tmpl string, r Request, p Placement, now time.Time) (string, error)
- func SafeRel(rel string) bool
- func SecretLine(text string) int
- type Entry
- type Hit
- type Note
- type Placement
- type Request
Constants ¶
const ( KindNote = "note" KindDecision = "decision" KindIncident = "incident" KindRunbook = "runbook" KindMeeting = "meeting" )
Kinds of note. Dated kinds carry the date in their file name.
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 ¶
var ErrRefused = errors.New("refused")
ErrRefused is wrapped by every refusal: a bad request, not a broken vault.
Functions ¶
func AddToFolderNote ¶
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 ¶
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 ¶
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 ¶
SafeRel reports whether rel stays inside the vault and outside the folders no tool may touch.
func SecretLine ¶
SecretLine returns the 1-based line of the first credential-shaped value, or 0.
Types ¶
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.