knowledge

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(root, id string, input NewConcept, force bool) (string, error)

func CanonicalID

func CanonicalID(value string) (string, error)

func IsSingleBundleRoot

func IsSingleBundleRoot(root string) (bool, error)

IsSingleBundleRoot reports whether root uses the single-bundle mode.

func Move

func Move(root, oldID, newID string) (int, error)

func UpdateIndexes

func UpdateIndexes(root string, checkOnly bool) ([]string, error)

Types

type Backlink struct {
	Concept *Concept
	Link    Link
}

type Bundle

type Bundle struct {
	Root     string
	Title    string
	Concepts []*Concept
	ByID     map[string]*Concept
	Markdown map[string]string
}

func Load

func Load(root string) (*Bundle, error)
func (b *Bundle) Backlinks(id string) ([]Backlink, error)

func (*Bundle) ConceptPath

func (b *Bundle) ConceptPath(id string) (string, string, error)

func (*Bundle) ConceptsUnder

func (b *Bundle) ConceptsUnder(prefix string, recursive bool) []*Concept

ConceptsUnder returns concepts in a directory, optionally including nested directories.

func (*Bundle) Get

func (b *Bundle) Get(id string) (*Concept, error)

func (*Bundle) Graph

func (b *Bundle) Graph(id string, maxDepth int) ([]GraphNode, error)

func (*Bundle) Outgoing

func (b *Bundle) Outgoing(id string) ([]Link, error)

type BundleValidationStats

type BundleValidationStats struct {
	Name                  string
	Root                  string
	MarkdownFiles         int
	ReservedFiles         int
	ConceptFiles          int
	LoadedConcepts        int
	InvalidConceptFiles   int
	LinksChecked          int
	BrokenLinks           int
	StaleGeneratedIndexes int
}

type Concept

type Concept struct {
	ID          string
	RelPath     string
	AbsPath     string
	Metadata    map[string]any
	Type        string
	Title       string
	Description string
	Tags        []string
	Body        string
	Links       []Link
}

type ConceptRef

type ConceptRef struct {
	BundleName string
	Bundle     *Bundle
	Concept    *Concept
}

ConceptRef identifies a concept together with the bundle that owns it.

type GraphNode

type GraphNode struct {
	Concept *Concept
	Depth   int
}

type Issue

type Issue struct {
	Path    string `json:"path"`
	Message string `json:"message"`
}
type Link struct {
	Label      string
	RawTarget  string
	TargetPath string
	TargetID   string
	External   bool
	Broken     bool
}

type NewConcept

type NewConcept struct {
	Type        string
	Title       string
	Description string
	Tags        []string
}

type SearchOptions

type SearchOptions struct {
	Tag   string
	Type  string
	Path  string
	Limit int
}

type SearchResult

type SearchResult struct {
	Concept *Concept
	Score   float64
}
func Search(bundle *Bundle, query string, options SearchOptions) []SearchResult

type SearchResultRef

type SearchResultRef struct {
	BundleName string
	Concept    *Concept
	Score      float64
}

SearchResultRef is a workspace-qualified search result.

type ValidationReport

type ValidationReport struct {
	Errors   []Issue
	Warnings []Issue
	Stats    ValidationStats
	Bundles  []BundleValidationStats
}

func Validate

func Validate(root string, strict bool) (ValidationReport, error)

func ValidateWorkspaceRoot

func ValidateWorkspaceRoot(root string, strict bool) (ValidationReport, error)

ValidateWorkspaceRoot validates a single bundle or all direct child bundles without loading concepts into the in-memory Bundle model first.

func (*ValidationReport) AddError

func (r *ValidationReport) AddError(path, message string)

func (*ValidationReport) AddWarning

func (r *ValidationReport) AddWarning(path, message string)

func (ValidationReport) Sort

func (r ValidationReport) Sort()

func (ValidationReport) Valid

func (r ValidationReport) Valid() bool

type ValidationStats

type ValidationStats struct {
	Root                  string
	Mode                  string
	Bundles               int
	MarkdownFiles         int
	ReservedFiles         int
	ConceptFiles          int
	LoadedConcepts        int
	InvalidConceptFiles   int
	LinksChecked          int
	BrokenLinks           int
	StaleGeneratedIndexes int
}

type Workspace

type Workspace struct {
	Root       string
	SingleRoot bool
	Bundles    []*Bundle
	ByName     map[string]*Bundle
}

Workspace coordinates one bundle or a directory containing direct child bundles.

func LoadWorkspace

func LoadWorkspace(root string) (*Workspace, error)

LoadWorkspace loads root as one bundle or discovers its direct child bundles.

func (*Workspace) QualifyID

func (w *Workspace) QualifyID(bundleName, localID string) string

QualifyID converts a bundle-local ID to the CLI ID for this workspace.

func (*Workspace) ResolveConcept

func (w *Workspace) ResolveConcept(value string) (*ConceptRef, error)

ResolveConcept resolves a local ID in a single bundle or a qualified ID in a workspace.

func (*Workspace) ResolveDirectory

func (w *Workspace) ResolveDirectory(value string) (*Bundle, string, string, error)

ResolveDirectory resolves a workspace directory path to its owning bundle and local prefix. An empty prefix in workspace mode refers to the workspace itself and returns a nil bundle.

func (*Workspace) Search

func (w *Workspace) Search(query string, options SearchOptions) ([]SearchResultRef, error)

Search searches all bundles, applying a qualified path filter when supplied.

func (*Workspace) Validate

func (w *Workspace) Validate(strict bool) (ValidationReport, error)

ValidateWorkspace validates each bundle and prefixes issues with its workspace path.

Jump to

Keyboard shortcuts

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