Documentation
¶
Overview ¶
Package vault provides path resolution, document rendering, reading, writing, and query helpers for Obsidian-compatible knowledge vaults.
Index ¶
- Constants
- func CreateExternalID(source string) string
- func CreateFileID(filePath string) string
- func CreateSymbolID(symbol models.SymbolNode) string
- func DeriveTopicDomain(topicSlug string) string
- func DeriveTopicSlug(rootPath string) string
- func DeriveTopicTitle(topicSlug string) string
- func DiscoverVaultPath(cwd string) (string, error)
- func ExtractLeadingComment(sourceText string) string
- func ExtractSection(body, heading string) string
- func GetBaseFilePath(baseName string) string
- func GetRawDirectoryIndexPath(directoryPath string) string
- func GetRawFileDocumentPath(filePath string) string
- func GetRawLanguageIndexPath(language string) string
- func GetRawSymbolDocumentPath(symbol models.SymbolNode) string
- func GetTopicIndexPath(indexTitle string) string
- func GetWikiConceptPath(articleTitle string) string
- func GetWikiIndexPath(indexTitle string) string
- func HumanizeSlug(value string) string
- func IsPathInside(parentPath, targetPath string) bool
- func ListAvailableTopics(options VaultQueryOptions) ([]string, error)
- func NormalizeComment(rawComment string) string
- func RenderBaseDefinition(definition models.BaseDefinition) string
- func RenderBaseFiles(metrics models.MetricsResult) []models.BaseFile
- func RenderDocuments(graph models.GraphSnapshot, metrics models.MetricsResult, ...) []models.RenderedDocument
- func SlugifySegment(value string) string
- func StripMarkdownExtension(documentPath string) string
- func StripQuotes(value string) string
- func ToPosixPath(value string) string
- func ToTopicWikiLink(topicSlug, documentPath, label string) string
- type ReadVaultOptions
- type ResolvedVault
- type VaultDocument
- type VaultQueryOptions
- type VaultRelation
- type VaultSnapshot
- type WriteProgress
- type WriteVaultOptions
- type WriteVaultResult
Constants ¶
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 ¶
CreateExternalID creates a stable external node identifier from a module source.
func CreateFileID ¶
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 ¶
DeriveTopicDomain returns the topic domain identifier for a topic slug.
func DeriveTopicSlug ¶
DeriveTopicSlug derives the topic slug from a root path.
func DeriveTopicTitle ¶
DeriveTopicTitle converts a topic slug into a human-readable title.
func DiscoverVaultPath ¶
DiscoverVaultPath walks up from cwd until it finds a `.kb/vault` directory.
func ExtractLeadingComment ¶
ExtractLeadingComment returns the first leading block or line comment from source text.
func ExtractSection ¶
ExtractSection returns the markdown content under the named level-two heading.
func GetBaseFilePath ¶
GetBaseFilePath derives the vault document path for an Obsidian Base definition.
func GetRawDirectoryIndexPath ¶
GetRawDirectoryIndexPath derives the vault document path for a raw directory index.
func GetRawFileDocumentPath ¶
GetRawFileDocumentPath derives the vault document path for a raw file snapshot.
func GetRawLanguageIndexPath ¶
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
GetTopicIndexPath derives the vault document path for a top-level topic index page.
func GetWikiConceptPath ¶
GetWikiConceptPath derives the vault document path for a generated wiki concept article.
func GetWikiIndexPath ¶
GetWikiIndexPath derives the vault document path for a generated wiki index page.
func HumanizeSlug ¶
HumanizeSlug converts a hyphenated slug into a title-cased label.
func IsPathInside ¶
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 ¶
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 ¶
SlugifySegment converts a free-form segment into a filesystem-friendly slug.
func StripMarkdownExtension ¶
StripMarkdownExtension removes a trailing .md extension from a document path.
func StripQuotes ¶
StripQuotes removes a single leading and trailing quote character when present.
func ToPosixPath ¶
ToPosixPath normalizes path separators to forward slashes and trims trailing slashes.
func ToTopicWikiLink ¶
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 ¶
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 ¶
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.