models

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: 2 Imported by: 0

Documentation

Overview

Package models defines shared domain types, interfaces, and snapshot structures used across the kb CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedLanguageNames added in v0.0.5

func SupportedLanguageNames() []string

SupportedLanguageNames returns every supported language name in stable order.

Types

type BaseDefinition

type BaseDefinition struct {
	Filters    *BaseFilter             `json:"filters,omitempty"`
	Formulas   map[string]string       `json:"formulas,omitempty"`
	Properties map[string]BaseProperty `json:"properties,omitempty"`
	Views      []BaseView              `json:"views"`
}

BaseDefinition is the persisted definition of an Obsidian Base file.

type BaseFile

type BaseFile struct {
	Definition   BaseDefinition `json:"definition"`
	RelativePath string         `json:"relativePath"`
}

BaseFile describes one generated Obsidian Base file.

type BaseFilter

type BaseFilter struct {
	Expression string       `json:"expression,omitempty"`
	And        []BaseFilter `json:"and,omitempty"`
	Or         []BaseFilter `json:"or,omitempty"`
	Not        *BaseFilter  `json:"not,omitempty"`
}

BaseFilter is a recursive Obsidian Base filter tree.

type BaseGroupBy

type BaseGroupBy struct {
	Direction string `json:"direction"`
	Property  string `json:"property"`
}

BaseGroupBy configures the grouping rule for a Base view.

type BaseProperty

type BaseProperty struct {
	DisplayName string `json:"displayName"`
}

BaseProperty configures the display metadata for a Base property.

type BaseView

type BaseView struct {
	Filters   *BaseFilter       `json:"filters,omitempty"`
	GroupBy   *BaseGroupBy      `json:"groupBy,omitempty"`
	Name      string            `json:"name"`
	Order     []string          `json:"order"`
	Summaries map[string]string `json:"summaries,omitempty"`
	Type      BaseViewType      `json:"type"`
}

BaseView configures a single Obsidian Base view.

type BaseViewType

type BaseViewType string

BaseViewType identifies the Obsidian Base view mode.

const (
	// ViewTable renders a table-based Base view.
	ViewTable BaseViewType = "table"
	// ViewCards renders a card-based Base view.
	ViewCards BaseViewType = "cards"
	// ViewList renders a list-based Base view.
	ViewList BaseViewType = "list"
)

type ConvertInput

type ConvertInput struct {
	Reader   io.ReadSeeker  `json:"-"`
	FilePath string         `json:"filePath,omitempty"`
	URL      string         `json:"url,omitempty"`
	Options  map[string]any `json:"options,omitempty"`
}

ConvertInput carries the source content and metadata needed for conversion.

type ConvertResult

type ConvertResult struct {
	Markdown string         `json:"markdown,omitempty"`
	Title    string         `json:"title,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

ConvertResult contains the Markdown output and metadata from a conversion.

type Converter

type Converter interface {
	// Accepts reports whether the converter supports the given file extension
	// and/or MIME type.
	Accepts(ext string, mimeType string) bool
	// Convert reads from the source and produces Markdown content plus metadata.
	Convert(ctx context.Context, input ConvertInput) (*ConvertResult, error)
}

Converter transforms a source into Markdown content.

type DiagnosticSeverity

type DiagnosticSeverity string

DiagnosticSeverity indicates the severity of a structured diagnostic.

const (
	// SeverityWarning is used for recoverable issues.
	SeverityWarning DiagnosticSeverity = "warning"
	// SeverityError is used for blocking issues.
	SeverityError DiagnosticSeverity = "error"
)

type DiagnosticStage

type DiagnosticStage string

DiagnosticStage indicates the pipeline stage that produced a diagnostic.

const (
	// StageScan indicates scan-time diagnostics.
	StageScan DiagnosticStage = "scan"
	// StageParse indicates parse-time diagnostics.
	StageParse DiagnosticStage = "parse"
	// StageRender indicates render-time diagnostics.
	StageRender DiagnosticStage = "render"
	// StageWrite indicates write-time diagnostics.
	StageWrite DiagnosticStage = "write"
	// StageValidate indicates validation-time diagnostics.
	StageValidate DiagnosticStage = "validate"
)

type DirectoryMetrics

type DirectoryMetrics struct {
	AfferentCoupling int     `json:"afferentCoupling"`
	EfferentCoupling int     `json:"efferentCoupling"`
	Instability      float64 `json:"instability"`
}

DirectoryMetrics stores aggregated metrics for a directory.

type DocumentKind

type DocumentKind string

DocumentKind identifies the rendered markdown document bucket.

const (
	// DocRaw marks a raw source snapshot document.
	DocRaw DocumentKind = "raw"
	// DocWiki marks a compiled wiki concept article.
	DocWiki DocumentKind = "wiki"
	// DocIndex marks a generated index page.
	DocIndex DocumentKind = "index"
)

type ExternalNode

type ExternalNode struct {
	ID       string `json:"id"`
	NodeType string `json:"nodeType"`
	Source   string `json:"source"`
	Label    string `json:"label"`
}

ExternalNode represents an imported module or package outside the graph.

type FileMetrics

type FileMetrics struct {
	AfferentCoupling      int      `json:"afferentCoupling"`
	EfferentCoupling      int      `json:"efferentCoupling"`
	HasCircularDependency bool     `json:"hasCircularDependency"`
	Instability           float64  `json:"instability"`
	IsEntryPoint          bool     `json:"isEntryPoint"`
	IsGodFile             bool     `json:"isGodFile"`
	IsOrphanFile          bool     `json:"isOrphanFile"`
	Smells                []string `json:"smells"`
}

FileMetrics stores computed metrics for an individual file.

type GenerateOptions

type GenerateOptions struct {
	RootPath        string   `json:"rootPath"`
	VaultPath       string   `json:"vaultPath,omitempty"`
	TopicSlug       string   `json:"topicSlug,omitempty"`
	Title           string   `json:"title,omitempty"`
	Domain          string   `json:"domain,omitempty"`
	IncludePatterns []string `json:"includePatterns,omitempty"`
	ExcludePatterns []string `json:"excludePatterns,omitempty"`
	DryRun          bool     `json:"dryRun,omitempty"`
	Semantic        bool     `json:"semantic,omitempty"`
}

GenerateOptions configures a full knowledge-base generation run.

type GenerationSummary

type GenerationSummary struct {
	Command               string                 `json:"command"`
	RootPath              string                 `json:"rootPath"`
	VaultPath             string                 `json:"vaultPath"`
	TopicPath             string                 `json:"topicPath"`
	TopicSlug             string                 `json:"topicSlug"`
	DryRun                bool                   `json:"dryRun"`
	DetectedLanguages     []string               `json:"detectedLanguages"`
	SelectedAdapters      []string               `json:"selectedAdapters"`
	FilesScanned          int                    `json:"filesScanned"`
	FilesParsed           int                    `json:"filesParsed"`
	FilesSkipped          int                    `json:"filesSkipped"`
	SymbolsExtracted      int                    `json:"symbolsExtracted"`
	RelationsEmitted      int                    `json:"relationsEmitted"`
	RawDocumentsWritten   int                    `json:"rawDocumentsWritten"`
	WikiDocumentsWritten  int                    `json:"wikiDocumentsWritten"`
	IndexDocumentsWritten int                    `json:"indexDocumentsWritten"`
	Timings               GenerationTimings      `json:"timings"`
	Diagnostics           []StructuredDiagnostic `json:"diagnostics"`
}

GenerationSummary reports the outcome of a generation run.

type GenerationTimings

type GenerationTimings struct {
	ScanMillis           int64 `json:"scanMillis"`
	SelectAdaptersMillis int64 `json:"selectAdaptersMillis"`
	ParseMillis          int64 `json:"parseMillis"`
	NormalizeMillis      int64 `json:"normalizeMillis"`
	MetricsMillis        int64 `json:"metricsMillis"`
	RenderMillis         int64 `json:"renderMillis"`
	WriteMillis          int64 `json:"writeMillis"`
	TotalMillis          int64 `json:"totalMillis"`
}

GenerationTimings reports the elapsed wall-clock time for each pipeline stage.

type GraphFile

type GraphFile struct {
	ID        string            `json:"id"`
	NodeType  string            `json:"nodeType"`
	FilePath  string            `json:"filePath"`
	Language  SupportedLanguage `json:"language"`
	ModuleDoc string            `json:"moduleDoc,omitempty"`
	SymbolIDs []string          `json:"symbolIds"`
}

GraphFile represents a parsed source file in the graph snapshot.

type GraphSnapshot

type GraphSnapshot struct {
	RootPath      string                 `json:"rootPath"`
	Files         []GraphFile            `json:"files"`
	Symbols       []SymbolNode           `json:"symbols"`
	ExternalNodes []ExternalNode         `json:"externalNodes"`
	Relations     []RelationEdge         `json:"relations"`
	Diagnostics   []StructuredDiagnostic `json:"diagnostics"`
}

GraphSnapshot is the merged graph output across all parsed files.

type IngestResult

type IngestResult struct {
	Topic      string     `json:"topic"`
	SourceType SourceKind `json:"sourceType"`
	FilePath   string     `json:"filePath"`
	Title      string     `json:"title"`
}

IngestResult represents a successfully ingested source.

type LanguageAdapter

type LanguageAdapter interface {
	Supports(lang SupportedLanguage) bool
	ParseFiles(files []ScannedSourceFile, rootPath string) ([]ParsedFile, error)
}

LanguageAdapter parses source files for a specific language into graph nodes.

type LintIssue

type LintIssue struct {
	Kind     LintIssueKind      `json:"kind"`
	Severity DiagnosticSeverity `json:"severity"`
	FilePath string             `json:"filePath,omitempty"`
	Message  string             `json:"message"`
	Target   string             `json:"target,omitempty"`
}

LintIssue represents a single structural problem found in the vault.

type LintIssueKind

type LintIssueKind string

LintIssueKind identifies the structural lint issue category.

const (
	// LintIssueKindDeadLink marks a dead wikilink or reference.
	LintIssueKindDeadLink LintIssueKind = "dead-link"
	// LintIssueKindOrphan marks content with no inbound references.
	LintIssueKindOrphan LintIssueKind = "orphan"
	// LintIssueKindMissingSource marks missing referenced source material.
	LintIssueKindMissingSource LintIssueKind = "missing-source"
	// LintIssueKindStale marks content that is older than its source material.
	LintIssueKindStale LintIssueKind = "stale"
	// LintIssueKindFormat marks frontmatter or structural format violations.
	LintIssueKindFormat LintIssueKind = "format"
)

func LintIssueKinds

func LintIssueKinds() []LintIssueKind

LintIssueKinds returns every lint issue kind in stable order.

type ManagedArea

type ManagedArea string

ManagedArea identifies the managed subtree within a generated topic.

const (
	// AreaRawCodebase stores generated raw source snapshots.
	AreaRawCodebase ManagedArea = "raw-codebase"
	// AreaWikiConcept stores generated wiki concept articles.
	AreaWikiConcept ManagedArea = "wiki-concept"
	// AreaWikiIndex stores generated wiki index pages.
	AreaWikiIndex ManagedArea = "wiki-index"
)

type MetricsResult

type MetricsResult struct {
	// CircularDependencies stores cyclic file groups, one per strongly connected
	// component with more than one file.
	CircularDependencies [][]string                  `json:"circularDependencies"`
	Directories          map[string]DirectoryMetrics `json:"directories"`
	Files                map[string]FileMetrics      `json:"files"`
	Symbols              map[string]SymbolMetrics    `json:"symbols"`
}

MetricsResult contains every computed metrics view for a graph snapshot.

type ParsedFile

type ParsedFile struct {
	File          GraphFile              `json:"file"`
	Symbols       []SymbolNode           `json:"symbols"`
	ExternalNodes []ExternalNode         `json:"externalNodes"`
	Relations     []RelationEdge         `json:"relations"`
	Diagnostics   []StructuredDiagnostic `json:"diagnostics"`
}

ParsedFile is the adapter output for one source file.

type RelationConfidence

type RelationConfidence string

RelationConfidence captures how strongly a relation is known.

const (
	// ConfidenceSemantic indicates a semantically resolved edge.
	ConfidenceSemantic RelationConfidence = "semantic"
	// ConfidenceSyntactic indicates a purely syntactic edge.
	ConfidenceSyntactic RelationConfidence = "syntactic"
)

type RelationEdge

type RelationEdge struct {
	FromID     string             `json:"fromId"`
	ToID       string             `json:"toId"`
	Type       RelationType       `json:"type"`
	Confidence RelationConfidence `json:"confidence"`
}

RelationEdge connects two graph nodes.

type RelationType

type RelationType string

RelationType identifies a graph edge type between parsed nodes.

const (
	// RelImports indicates an import edge from a file to another file or module.
	RelImports RelationType = "imports"
	// RelExports indicates a file exports a symbol.
	RelExports RelationType = "exports"
	// RelCalls indicates one symbol calls another symbol.
	RelCalls RelationType = "calls"
	// RelReferences indicates a non-call reference edge.
	RelReferences RelationType = "references"
	// RelDeclares indicates a declaration edge.
	RelDeclares RelationType = "declares"
	// RelContains indicates containment from a file to a symbol.
	RelContains RelationType = "contains"
)

type RenderedDocument

type RenderedDocument struct {
	Kind         DocumentKind           `json:"kind"`
	ManagedArea  ManagedArea            `json:"managedArea"`
	RelativePath string                 `json:"relativePath"`
	Frontmatter  map[string]interface{} `json:"frontmatter"`
	Body         string                 `json:"body"`
}

RenderedDocument is the in-memory representation of a generated markdown file.

type ScannedSourceFile

type ScannedSourceFile struct {
	AbsolutePath string            `json:"absolutePath"`
	RelativePath string            `json:"relativePath"`
	Language     SupportedLanguage `json:"language"`
}

ScannedSourceFile describes a supported source file discovered in a workspace scan.

type ScannedWorkspace

type ScannedWorkspace struct {
	Files           []ScannedSourceFile                       `json:"files"`
	FilesByLanguage map[SupportedLanguage][]ScannedSourceFile `json:"filesByLanguage"`
}

ScannedWorkspace contains the files discovered during workspace scanning.

type SourceKind

type SourceKind string

SourceKind identifies the source category for ingested KB content.

const (
	// SourceKindArticle marks a general article source.
	SourceKindArticle SourceKind = "article"
	// SourceKindGitHubREADME marks an ingested GitHub README.
	SourceKindGitHubREADME SourceKind = "github-readme"
	// SourceKindYouTubeTranscript marks an ingested YouTube transcript.
	SourceKindYouTubeTranscript SourceKind = "youtube-transcript"
	// SourceKindCodebaseFile marks a codebase file snapshot.
	SourceKindCodebaseFile SourceKind = "codebase-file"
	// SourceKindCodebaseSymbol marks a codebase symbol snapshot.
	SourceKindCodebaseSymbol SourceKind = "codebase-symbol"
	// SourceKindBookmarkCluster marks an ingested bookmark cluster.
	SourceKindBookmarkCluster SourceKind = "bookmark-cluster"
	// SourceKindDocument marks a general uploaded document.
	SourceKindDocument SourceKind = "document"
)

func SourceKinds

func SourceKinds() []SourceKind

SourceKinds returns every source kind in stable order.

type StructuredDiagnostic

type StructuredDiagnostic struct {
	Code     string             `json:"code"`
	Severity DiagnosticSeverity `json:"severity"`
	Stage    DiagnosticStage    `json:"stage"`
	Message  string             `json:"message"`
	FilePath string             `json:"filePath,omitempty"`
	Language SupportedLanguage  `json:"language,omitempty"`
	Detail   string             `json:"detail,omitempty"`
}

StructuredDiagnostic is a machine-readable issue emitted during processing.

type SupportedLanguage

type SupportedLanguage string

SupportedLanguage identifies a source language handled by the pipeline.

const (
	// LangTS represents TypeScript source files.
	LangTS SupportedLanguage = "ts"
	// LangTSX represents TSX source files.
	LangTSX SupportedLanguage = "tsx"
	// LangJS represents JavaScript source files.
	LangJS SupportedLanguage = "js"
	// LangJSX represents JSX source files.
	LangJSX SupportedLanguage = "jsx"
	// LangGo represents Go source files.
	LangGo SupportedLanguage = "go"
	// LangRust represents Rust source files.
	LangRust SupportedLanguage = "rust"
)

func SupportedLanguages

func SupportedLanguages() []SupportedLanguage

SupportedLanguages returns every supported language constant in stable order.

type SymbolMetrics

type SymbolMetrics struct {
	BlastRadius            int      `json:"blastRadius"`
	Centrality             float64  `json:"centrality"`
	DirectDependents       int      `json:"directDependents"`
	ExternalReferenceCount int      `json:"externalReferenceCount"`
	IsDeadExport           bool     `json:"isDeadExport"`
	IsLongFunction         bool     `json:"isLongFunction"`
	LOC                    int      `json:"loc"`
	Smells                 []string `json:"smells"`
}

SymbolMetrics stores computed metrics for an individual symbol.

type SymbolNode

type SymbolNode struct {
	ID                   string            `json:"id"`
	NodeType             string            `json:"nodeType"`
	Name                 string            `json:"name"`
	SymbolKind           string            `json:"symbolKind"`
	Language             SupportedLanguage `json:"language"`
	FilePath             string            `json:"filePath"`
	StartLine            int               `json:"startLine"`
	EndLine              int               `json:"endLine"`
	Signature            string            `json:"signature,omitempty"`
	DocComment           string            `json:"docComment,omitempty"`
	Exported             bool              `json:"exported"`
	CyclomaticComplexity int               `json:"cyclomaticComplexity,omitempty"`
}

SymbolNode represents a symbol declaration discovered in a file.

type TopicInfo

type TopicInfo struct {
	Slug         string `json:"slug"`
	Title        string `json:"title"`
	Domain       string `json:"domain"`
	RootPath     string `json:"rootPath"`
	ArticleCount int    `json:"articleCount"`
	SourceCount  int    `json:"sourceCount"`
	LastLogEntry string `json:"lastLogEntry,omitempty"`
}

TopicInfo captures topic metadata for list and info operations.

type TopicMetadata

type TopicMetadata struct {
	RootPath  string `json:"rootPath"`
	Title     string `json:"title"`
	Slug      string `json:"slug"`
	Domain    string `json:"domain"`
	Today     string `json:"today"`
	VaultPath string `json:"vaultPath"`
	TopicPath string `json:"topicPath"`
}

TopicMetadata captures the derived topic information for a vault render.

Jump to

Keyboard shortcuts

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