index

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package index is a memory-only full-text index of skills (spec 125, D12).

It is built from scratch by Replace and never written to disk. It uses the same analyzers as the tool index, so ranking behaves like retrieve_tools. The package imports nothing from this module: the runtime decides which skills go in and re-checks every hit against live state.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("skills index is closed")

ErrClosed is returned by a closed index.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	ID, Server, Path, URI, Name, Description string
}

Doc is one skill to index. ID is "server:skill-path"; URI is the skill's address on its server, which is the key of its record.

type Hit

type Hit struct {
	ID, Server, Path, URI string
	Score                 float64
}

Hit is one search result, best first.

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index holds the current generation; Replace swaps it atomically.

func New

func New() (*Index, error)

New returns an empty index.

func (*Index) Close

func (ix *Index) Close() error

Close releases the index; it is safe to call twice.

func (*Index) Len

func (ix *Index) Len() int

Len is the number of documents in the current index.

func (*Index) Replace

func (ix *Index) Replace(docs []Doc) error

Replace builds a fresh index from docs and swaps it in. A search that is running sees the old index or the new one, never a half-built one.

func (*Index) Search

func (ix *Index) Search(query string, limit int) (hits []Hit, total int, err error)

Search returns up to limit hits, best first, ties broken by id, and the number of documents that match at all. An empty or blank query returns nothing.

Jump to

Keyboard shortcuts

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