Documentation
¶
Overview ¶
Package model defines canonical types for core Raven concepts. These types are the single source of truth used across all layers: database, query execution, CLI output, and MCP tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Numbered ¶
type Numbered[T Result] struct { // Num is the 1-indexed result number for user reference. Num int `json:"num"` // Item is the underlying result. Item T `json:"item"` }
Numbered wraps any Result with a 1-indexed number for user reference. This is used by commands that return lists (query, backlinks, search) to enable selection via `rvn last 1,3,5`.
func NumberedList ¶
NumberedList converts a slice of results to numbered results.
func (Numbered[T]) GetContent ¶
GetContent delegates to the underlying item.
func (Numbered[T]) GetLocation ¶
GetLocation delegates to the underlying item.
type Object ¶
type Object struct {
// ID uniquely identifies this object.
// Typically the file path without extension, e.g., "people/alice".
ID string `json:"id"`
// Type is the type of this object (e.g., "person", "project").
Type string `json:"type"`
// Fields contains the frontmatter field values, parsed from YAML.
Fields map[string]interface{} `json:"fields,omitempty"`
// FilePath is the path to the file containing this object,
// relative to the vault root.
FilePath string `json:"file_path"`
// LineStart is the 1-indexed line number where this object starts.
LineStart int `json:"line_start"`
// ParentID is the ID of the parent object, if this object is nested.
// Nil for top-level objects.
ParentID *string `json:"parent_id,omitempty"`
}
Object represents an instance of a typed object in the vault. Objects are markdown files with frontmatter that defines their type and fields.
func (Object) GetContent ¶
GetContent returns a human-readable description for display. Uses the object ID (typically the file basename).
func (Object) GetLocation ¶
GetLocation returns a short location string (file:line).
type Reference ¶
type Reference struct {
// SourceID is the ID of the object or trait containing the reference.
SourceID string `json:"source_id"`
// SourceType indicates whether the source is an "object" or "trait".
SourceType string `json:"source_type"`
// TargetRaw is the raw target as written in the wikilink.
TargetRaw string `json:"target_raw"`
// FilePath is the path to the file containing this reference.
FilePath string `json:"file_path"`
// Line is the 1-indexed line number where this reference appears.
// May be nil if the reference is in frontmatter.
Line *int `json:"line,omitempty"`
// DisplayText is the display text of the wikilink, if different from target.
DisplayText *string `json:"display_text,omitempty"`
}
Reference represents a wikilink reference from one location to another. This is used for both backlinks (who references X?) and outlinks (what does X reference?).
func (Reference) GetContent ¶
GetContent returns a human-readable description for display.
func (Reference) GetLocation ¶
GetLocation returns a short location string (file:line).
type Result ¶
type Result interface {
GetID() string
GetKind() string // "trait", "object", "reference", "search"
GetContent() string
GetLocation() string
}
Result is the interface implemented by all result types. This allows uniform handling in display and numbered reference systems.
type SearchMatch ¶
type SearchMatch struct {
// ObjectID is the ID of the object containing the match.
ObjectID string `json:"object_id"`
// Title is the title of the matched document.
Title string `json:"title"`
// FilePath is the path to the file containing the match.
FilePath string `json:"file_path"`
// Snippet is the matched text with surrounding context.
// Match boundaries are marked with » and «.
Snippet string `json:"snippet"`
// Rank is the FTS5 BM25 ranking score (lower is better match).
Rank float64 `json:"rank"`
}
SearchMatch represents a full-text search result.
func (SearchMatch) GetContent ¶
func (s SearchMatch) GetContent() string
GetContent returns the snippet for display.
func (SearchMatch) GetID ¶
func (s SearchMatch) GetID() string
GetID returns the object ID as the search match identifier.
func (SearchMatch) GetKind ¶
func (s SearchMatch) GetKind() string
GetKind returns "search" for search match results.
func (SearchMatch) GetLocation ¶
func (s SearchMatch) GetLocation() string
GetLocation returns the file path as location.
type Trait ¶
type Trait struct {
// ID uniquely identifies this trait instance.
// Format: "file/path.md:trait:N" where N is the trait index in the file.
ID string `json:"id"`
// TraitType is the name of the trait (e.g., "todo", "due", "highlight").
TraitType string `json:"trait_type"`
// Value is the trait's value, if any. Nil for boolean traits like @highlight.
Value *string `json:"value,omitempty"`
// Content is the text content of the line containing this trait,
// with trait annotations removed.
Content string `json:"content"`
// FilePath is the path to the file containing this trait,
// relative to the vault root.
FilePath string `json:"file_path"`
// Line is the 1-indexed line number where this trait appears.
Line int `json:"line"`
// ParentObjectID is the ID of the object containing this trait.
// This is the nearest ancestor object in the document hierarchy.
ParentObjectID string `json:"parent_object_id"`
}
Trait represents an instance of a trait annotation in the vault. Examples: @todo, @todo(done), @due(2025-01-25), @highlight
func (Trait) GetContent ¶
GetContent returns a human-readable description for display.
func (Trait) GetLocation ¶
GetLocation returns a short location string (file:line).