Documentation
¶
Index ¶
- func NewChiAPI() (chi.Router, huma.API)
- func ParseFrontmatter(content string) (map[string]interface{}, string, error)
- func RegisterRoutes(api huma.API, router chi.Router, store *Store, storage platform.Storage)
- func Unpack(r io.Reader, destDir string) error
- type Alias
- type FileEntry
- type Skill
- type Store
- func (s *Store) BulkSetReview(ctx context.Context, names []string, reviewedBy string) (int, error)
- func (s *Store) ClearReview(ctx context.Context, name string) error
- func (s *Store) Create(ctx context.Context, name, displayName, description, content string, ...) (*Skill, error)
- func (s *Store) CreateAlias(ctx context.Context, alias, canonical string) error
- func (s *Store) CreateVersion(ctx context.Context, skillID, archivePath, checksum, changelog string, ...) (*Version, error)
- func (s *Store) Delete(ctx context.Context, name string) error
- func (s *Store) DeleteAlias(ctx context.Context, alias string) error
- func (s *Store) GetByName(ctx context.Context, name string) (*Skill, error)
- func (s *Store) GetVersion(ctx context.Context, skillName string, version int) (*Version, error)
- func (s *Store) List(ctx context.Context, limit, offset int) ([]Skill, int, error)
- func (s *Store) ListAliases(ctx context.Context, canonical string) ([]Alias, error)
- func (s *Store) ListVersions(ctx context.Context, skillName string) ([]Version, error)
- func (s *Store) Merge(ctx context.Context, sourceName, targetName string) (*Skill, error)
- func (s *Store) ResolveAlias(ctx context.Context, name string) (string, error)
- func (s *Store) Search(ctx context.Context, query string, limit int) ([]Skill, error)
- func (s *Store) SetReview(ctx context.Context, name, reviewedBy string) error
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewChiAPI ¶
NewChiAPI creates a new Chi router and Huma API suitable for production and tests. Returns both so callers can mount additional middleware on the router or serve it directly.
func ParseFrontmatter ¶
ParseFrontmatter parses YAML frontmatter from content delimited by "---\n" blocks. It returns the frontmatter as a map, the body (content after the closing delimiter), and any error.
If no frontmatter is found (content does not start with "---\n"), it returns nil, content, nil.
func RegisterRoutes ¶
RegisterRoutes wires up all skill-related HTTP endpoints onto the provided Huma API and Chi router. The router is needed for the two raw-response routes (download + scan) that stream bytes rather than returning JSON.
Types ¶
type Skill ¶
type Skill struct {
ID string `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description"`
Content string `json:"content,omitempty"`
LatestVersion int `json:"latest_version"`
Frontmatter json.RawMessage `json:"frontmatter"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ReviewedAt *time.Time `json:"reviewed_at"`
ReviewedBy string `json:"reviewed_by"`
}
Skill represents a skill entry in the registry.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles Postgres persistence for skills and their versions.
func (*Store) BulkSetReview ¶
BulkSetReview marks multiple skills as reviewed in a single UPDATE. Returns the number of rows actually updated.
func (*Store) ClearReview ¶
ClearReview removes the review mark from a skill.
func (*Store) Create ¶
func (s *Store) Create(ctx context.Context, name, displayName, description, content string, frontmatter json.RawMessage) (*Skill, error)
Create inserts a new skill row and returns the created record.
func (*Store) CreateAlias ¶
func (*Store) CreateVersion ¶
func (s *Store) CreateVersion( ctx context.Context, skillID, archivePath, checksum, changelog string, description, content string, frontmatter json.RawMessage, manifest []FileEntry, scanResult json.RawMessage, ) (*Version, error)
CreateVersion increments latest_version on the parent skill, updates its description/content/frontmatter, and inserts a new skill_versions row, all within a single transaction.
func (*Store) GetByName ¶
GetByName retrieves a skill by its unique name. Returns nil, nil when not found.
func (*Store) GetVersion ¶
GetVersion retrieves a specific version of a skill. Returns nil, nil if not found.
func (*Store) ListAliases ¶
func (*Store) ListVersions ¶
ListVersions returns all versions for a skill ordered by version DESC.
func (*Store) ResolveAlias ¶
func (*Store) Search ¶
Search returns skills matching the given query using a combination of Postgres full-text search (websearch_to_tsquery + ts_rank on search_vector) and pg_trgm fuzzy name matching (similarity()). Results are returned where either FTS matches OR name similarity exceeds 0.2, ordered by FTS rank then trigram rank. Limit caps the number of returned results.
type Version ¶
type Version struct {
ID string `json:"id"`
SkillID string `json:"skill_id"`
Version int `json:"version"`
ArchivePath string `json:"-"`
Checksum string `json:"checksum"`
Changelog string `json:"changelog"`
Frontmatter json.RawMessage `json:"frontmatter"`
FileManifest []FileEntry `json:"file_manifest"`
ScanResult json.RawMessage `json:"scan_result,omitempty"`
PublishedBy string `json:"published_by"`
CreatedAt time.Time `json:"created_at"`
}
Version represents a specific published version of a skill.