Documentation
¶
Overview ¶
Copyright (c) 2025 Reliant Labs
Index ¶
- func FormatComponentList(entries []Entry) string
- type Category
- type Entry
- type Library
- func (l *Library) ByName() map[string]*Entry
- func (l *Library) Dependencies(name string) ([]string, error)
- func (l *Library) FindSimilar(name string) []string
- func (l *Library) Get(name string) (string, error)
- func (l *Library) GetEntry(name string) (*Entry, bool)
- func (l *Library) List(tag, category string) []Entry
- func (l *Library) Registry() []Entry
- func (l *Library) Search(query string) []Entry
- func (l *Library) SearchDetailed(query string) (entries []Entry, matched, total int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatComponentList ¶
FormatComponentList formats a list of entries into a human-readable string grouped by category.
Types ¶
type Category ¶
type Category string
Category groups components by type.
const ( CategoryLayouts Category = "layouts" CategoryCharts Category = "charts" CategoryDiagrams Category = "diagrams" CategoryDeck Category = "deck" CategoryUI Category = "ui" )
Category enum values. Each value tags a component template with the kind of artifact it produces (HTML layout, SVG chart, diagram, deck slide, or generic UI primitive).
type Entry ¶
type Entry struct {
Name string `json:"name"`
Category Category `json:"category"`
Description string `json:"description"`
Tags []string `json:"tags"`
FilePath string `json:"-"` // internal embed path
}
Entry describes a single component in the library.
type Library ¶
type Library struct{}
Library provides access to the component library.
func (*Library) Dependencies ¶ added in v1.0.0
Dependencies returns every library component that name imports, directly or through another dependency, sorted. Components install into one flat directory, so a `./x` import is a sibling file the install must also write: installing `input` alone into an empty directory otherwise leaves an import of `./form_field_context` that does not resolve.
func (*Library) FindSimilar ¶
FindSimilar returns up to 5 component names similar to the given name.
func (*Library) Search ¶
Search finds components using unified keyword search. See SearchDetailed for the semantics; this is the entries-only convenience wrapper.
func (*Library) SearchDetailed ¶
SearchDetailed finds components by keyword and reports how much of the query it was able to honour. The query is split into words; each word is matched against the component's name, tags, category, and description.
Semantics are BEST-MATCH, not bag-of-words AND. A component's match count is how many query words it hits; the result set is every component whose count equals the BEST count any component achieved, ordered by a field-weighted score (name > tag > category > description).
Why not AND: a search that gets WORSE as you describe your need more precisely is backwards, and that is exactly what AND does. `dashboard metric stat tiles` returned nothing while `dashboard metric stat` returned metric_card — one extra, more specific word emptied the library. Under best-match, adding a word that nothing carries cannot destroy a result set; it can only re-rank one. Everything a caller could want is preserved:
- one word — identical to the old behaviour;
- all words matched by something — identical to AND (best == len(words));
- nothing matched at all — still empty, so "no such component" is still distinguishable from "here is the closest thing".
Returns (entries, matched, total): `total` is the number of query words, `matched` the number the returned entries actually hit. matched < total is the caller's cue to say so rather than present a partial hit as exact.