okf

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion = 3
	OKFVersion    = "0.2"
)

Variables

This section is empty.

Functions

func LoadSourceRoot

func LoadSourceRoot(sourceRoot string) (string, []byte, error)

func VerifyDistFiles

func VerifyDistFiles(distRoot string, result BuildResult) error

func WriteDistFiles

func WriteDistFiles(distRoot string, result BuildResult) error

Types

type BuildResult

type BuildResult struct {
	Bundle       Bundle
	BundleJSON   []byte
	Manifest     BundleManifest
	ManifestJSON []byte
	SHA256File   []byte
}

func BuildFromSource

func BuildFromSource(sourceRoot string) (BuildResult, error)

type Bundle

type Bundle struct {
	SchemaVersion int       `json:"schema_version"`
	OKFVersion    string    `json:"okf_version"`
	RootIndex     RootIndex `json:"root_index"`
	Concepts      []Concept `json:"concepts"`
	SourceSHA256  string    `json:"source_sha256"`
}

func LoadEmbeddedBundle

func LoadEmbeddedBundle() (Bundle, error)

func LoadSourceBundle

func LoadSourceBundle(sourceRoot string) (Bundle, []byte, error)

type BundleManifest

type BundleManifest struct {
	SchemaVersion int    `json:"schema_version"`
	OKFVersion    string `json:"okf_version"`
	ConceptCount  int    `json:"concept_count"`
	SectionCount  int    `json:"section_count"`
	EvidenceCount int    `json:"evidence_count"`
	BundleSHA256  string `json:"bundle_sha256"`
	SourceSHA256  string `json:"source_sha256"`
}

type Concept

type Concept struct {
	Path        string           `json:"path"`
	ConceptID   string           `json:"concept_id"`
	Type        string           `json:"type"`
	Title       string           `json:"title"`
	Description string           `json:"description,omitempty"`
	Resource    string           `json:"resource,omitempty"`
	Tags        []string         `json:"tags,omitempty"`
	Timestamp   string           `json:"timestamp,omitempty"`
	Frontmatter map[string]any   `json:"frontmatter,omitempty"`
	Body        string           `json:"-"`
	BodyLength  int              `json:"body_length"`
	Summary     string           `json:"summary,omitempty"`
	Sections    []ConceptSection `json:"sections,omitempty"`
	Evidence    []EvidenceRef    `json:"evidence,omitempty"`
	Legacy      bool             `json:"-"`
	HasSummary  bool             `json:"-"`
	HasContract bool             `json:"-"`
	HasBounds   bool             `json:"-"`
	HasEvidence bool             `json:"-"`
	Snippet     string           `json:"snippet,omitempty"`
	Links       []ConceptLink    `json:"links,omitempty"`
	Backlinks   []ConceptLink    `json:"backlinks,omitempty"`
}
type ConceptLink struct {
	Label     string `json:"label"`
	Path      string `json:"path"`
	ConceptID string `json:"concept_id,omitempty"`
	Title     string `json:"title,omitempty"`
}

type ConceptSection added in v0.10.0

type ConceptSection struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Level     int    `json:"level"`
	Body      string `json:"body"`
	CharCount int    `json:"char_count"`
}

type ConceptSummary added in v0.7.2

type ConceptSummary struct {
	ConceptID    string   `json:"concept_id,omitempty"`
	Path         string   `json:"path"`
	Type         string   `json:"type,omitempty"`
	Title        string   `json:"title"`
	Description  string   `json:"description,omitempty"`
	Resource     string   `json:"resource,omitempty"`
	Tags         []string `json:"tags,omitempty"`
	Summary      string   `json:"summary,omitempty"`
	SectionCount int      `json:"section_count,omitempty"`
}

type EvidenceRef added in v0.10.0

type EvidenceRef struct {
	ID          string `json:"id"`
	Source      string `json:"source"`
	Line        int    `json:"line,omitempty"`
	Description string `json:"description"`
}

type IndexEntry added in v0.7.2

type IndexEntry struct {
	ConceptSummary
}

type IndexRequest added in v0.7.2

type IndexRequest struct {
	Section string
}

type IndexResult added in v0.7.2

type IndexResult struct {
	OKFVersion    string         `json:"okf_version"`
	TotalSections int            `json:"total_sections"`
	Sections      []IndexSection `json:"sections"`
	Truncated     bool           `json:"truncated"`
}

func Index added in v0.7.2

func Index(req IndexRequest) (IndexResult, error)

func IndexBundle added in v0.7.2

func IndexBundle(bundle Bundle, req IndexRequest) IndexResult

type IndexSection added in v0.7.2

type IndexSection struct {
	Title   string       `json:"title"`
	Slug    string       `json:"slug"`
	Entries []IndexEntry `json:"entries"`
}

type OpenRequest added in v0.7.2

type OpenRequest struct {
	ConceptID       string
	Path            string
	Section         string
	BodyOffset      int
	BodyLimit       int
	IncludeEvidence bool
}

type OpenResult added in v0.7.2

type OpenResult struct {
	Concept            ConceptSummary   `json:"concept"`
	Summary            string           `json:"summary,omitempty"`
	SectionID          string           `json:"section_id,omitempty"`
	SectionTitle       string           `json:"section_title,omitempty"`
	Sections           []SectionSummary `json:"sections,omitempty"`
	Evidence           []EvidenceRef    `json:"evidence,omitempty"`
	EvidenceOmitted    bool             `json:"evidence_omitted,omitempty"`
	Body               string           `json:"body"`
	BodyOffset         int              `json:"body_offset"`
	BodyLength         int              `json:"body_length"`
	ReturnedBodyLength int              `json:"returned_body_length"`
	ConceptBodyLength  int              `json:"concept_body_length"`
	Truncated          bool             `json:"truncated"`
	Links              []ConceptLink    `json:"links"`
	Backlinks          []ConceptLink    `json:"backlinks"`
}

func Open added in v0.7.2

func Open(req OpenRequest) (OpenResult, error)

func OpenBundle added in v0.7.2

func OpenBundle(bundle Bundle, req OpenRequest) (OpenResult, error)

type QualityIssue added in v0.10.0

type QualityIssue struct {
	Level   string `json:"level"`
	Code    string `json:"code"`
	Path    string `json:"path"`
	Message string `json:"message"`
}

type QualityMode added in v0.10.0

type QualityMode string
const (
	QualityOff        QualityMode = "off"
	QualityReportMode QualityMode = "report"
	QualityStrict     QualityMode = "strict"
)

type QualityReport added in v0.10.0

type QualityReport struct {
	Issues   []QualityIssue `json:"issues"`
	Errors   int            `json:"errors"`
	Warnings int            `json:"warnings"`
}

func ValidateBundleQuality added in v0.10.0

func ValidateBundleQuality(bundle Bundle, sourceRoot string, mode QualityMode) QualityReport

func (QualityReport) SortedIssues added in v0.10.0

func (r QualityReport) SortedIssues() []QualityIssue

type RootIndex

type RootIndex struct {
	Path        string         `json:"path"`
	OKFVersion  string         `json:"okf_version"`
	Frontmatter map[string]any `json:"frontmatter,omitempty"`
	Body        string         `json:"body"`
	Sections    []IndexSection `json:"sections,omitempty"`
	Links       []ConceptLink  `json:"links,omitempty"`
}

type SearchFilters added in v0.7.2

type SearchFilters struct {
	Type string   `json:"type,omitempty"`
	Tags []string `json:"tags,omitempty"`
}

type SearchMatch

type SearchMatch struct {
	ConceptID    string   `json:"concept_id"`
	Path         string   `json:"path"`
	Type         string   `json:"type"`
	Title        string   `json:"title"`
	Description  string   `json:"description,omitempty"`
	Resource     string   `json:"resource,omitempty"`
	Tags         []string `json:"tags,omitempty"`
	Summary      string   `json:"summary,omitempty"`
	SectionID    string   `json:"section_id,omitempty"`
	SectionTitle string   `json:"section_title,omitempty"`
	Snippet      string   `json:"snippet,omitempty"`
	Score        int      `json:"score"`
}

type SearchRequest

type SearchRequest struct {
	Query      string
	MaxResults int
	Type       string
	Tags       []string
}

type SearchResult

type SearchResult struct {
	Query         string        `json:"query"`
	Filters       SearchFilters `json:"filters,omitempty"`
	TotalConcepts int           `json:"total_concepts"`
	TotalMatches  int           `json:"total_matches"`
	MatchCount    int           `json:"match_count"`
	MaxResults    int           `json:"max_results"`
	HasMore       bool          `json:"has_more"`
	OmittedCount  int           `json:"omitted_count"`
	Matches       []SearchMatch `json:"matches"`
	Truncated     bool          `json:"truncated"`
}
func Search(req SearchRequest) (SearchResult, error)

func SearchBundle added in v0.7.2

func SearchBundle(bundle Bundle, req SearchRequest) SearchResult

type SectionSummary added in v0.10.0

type SectionSummary struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Level     int    `json:"level"`
	CharCount int    `json:"char_count"`
}

Jump to

Keyboard shortcuts

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