vault

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package vault provides path resolution, document rendering, reading, writing, and query helpers for Obsidian-compatible knowledge vaults.

Index

Constants

View Source
const (
	CodebaseDashboardTitle    = "Codebase Dashboard"
	CodebaseConceptIndexTitle = "Codebase Concept Index"
	CodebaseSourceIndexTitle  = "Codebase Source Index"
	TopicDashboardTitle       = "Dashboard"
	TopicConceptIndexTitle    = "Concept Index"
	TopicSourceIndexTitle     = "Source Index"
)

Variables

This section is empty.

Functions

func CreateExternalID

func CreateExternalID(source string) string

CreateExternalID creates a stable external node identifier from a module source.

func CreateFileID

func CreateFileID(filePath string) string

CreateFileID creates a stable file node identifier from a file path.

func CreateSymbolID

func CreateSymbolID(symbol models.SymbolNode) string

CreateSymbolID creates a stable symbol identifier from a symbol node.

func DeriveTopicDomain

func DeriveTopicDomain(topicSlug string) string

DeriveTopicDomain returns the topic domain identifier for a topic slug.

func DeriveTopicSlug

func DeriveTopicSlug(rootPath string) string

DeriveTopicSlug derives the topic slug from a root path.

func DeriveTopicTitle

func DeriveTopicTitle(topicSlug string) string

DeriveTopicTitle converts a topic slug into a human-readable title.

func DiscoverVaultPath

func DiscoverVaultPath(cwd string) (string, error)

DiscoverVaultPath walks up from cwd until it finds a `.kb/vault` directory.

func ExtractLeadingComment

func ExtractLeadingComment(sourceText string) string

ExtractLeadingComment returns the first leading block or line comment from source text.

func ExtractSection

func ExtractSection(body, heading string) string

ExtractSection returns the markdown content under the named level-two heading.

func GetBaseFilePath

func GetBaseFilePath(baseName string) string

GetBaseFilePath derives the vault document path for an Obsidian Base definition.

func GetRawDirectoryIndexPath

func GetRawDirectoryIndexPath(directoryPath string) string

GetRawDirectoryIndexPath derives the vault document path for a raw directory index.

func GetRawFileDocumentPath

func GetRawFileDocumentPath(filePath string) string

GetRawFileDocumentPath derives the vault document path for a raw file snapshot.

func GetRawLanguageIndexPath

func GetRawLanguageIndexPath(language string) string

GetRawLanguageIndexPath derives the vault document path for a raw language index.

func GetRawSymbolDocumentPath

func GetRawSymbolDocumentPath(symbol models.SymbolNode) string

GetRawSymbolDocumentPath derives the vault document path for a raw symbol snapshot.

func GetTopicIndexPath added in v0.0.5

func GetTopicIndexPath(indexTitle string) string

GetTopicIndexPath derives the vault document path for a top-level topic index page.

func GetWikiConceptPath

func GetWikiConceptPath(articleTitle string) string

GetWikiConceptPath derives the vault document path for a generated wiki concept article.

func GetWikiIndexPath

func GetWikiIndexPath(indexTitle string) string

GetWikiIndexPath derives the vault document path for a generated wiki index page.

func HumanizeSlug

func HumanizeSlug(value string) string

HumanizeSlug converts a hyphenated slug into a title-cased label.

func IsPathInside

func IsPathInside(parentPath, targetPath string) bool

IsPathInside reports whether targetPath is the same as or nested under parentPath.

func ListAvailableTopics

func ListAvailableTopics(options VaultQueryOptions) ([]string, error)

ListAvailableTopics returns the marker-backed topic directories in deterministic order.

func NormalizeComment

func NormalizeComment(rawComment string) string

NormalizeComment strips Go/TS comment delimiters while preserving the comment text.

func RenderBaseDefinition

func RenderBaseDefinition(definition models.BaseDefinition) string

func RenderBaseFiles

func RenderBaseFiles(metrics models.MetricsResult) []models.BaseFile

func RenderDocuments

func RenderDocuments(
	graph models.GraphSnapshot,
	metrics models.MetricsResult,
	topic models.TopicMetadata,
) []models.RenderedDocument

func SlugifySegment

func SlugifySegment(value string) string

SlugifySegment converts a free-form segment into a filesystem-friendly slug.

func StripMarkdownExtension

func StripMarkdownExtension(documentPath string) string

StripMarkdownExtension removes a trailing .md extension from a document path.

func StripQuotes

func StripQuotes(value string) string

StripQuotes removes a single leading and trailing quote character when present.

func ToPosixPath

func ToPosixPath(value string) string

ToPosixPath normalizes path separators to forward slashes and trims trailing slashes.

func ToTopicWikiLink(topicSlug, documentPath, label string) string

ToTopicWikiLink formats a topic-scoped Obsidian wiki-link.

Types

type ReadVaultOptions

type ReadVaultOptions struct {
	Warn func(message string)
}

ReadVaultOptions controls non-fatal reader behavior.

type ResolvedVault

type ResolvedVault struct {
	VaultPath string `json:"vaultPath"`
	TopicPath string `json:"topicPath"`
	TopicSlug string `json:"topicSlug"`
}

ResolvedVault identifies the vault root and topic directory selected for a command.

func ResolveVaultQuery

func ResolveVaultQuery(options VaultQueryOptions) (ResolvedVault, error)

ResolveVaultQuery resolves the target vault and topic from the provided options.

type VaultDocument

type VaultDocument struct {
	RelativePath      string                 `json:"relativePath"`
	Frontmatter       map[string]interface{} `json:"frontmatter"`
	Body              string                 `json:"body"`
	Backlinks         []VaultRelation        `json:"backlinks"`
	OutgoingRelations []VaultRelation        `json:"outgoingRelations"`
}

VaultDocument is the parsed read-side representation of a vault markdown file.

func FindSymbolsByName

func FindSymbolsByName(snapshot VaultSnapshot, query string) []VaultDocument

FindSymbolsByName returns symbol documents whose symbol_name frontmatter contains the query.

type VaultQueryOptions

type VaultQueryOptions struct {
	Vault string
	Topic string
	CWD   string
}

VaultQueryOptions control vault and topic discovery from CLI-style flags.

type VaultRelation

type VaultRelation struct {
	TargetPath string `json:"targetPath"`
	Type       string `json:"type"`
	Confidence string `json:"confidence"`
}

VaultRelation describes a parsed relation link in a vault markdown document.

type VaultSnapshot

type VaultSnapshot struct {
	VaultPath   string          `json:"vaultPath"`
	TopicSlug   string          `json:"topicSlug"`
	Symbols     []VaultDocument `json:"symbols"`
	Files       []VaultDocument `json:"files"`
	Directories []VaultDocument `json:"directories"`
	Wikis       []VaultDocument `json:"wikis"`
}

VaultSnapshot groups parsed vault documents by their source category.

func ReadVaultSnapshot

func ReadVaultSnapshot(resolvedVault ResolvedVault, options ReadVaultOptions) (VaultSnapshot, error)

ReadVaultSnapshot walks a topic directory and parses every managed markdown file.

type WriteProgress

type WriteProgress struct {
	Completed int
	Path      string
	Total     int
}

WriteProgress reports one successful persisted file within the write stage.

type WriteVaultOptions

type WriteVaultOptions struct {
	BaseFiles []models.BaseFile
	Documents []models.RenderedDocument
	Graph     models.GraphSnapshot
	Progress  func(WriteProgress)
	Topic     models.TopicMetadata
}

WriteVaultOptions bundles the rendered vault payload written to disk.

type WriteVaultResult

type WriteVaultResult struct {
	RawDocumentsWritten   int
	WikiDocumentsWritten  int
	IndexDocumentsWritten int
}

WriteVaultResult reports how many managed markdown documents were written.

func WriteVault

func WriteVault(ctx context.Context, options WriteVaultOptions) (WriteVaultResult, error)

WriteVault persists the rendered markdown and base files for a topic.

Jump to

Keyboard shortcuts

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